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

Update hostname setting for SUSE distros #1832

Merged
merged 4 commits into from
Apr 24, 2020
Merged

Conversation

rjschwei
Copy link
Contributor

@rjschwei rjschwei commented Mar 24, 2020

Description

Current versions of openSUSE and SLES are systemd based. Use hostnamectl to set the hostname and make sure it is properly propagated through the system.

Issue #
The hostname setting may not be properly propagated in the running system using the "hostname" command.


PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • Except for special cases involving multiple contributors, the PR is started from a fork of the main repository, not a branch.
  • If applicable, the PR references the bug/issue that it fixes in the description.
  • New Unit tests were added for the changes made and Travis.CI is passing.

Quality of Code and Contribution Guidelines


This change is Reviewable

  hostnamectl to set the hostname and make sure it is properly propagated
  through the system.
@codecov
Copy link

codecov bot commented Mar 24, 2020

Codecov Report

Merging #1832 into develop will decrease coverage by 0.33%.
The diff coverage is 4.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1832      +/-   ##
===========================================
- Coverage    69.45%   69.12%   -0.34%     
===========================================
  Files           82       82              
  Lines        11469    11511      +42     
  Branches      1619     1619              
===========================================
- Hits          7966     7957       -9     
- Misses        3166     3217      +51     
  Partials       337      337              
Impacted Files Coverage Δ
azurelinuxagent/common/osutil/suse.py 32.11% <4.00%> (-33.57%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f08dd83...26a4fd8. Read the comment docs.

pgombar
pgombar previously approved these changes Apr 8, 2020
@pgombar
Copy link
Contributor

pgombar commented Apr 8, 2020

Travis run is green: https://travis-ci.org/github/Azure/WALinuxAgent/builds/666506710
Internal end-to-end automation is passing, @narrieta can you add your review?

vrdmr
vrdmr previously approved these changes Apr 8, 2020
larohra
larohra previously approved these changes Apr 8, 2020
azurelinuxagent/common/osutil/suse.py Outdated Show resolved Hide resolved
azurelinuxagent/common/osutil/suse.py Outdated Show resolved Hide resolved
@pgombar
Copy link
Contributor

pgombar commented Apr 23, 2020

Hi @rjschwei I was running end-to-end automation for this change and it seems that the hostname in SUSE12 SP5 keeps flip-flopping between localhost and whatever the hostname is set to during provisioning. This happens when either hostname or hostnamectl commands are used to set the hostname during provisioning.

2020/04/22 06:21:06.863525 INFO ExtHandler EnvMonitor: Detected hostname change: localhost-> edpt9hdky6
2020/04/22 06:21:06.873529 INFO ExtHandler Examine /proc/net/route for primary interface
2020/04/22 06:21:06.877988 INFO ExtHandler Primary interface is [eth0]
2020/04/22 06:21:31.683811 INFO ExtHandler EnvMonitor: Detected hostname change: edpt9hdky6-> localhost

We are not seeing this behavior in other images. I did a little bit of research and the hostname change remains persistent if I tell DHCP to not change the hostname like:
sed --in-place 's/DHCLIENT_SET_HOSTNAME="yes"/DHCLIENT_SET_HOSTNAME="no"/' /etc/sysconfig/network/dhcp

Is this behavior expected? cc @trstringer who might have more context on this from the provisioning side.

  + The shellutil.run() is deprecated and should no longer be used
@rjschwei rjschwei dismissed stale reviews from larohra, vrdmr, and pgombar via c1e3ecc April 23, 2020 11:50
@rjschwei
Copy link
Contributor Author

@pgombar the hostname keeps flipping because of a configuration error in our images where we have DHCLIENT_SET_HOSTNAME=yes in /etc/sysconfig/network/dhcp instead of DHCLIENT_SET_HOSTNAME=no.

The issue has been fixed and the next image refresh cycle will have the updated value. It is unknown why this has never been a problem in the past, best guess is that a change in wicked triggered this to show up.

@pgombar
Copy link
Contributor

pgombar commented Apr 23, 2020

@pgombar the hostname keeps flipping because of a configuration error in our images where we have DHCLIENT_SET_HOSTNAME=yes in /etc/sysconfig/network/dhcp instead of DHCLIENT_SET_HOSTNAME=no.

The issue has been fixed and the next image refresh cycle will have the updated value. It is unknown why this has never been a problem in the past, best guess is that a change in wicked triggered this to show up.

Thanks for confirming!

Also, thank you for changing all of the calls in suse.py. I was expecting you to change just the method you were touching in this PR.

However, we want to keep the current behaviour of swallowing exceptions and not logging to agent log. Since we want to merge this change as soon as possible, I have updated the PR to expedite the review.

Copy link
Contributor

@larohra larohra left a comment

Choose a reason for hiding this comment

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

LGTM

@pgombar
Copy link
Contributor

pgombar commented Apr 23, 2020

End-to-end automation OK.

@pgombar pgombar merged commit ed5cb57 into Azure:develop Apr 24, 2020
@pgombar
Copy link
Contributor

pgombar commented Apr 24, 2020

@rjschwei merged, thanks for your contribution!

@rjschwei
Copy link
Contributor Author

Thanks for cleaning up after me while I was pulled away chasing other stuff.

@rjschwei rjschwei deleted the usehstnctl branch May 21, 2020 21:06
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