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

2.7 - Hostname resolution in network-get omits loopback IPs #11638

Merged
merged 2 commits into from
Jun 5, 2020

Conversation

manadart
Copy link
Member

@manadart manadart commented May 28, 2020

Description of change

When a manual machine is provisioned using a FQDN, that name is what is returned by the instance-poller for provider addresses. This means that this name is often also returned as the preferred private and public machine addresses.

In turn, when network-get runs for a unit on such a machine, the FQDN is resolved before returning an address result. When it resolves addresses, it returns the first it finds.

We have observed cases where the machine hosts file has an entry like this:

127.0.1.1 hostname.fqdn hostname

This means that the IP returned by network-get is not usable by relations to the unit.

This patch ensures that where possible, we filter 127.*.*.* addresses before returning host-name resolved addresses. If filtering removes all addresses, we log a warning message to give the operator some information for possible resolution.

QA steps

To do this, I have a LXD profile that includes my Juju SSH key in authorised keys for the "ubuntu" user.

  • Create 2 LXD machines with the profile. I named them manual-ctrl and manual-m1.
  • juju bootstrap manual/ssh:ubuntu@<manual-ctrl IP> net-get-test --debug --no-gui.
  • Use lxc exec manual-m1 bash and add an entry to the hosts file like this:
    127.0.1.1 manual-m1.lxd manual-m1.
  • Add an entry to /etc/hosts on the host machine:
    <manual-m1 IP> manual-m1.
  • juju add-machine ssh:ubuntu@manual-m1.
  • juju deploy percona-cluster mysql --to 0 and await quiescence.
  • juju run --unit mysql/0 "network-get --format yaml db".
  • Result should show the hostname, but not the IP from the container host file:
bind-addresses:
- macaddress: ""
  interfacename: ""
  addresses:
  - hostname: manual-m1
    address: ""
    cidr: ""
...
  • juju debug-log --include mysql/0 should include a warning entry like this:
unit-mysql-0: 13:36:00 WARNING worker.uniter.jujuc no usable addresses resolved for host "manual-m1"
        resolved: [127.0.1.1]
        consider editing the hosts file, or changing host resolution order via /etc/nsswitch.conf

Documentation changes

None.

Bug reference

https://bugs.launchpad.net/juju/+bug/1831580

@manadart
Copy link
Member Author

@manadart
Copy link
Member Author

!!build!!

@manadart manadart changed the title Hostname resolution in network-get returns non-loopback IPs 2.7 Hostname resolution in network-get omits loopback IPs Jun 2, 2020
@manadart manadart changed the title 2.7 Hostname resolution in network-get omits loopback IPs 2.7 - Hostname resolution in network-get omits loopback IPs Jun 2, 2020
Copy link
Contributor

@achilleasa achilleasa left a comment

Choose a reason for hiding this comment

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

The last commit LGTM.

Can you also update the bit about filtering in the PR description and add something along the lines of "if only loopback IPs are found, we log an error advising the operator on how to tweak the system settings to ensure proper IP discoverability"?

@hpidcock hpidcock added the 2.7 label Jun 3, 2020
@manadart
Copy link
Member Author

manadart commented Jun 4, 2020

$$merge$$

1 similar comment
@howbazaar
Copy link
Contributor

$$merge$$

@jujubot jujubot merged commit 5eb45dd into juju:2.7 Jun 5, 2020
@manadart manadart deleted the 2.7-local-machine-addrs branch June 8, 2020 09:48
@manadart manadart mentioned this pull request Jun 10, 2020
jujubot added a commit that referenced this pull request Jun 10, 2020
#11688

Merge 2.7 into 2.8 to bring forward:
- #11657 from manadart/2.7-update-gorilla-websocket
- #11638 from manadart/2.7-local-machine-addrs
- #11639 from SimonRichardson/unpin-machine-applications-on-destroy
- #11650 from manadart/2.7-pruner-test-kill
- #11660 from achilleasa/2.7-ensure-cert-leafs-are-at-least-384-bytes-long
- #11664 from ycliuhw/fix/OCI-fetch-2.7

Some of these are effectively no-ops. The material changes are:
- The logging instead of throwing or errors in #11639.
- #11638.
@achilleasa achilleasa mentioned this pull request Jun 11, 2020
jujubot added a commit that referenced this pull request Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants