-
Notifications
You must be signed in to change notification settings - Fork 137
Added logic to read NetworkInfo from /state.json. #266
Changes from 3 commits
813abb9
122a285
e054373
6e0b1ae
4622dac
1b88053
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,9 +46,22 @@ type Label struct { | |
|
||
// Status holds a task status as defined in the /state.json Mesos HTTP endpoint. | ||
type Status struct { | ||
Timestamp float64 `json:"timestamp"` | ||
State string `json:"state"` | ||
Labels []Label `json:"labels,omitempty"` | ||
Timestamp float64 `json:"timestamp"` | ||
State string `json:"state"` | ||
Labels []Label `json:"labels,omitempty"` | ||
ContainerStatus ContainerStatus `json:"container_status,omitempty"` | ||
} | ||
|
||
// ContainerStatus holds container metadata as defined in the /state.json | ||
// Mesos HTTP endpoint. | ||
type ContainerStatus struct { | ||
NetworkInfos []NetworkInfo `json:"network_infos,omitempty"` | ||
} | ||
|
||
// NetworkInfo holds a network address resolution as defined in the | ||
// /state.json Mesos HTTP endpoint. | ||
type NetworkInfo struct { | ||
IPAddress string `json:"ip_address,omitempty"` | ||
} | ||
|
||
// Task holds a task as defined in the /state.json Mesos HTTP endpoint. | ||
|
@@ -103,7 +116,18 @@ func (t *Task) containerIP(src string) string { | |
continue | ||
} | ||
|
||
// find the latest docker-inspect label | ||
// first try to extract the address from the NetworkInfo structure | ||
if len(status.ContainerStatus.NetworkInfos) > 0 { | ||
// TODO(CD): handle multiple NetworkInfo objects | ||
// TODO(CD): only create A records if the address is IPv4 | ||
// TODO(CD): create AAAA records if the address is IPv6 | ||
latestContainerIP = status.ContainerStatus.NetworkInfos[0].IPAddress | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may be interesting to filter on label here at some point in the future when there are multiple IPs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not even sure what Mesos-DNS should do when there are multiple addreses assigned. I think we'd need conventions for handling additional metadata to give us clues (e.g. labels on NetworkInfo, etc.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, it's not clear to me either how mesos-dns should respond in On Wed, Sep 16, 2015 at 7:15 PM, Connor Doyle [email protected]
|
||
latestTimestamp = status.Timestamp | ||
continue // Skip label inspection step below for this element | ||
} | ||
|
||
// next, fall back to the docker-inspect label | ||
// TODO(CD): deprecate and then remove this address discovery method | ||
for _, label := range status.Labels { | ||
if label.Key == ipLabel { | ||
latestContainerIP = label.Value | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we know if the
IPAddress
is v4 or v6? Are all clients supposed to try parsing one and then fallback?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly. Using a string here was seen as a better alternative than trying to come up with a clever packed representation.