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

Add hostname to system-data #593

Merged
merged 1 commit into from
Jan 12, 2024
Merged

Conversation

frelon
Copy link
Contributor

@frelon frelon commented Jan 9, 2024

Add new ${System Data/Runtime/Hostname} key to the registration data sent from the elemental-register command.

Fixes #591

@github-actions github-actions bot added area/operator operator related changes area/tests test related changes labels Jan 9, 2024
Copy link

codecov bot commented Jan 9, 2024

Codecov Report

Attention: 23 lines in your changes are missing coverage. Please review.

Comparison is base (8d424e7) 53.86% compared to head (8f220ca) 53.75%.

Files Patch % Lines
pkg/server/api_registration.go 33.33% 8 Missing and 2 partials ⚠️
pkg/runtime/info.go 0.00% 8 Missing ⚠️
pkg/hostinfo/hostinfo.go 50.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #593      +/-   ##
==========================================
- Coverage   53.86%   53.75%   -0.11%     
==========================================
  Files          39       40       +1     
  Lines        6037     6066      +29     
==========================================
+ Hits         3252     3261       +9     
- Misses       2500     2519      +19     
- Partials      285      286       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@frelon frelon force-pushed the registration-hostname branch from cb87709 to e36c5bf Compare January 9, 2024 12:25
Copy link
Contributor

@kkaempf kkaempf left a comment

Choose a reason for hiding this comment

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

lgtm

@kkaempf
Copy link
Contributor

kkaempf commented Jan 9, 2024

This should also be backported to 1.4.1 (aka OBS Staging)

@frelon frelon force-pushed the registration-hostname branch from e36c5bf to 7eca722 Compare January 10, 2024 08:20
Add new ${System Data/Runtime/Hostname} key to the registration data
sent from the elemental-register command.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
@frelon frelon force-pushed the registration-hostname branch from 7eca722 to 8f220ca Compare January 11, 2024 14:44
@frelon frelon marked this pull request as ready for review January 11, 2024 14:44
@frelon frelon requested a review from a team as a code owner January 11, 2024 14:44
Copy link
Contributor

@kkaempf kkaempf left a comment

Choose a reason for hiding this comment

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

lgtm

@frelon frelon merged commit 0a4fe2e into rancher:main Jan 12, 2024
16 checks passed
@frelon frelon deleted the registration-hostname branch January 12, 2024 08:41
fgiudici added a commit to fgiudici/elemental that referenced this pull request Jan 19, 2024
If the (static) hostname is not set, we used to set a rancher-${RANDOM}
one. This anyway prevents DHCP to serve a transient hostname.
In Elemental, at registration time, the hostname is recorded as the
MachineInventory name and from that point onwards it could not be
changed. It will be enforced as the static hostname during the k3s/RKE2
provisioning.
Since we do registration just after the ISO boot, in order to use the
DHCP provided hostname, we should allow the transient name to be set by
the dhcp client (which happens only if the static hostname is not
set) and then take advantage of the new templating value:
${System Data/Runtime/Hostname}
(see rancher/elemental-operator#593)

Drawbacks: if no hostname is provided by the DHCP server or via IP
reverse lookup, and if the MachineName has not been set in the
MachineInventory, the Elemental host will have "localhost" hostname till
k3s/RKE2 provisioning.

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
fgiudici added a commit to fgiudici/elemental that referenced this pull request Jan 19, 2024
If the (static) hostname is not set, we used to set a rancher-${RANDOM}
one. This anyway prevents DHCP to serve a transient hostname.
In Elemental, at registration time, the hostname is recorded as the
MachineInventory name and from that point onwards it could not be
changed. It will be enforced as the static hostname during the k3s/RKE2
provisioning.
Since we do registration just after the ISO boot, in order to use the
DHCP provided hostname, we should allow the transient name to be set by
the dhcp client (which happens only if the static hostname is not
set) and then take advantage of the new templating value:
${System Data/Runtime/Hostname}
(see rancher/elemental-operator#593)

Drawbacks: if no hostname is provided by the DHCP server or via IP
reverse lookup, and if the MachineName has not been set in the
MachineInventory, the Elemental host will have "localhost" hostname till
k3s/RKE2 provisioning.

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
fgiudici added a commit to fgiudici/elemental that referenced this pull request Jan 29, 2024
If the (static) hostname is not set, we used to set a rancher-${RANDOM}
one. This anyway prevents DHCP to serve a transient hostname.
In Elemental, at registration time, the hostname is recorded as the
MachineInventory name and from that point onwards it could not be
changed. It will be enforced as the static hostname during the k3s/RKE2
provisioning.
Since we do registration just after the ISO boot, in order to use the
DHCP provided hostname, we should allow the transient name to be set by
the dhcp client (which happens only if the static hostname is not
set) and then take advantage of the new templating value:
${System Data/Runtime/Hostname}
(see rancher/elemental-operator#593)

Let's anyway set the racher-${RANDOM} hostname but as a transient one
and before the network stage (so it may be replaced by the DHCP provided
one).

This is a change in behavior: on Elemental booting (before provisioning)
if a hostname has not been set and DHCP provides one, the DHCP hostname
takes precedence over the rancher-${RANDOM} one.

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
fgiudici added a commit to fgiudici/elemental that referenced this pull request Jan 31, 2024
If the (static) hostname is not set, we used to set a rancher-${RANDOM}
one. This anyway prevents DHCP to serve a transient hostname.
In Elemental, at registration time, the hostname is recorded as the
MachineInventory name and from that point onwards it could not be
changed. It will be enforced as the static hostname during the k3s/RKE2
provisioning.
Since we do registration just after the ISO boot, in order to use the
DHCP provided hostname, we should allow the transient name to be set by
the dhcp client (which happens only if the static hostname is not
set) and then take advantage of the new templating value:
${System Data/Runtime/Hostname}
(see rancher/elemental-operator#593)

Let's anyway set the racher-${RANDOM} hostname but as a transient one
and before the network stage (so it may be replaced by the DHCP provided
one).

This is a change in behavior: on Elemental booting (before provisioning)
if a hostname has not been set and DHCP provides one, the DHCP hostname
takes precedence over the rancher-${RANDOM} one.

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
fgiudici added a commit to rancher/elemental that referenced this pull request Jan 31, 2024
If the (static) hostname is not set, we used to set a rancher-${RANDOM}
one. This anyway prevents DHCP to serve a transient hostname.
In Elemental, at registration time, the hostname is recorded as the
MachineInventory name and from that point onwards it could not be
changed. It will be enforced as the static hostname during the k3s/RKE2
provisioning.
Since we do registration just after the ISO boot, in order to use the
DHCP provided hostname, we should allow the transient name to be set by
the dhcp client (which happens only if the static hostname is not
set) and then take advantage of the new templating value:
${System Data/Runtime/Hostname}
(see rancher/elemental-operator#593)

Let's anyway set the racher-${RANDOM} hostname but as a transient one
and before the network stage (so it may be replaced by the DHCP provided
one).

This is a change in behavior: on Elemental booting (before provisioning)
if a hostname has not been set and DHCP provides one, the DHCP hostname
takes precedence over the rancher-${RANDOM} one.

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/operator operator related changes area/tests test related changes
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Allow pre-set hostnames to be used during Elemental registration
2 participants