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

honor config.NetworkInterface in NodeNetworks #8486

Merged
merged 1 commit into from
Jul 22, 2020

Conversation

notnoop
Copy link
Contributor

@notnoop notnoop commented Jul 21, 2020

Fixes #8445 .

Nomad 0.12 introduces NodeNetworks structs in #8208 but it looks like it may be out of sync from earlier network interpretation, namely, .NodeResources.Networks. NodeResources.Networks honors network_interface from config, but looks like .NodeResources.Networks uses the "default" network (as specified by ip route). This mis-attribution result into pods getting assigned unexpected ip addresses.

It's notable that NodeResources aren't reported when using nomad node status -json - we must use curl.

To test this, I had a simple nomad agent with network_interface = "eth2" config. Notice how NodeNetworks and Networks report different interface names before, and with the fix both point to eth2.

The command:

curl -sSL localhost:4646/v1/node/$(nomad node status -self -json | jq -r .ID) | jq '{NodeNetworks: .NodeResources.NodeNetworks, Networks: .NodeResources.Networks}

Before

{
  "NodeNetworks": [
    {
      "Mode": "bridge",
      "Device": "",
      "MacAddress": "",
      "Speed": 0,
      "Addresses": null
    },
    {
      "Mode": "host",
      "Device": "eth0",
      "MacAddress": "08:00:27:81:14:5e",
      "Speed": 1000,
      "Addresses": [
        {
          "Family": "ipv4",
          "Alias": "default",
          "Address": "10.0.2.15",
          "ReservedPorts": "",
          "Gateway": ""
        }
      ]
    }
  ],
  "Networks": [
    {
      "Mode": "bridge",
      "Device": "",
      "CIDR": "",
      "IP": "",
      "MBits": 0,
      "DNS": null,
      "ReservedPorts": null,
      "DynamicPorts": null
    },
    {
      "Mode": "host",
      "Device": "eth2",
      "CIDR": "10.199.0.200/32",
      "IP": "10.199.0.200",
      "MBits": 1000,
      "DNS": null,
      "ReservedPorts": null,
      "DynamicPorts": null
    }
  ]
}

After

{
  "NodeNetworks": [
    {
      "Addresses": null,
      "Device": "",
      "MacAddress": "",
      "Mode": "bridge",
      "Speed": 0
    },
    {
      "Addresses": [
        {
          "Address": "10.199.0.200",
          "Alias": "default",
          "Family": "ipv4",
          "Gateway": "",
          "ReservedPorts": ""
        }
      ],
      "Device": "eth2",
      "MacAddress": "08:00:27:7c:5f:ec",
      "Mode": "host",
      "Speed": 1000
    }
  ],
  "Networks": [
    {
      "CIDR": "",
      "DNS": null,
      "Device": "",
      "DynamicPorts": null,
      "IP": "",
      "MBits": 0,
      "Mode": "bridge",
      "ReservedPorts": null
    },
    {
      "CIDR": "10.199.0.200/32",
      "DNS": null,
      "Device": "eth2",
      "DynamicPorts": null,
      "IP": "10.199.0.200",
      "MBits": 1000,
      "Mode": "host",
      "ReservedPorts": null
    }
  ]
}

@notnoop notnoop self-assigned this Jul 21, 2020
Copy link
Member

@schmichael schmichael left a comment

Choose a reason for hiding this comment

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

Thanks for jumping on this!

Copy link
Member

@nickethier nickethier left a comment

Choose a reason for hiding this comment

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

👍 Thanks for getting this!

@notnoop notnoop merged commit e6f5fb6 into master Jul 22, 2020
@notnoop notnoop deleted the b-node-network-devices-1 branch July 22, 2020 14:44
@github-actions
Copy link

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 Dec 28, 2022
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.

network_interface parameter does not influence port allocations in 0.12.0
3 participants