Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support IPv6 addresses during fingerprinting #2536

Merged
merged 10 commits into from
Apr 10, 2017
Merged

Conversation

diptanu
Copy link
Contributor

@diptanu diptanu commented Apr 7, 2017

This enables the Nomad fingerprinter to pick up IPv6 addresses. Once this is merged I will add a note in the documentation that Nomad may pick either an IPv4 or an IPv6 address on a dual stack system if an interface has both ipv4 and ipv6 addresses.

@diptanu diptanu requested a review from dadgar April 7, 2017 23:09
Copy link
Contributor

@dadgar dadgar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we special case loopback:

"Resources": {
        "CPU": 8709,
        "DiskMB": 32814,
        "IOPS": 0,
        "MemoryMB": 2000,
        "Networks": [
            {
                "CIDR": "127.0.0.1/32",
                "DynamicPorts": null,
                "IP": "127.0.0.1",
                "MBits": 1000,
                "Public": false,
                "ReservedPorts": null
            },
            {
                "CIDR": "::1/128",
                "DynamicPorts": null,
                "IP": "::1",
                "MBits": 1000,
                "Public": false,
                "ReservedPorts": null
            }
        ]
    },

// Add the network resources to the node
for _, nwResource := range nwResources {
node.Resources.Networks = append(node.Resources.Networks, nwResource)
f.logger.Printf("[DEBUG] fingerprint.network: Detected interface %v with IP: %v, CIDR: %v during fingerprinting",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove during fingerprinting. The prefix is fingerprint.network :)

var ip net.IP
switch v := (addr).(type) {
case *net.IPNet:
ip = v.IP
newNetwork.IP = v.IP.String()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this get overrides right below?

node.Resources.Networks = append(node.Resources.Networks, newNetwork)
// Add the network resources to the node
for _, nwResource := range nwResources {
node.Resources.Networks = append(node.Resources.Networks, nwResource)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node.Resources.Networks = nwResource outside of the loop?

case *net.IPAddr:
ip = v.IP
}

// If the ip is link-local then we ignore it
if ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get a test around these and IPv4/6 CIDRs

return false, fmt.Errorf("Unable to find IP address of interface: %s, err: %v", intf.Name, err)
}

newNetwork.Device = intf.Name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to set device name

Copy link
Contributor Author

@diptanu diptanu Apr 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@dadgar dadgar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -95,6 +95,7 @@ func (f *NetworkFingerprint) Fingerprint(cfg *config.Config, node *structs.Node)
f.logger.Printf("[DEBUG] fingerprint.network: Detected interface %v with IP: %v", intf.Name, nwResource.IP)
}

// Deprectaed, setting the first IP as unique IP for the node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprectaed -> Deprecated

@github-actions
Copy link

github-actions bot commented Apr 2, 2023

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants