-
Notifications
You must be signed in to change notification settings - Fork 20
Bug 2041183: Configure hostnames via ignition #35
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
Bug 2041183: Configure hostnames via ignition #35
Conversation
|
/cc @andfasano |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sadasu The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@sadasu: An error was encountered querying GitHub for users with public email (yporagpa@redhat.com) for bug 2041183 on the Bugzilla server at https://bugzilla.redhat.com. No known errors were detected, please see the full error message for details. Full error message.
non-200 OK status code: 403 Forbidden body: "{\n \"documentation_url\": \"https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#secondary-rate-limits\",\n \"message\": \"You have exceeded a secondary rate limit. Please wait a few minutes before you try again.\"\n}\n"
Please contact an administrator to resolve this issue, then request a bug refresh with In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
24c57ff to
b5d86d0
Compare
|
/cc @zaneb |
b5d86d0 to
2b96066
Compare
|
This looks plausible to me. @cybertron I was thinking that we probably want this default hostname to take precedence over reverse DNS, to avoid problems with getting the hostname from the VIP. I suspect this change will have that effect, but we should check. WDYT? Also need to check that this does not override DHCP if a hostname is provided that way. If it does we may need an additional NM dispatcher script. |
|
Agreed, I think we need this or something like it. I found the previous bug about this[0], but unfortunately that only helps with ipv6. The ipv4 vips don't show up as deprecated so there's no obvious way to differentiate them. If I pull this down, will it work with the usual dev-scripts image override mechanism? |
|
Testing locally with DHCP, I see in the logs: policy: set-hostname: set hostname to 'master-0' (from DHCPv4) Although it's worth noting that the hostname was already set at that point. Is that expected if I'm not passing nmstate config? I'm also not sure if DHCP would override the static hostname (assuming that's where it came from originally) since they match in this case. Maybe if I hack the names in install-config? |
|
Looks like 2 problems with this:
Good news: If the solution to 2. were to set it in a NM dispatcher script, that would solve 1. as well. |
2b96066 to
5f18c09
Compare
pkg/ignition/builder.go
Outdated
| config.Storage.Files = append(config.Storage.Files, ignitionFileEmbed( | ||
| "/etc/NetworkManager/dispatcher.d/02-hostname", | ||
| 0744, false, | ||
| []byte("hostnamectl set-hostname --static --transient b.hostname"))) |
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.
I don't think we can set --static, that seems to take precedence over DHCP (it updates /etc/hostname).
From what I can gather we want to do set-hostname --transient whenever the current hostname is localhost.
I suggest we consolidate this into the 01-hostname script,
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.
Updated the 01-hostname script. Not sure if this is what we want the order of the 2 operations to be.
5f18c09 to
ba72ac0
Compare
|
/test e2e-metal-ipi-serial-ipv6 |
|
@sadasu: The specified target(s) for
Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/bugzilla refresh |
|
@dtantsur: This pull request references Bugzilla bug 2041183, which is valid. 3 validation(s) were run on this bug
No GitHub users were found matching the public email listed for the QA contact in Bugzilla (yporagpa@redhat.com), skipping review request. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
pkg/ignition/builder.go
Outdated
| "/etc/NetworkManager/dispatcher.d/01-hostname", | ||
| 0744, false, | ||
| []byte("[[ \"$DHCP6_FQDN_FQDN\" =~ \".\" ]] && hostnamectl set-hostname --static --transient $DHCP6_FQDN_FQDN"))) | ||
| []byte("[[ \"$DHCP6_FQDN_FQDN\" =~ \".\" ]] && hostnamectl set-hostname --static --transient $DHCP6_FQDN_FQDN; [[ $HOSTNAME = localhost ]] && hostnamectl set-hostname --transient b.hostname"))) |
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.
Just for my education: what is b.hostname here? How does it work?
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.
During the installer bootstrap a bunch of files are created containing the nmstate configuration defined in the install-config.yaml file (per host) (see here) and then passed to the icc. These file are named as the hostname specified in the config. Here each filename is extracted and passed in this ignitionBuilder struct as a field, to be used as hostname).
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.
So, it will execute hostnamectl set-hostname --transient b.hostname right? won't it set the hostnames of all nodes to literal string b.hostname?
Also I guess hostnamectl is different in coreos? mine has hostnamectl hostname, at least according to the man page.
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.
I think we should be sprintfing the variable b.hostname in here, not setting the hostname to the literal string "b.hostname" though, right?
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.
yeah, so
fmt.Sprintf("[[ \"$DHCP6_FQDN_FQDN\" =~ \".\" ]] && hostnamectl set-hostname --static --transient $DHCP6_FQDN_FQDN; [[ $HOSTNAME = localhost ]] && hostnamectl set-hostname --transient %s", b.hostname)ba72ac0 to
139dda1
Compare
pkg/ignition/builder.go
Outdated
| "/etc/NetworkManager/dispatcher.d/01-hostname", | ||
| 0744, false, | ||
| []byte("[[ \"$DHCP6_FQDN_FQDN\" =~ \".\" ]] && hostnamectl set-hostname --static --transient $DHCP6_FQDN_FQDN"))) | ||
| []byte("[[ \"$DHCP6_FQDN_FQDN\" =~ \".\" ]] && hostnamectl set-hostname --static --transient $DHCP6_FQDN_FQDN; [[ $HOSTNAME = localhost ]] && hostnamectl set-hostname --transient $b.hostname"))) |
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.
should be
[]byte(fmt.Sprintf("[[ \"$DHCP6_FQDN_FQDN\" =~ \".\" ]] && hostnamectl set-hostname --static --transient $DHCP6_FQDN_FQDN; [[ $HOSTNAME = localhost ]] && hostnamectl set-hostname --transient %s", b.hostname))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.
Fixed. I hope.
139dda1 to
df54613
Compare
pkg/ignition/builder.go
Outdated
| "/etc/NetworkManager/dispatcher.d/01-hostname", | ||
| 0744, false, | ||
| []byte("[[ \"$DHCP6_FQDN_FQDN\" =~ \".\" ]] && hostnamectl set-hostname --static --transient $DHCP6_FQDN_FQDN"))) | ||
| []byte(fmt.Sprintf("[[ \"$DHCP6_FQDN_FQDN\" =~ \".\" ]] && hostnamectl set-hostname --static --transient $DHCP6_FQDN_FQDN; [[ $HOSTNAME = localhost ]] && hostnamectl set-hostname --transient %s", b.hostname)))) |
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.
I don't see any evidence that the HOSTNAME environment variable is defined for us?
I think we also need to take into account all of the possible variations of localhost that I linked earlier: https://github.com/systemd/systemd/blob/main/src/basic/hostname-util.c#L183-L192
I think [[ \"$(hostnamectl --transient)\" =~ (^|\\.)localhost(\\.localdomain)?\\.?$ ]] works.
Ordering I think doesn't really matter, since transient never overrides static. Separating commands with a newline rather than a ; might make the script itself easier to read - it might pay to find a better way to lay out this code as well (using ` strings instead of " maybe?).
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.
node-valid-hostname checks the hostname this way: https://github.com/openshift/machine-config-operator/blob/47436bdb7b8c49425d6813abca594485171e1221/templates/common/_base/files/usr-local-bin-mco-hostname.yaml#L17 It probably makes sense to do it the same way here for consistency.
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.
Thanks for both comments!
df54613 to
5a0b71d
Compare
zaneb
left a comment
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.
/lgtm
pkg/ignition/builder.go
Outdated
| []byte("[connection]\nipv6.dhcp-duid=ll\nipv6.dhcp-iaid=mac"))) | ||
|
|
||
| update_hostname := fmt.Sprintf(` | ||
| [[ \"$DHCP6_FQDN_FQDN\" =~ \".\" ]] && hostnamectl set-hostname --static --transient $DHCP6_FQDN_FQDN |
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.
nit: I assume the escapes on the double quotes are still OK, but no longer necessary.
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.
yeah, I didn't want to touch the existing DHCP6 FQDN based update to the hostname.
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.
Right, but the \ was for golang because it was inside a double-quoted string, but now it's inside a backtick string there's no need for escaping afair.
5a0b71d to
00e7971
Compare
|
/retest |
1 similar comment
|
/retest |
|
|
||
| update_hostname := fmt.Sprintf(` | ||
| [[ "$DHCP6_FQDN_FQDN" =~ "." ]] && hostnamectl set-hostname --static --transient $DHCP6_FQDN_FQDN | ||
| [[ "$(< /proc/sys/kernel/hostname)" =~ (localhost|localhost.localdomain) ]] && hostnamectl set-hostname --transient %s`, b.hostname) |
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.
nit: it's enough to do =~ localhost
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.
True, but they both incorrectly match all kinds of rubbish (like test.definitely-not-a-localhost-domain.example.com (the correct regex is (^|\\.)localhost(\\.localdomain)?\\.?$), so there's no point doing it wrong and differently to https://github.com/openshift/machine-config-operator/blob/47436bdb7b8c49425d6813abca594485171e1221/templates/common/_base/files/usr-local-bin-mco-hostname.yaml#L17.
|
/lgtm |
|
@sadasu: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
@sadasu: All pull requests linked via external trackers have merged: Bugzilla bug 2041183 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/cherry-pick release-4.10 |
|
@sadasu: new pull request created: #37 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
No description provided.