Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions records/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ type context struct {
slaveID string
taskIPs []net.IP
slaveIPs []string
containerIP string
}

func (rg *RecordGenerator) taskRecord(task state.Task, f state.Framework, domain string, spec labels.Func, ipSources []string, enumFW *EnumerableFramework) {
Expand All @@ -409,6 +410,7 @@ func (rg *RecordGenerator) taskRecord(task state.Task, f state.Framework, domain
slaveIDTail(task.SlaveID),
task.IPs(ipSources...),
task.SlaveIPs,
task.ContainerIPAddress(),
}

// use DiscoveryInfo name if defined instead of task name
Expand Down Expand Up @@ -454,6 +456,9 @@ func (rg *RecordGenerator) taskContextRecord(ctx context, task state.Task, f sta
rg.insertTaskRR(canonical+".slave"+tail, sIPStr, A, enumTask)
}
}
if ctx.containerIP != "" {
rg.insertTaskRR(arec+".container"+tail, ctx.containerIP, A, enumTask)
}

// recordName generates records for ctx.taskName, given some generation chain
recordName := func(gen chain) { gen("_" + ctx.taskName) }
Expand Down
9 changes: 9 additions & 0 deletions records/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ func (t *Task) IPs(srcs ...string) (ips []net.IP) {
return ips
}

func (t *Task) ContainerIPAddress() string{
for _, status := range(t.Statuses) {
if status.State == "TASK_RUNNING" {
return status.ContainerStatus.NetworkInfos[0].IPAddresses[0].IPAddress
}
}
return ""
}

// sources maps the string representation of IP sources to their functions.
var sources = map[string]func(*Task) []string{
"host": hostIPs,
Expand Down