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

recovery as machine inventory name after reset #646

Closed
juadk opened this issue Feb 28, 2024 · 2 comments · Fixed by rancher/elemental#1249 or rancher/elemental#1264
Closed

recovery as machine inventory name after reset #646

juadk opened this issue Feb 28, 2024 · 2 comments · Fixed by rancher/elemental#1249 or rancher/elemental#1264
Assignees
Labels
kind/bug Something isn't working

Comments

@juadk
Copy link
Contributor

juadk commented Feb 28, 2024

I was playing with my rancher / elemental lab using machineName: ${System Data/Runtime/Hostname} and when I reset the node, I saw that machine inventory got created with recovery name (see screenshot below)

image

What will happen if we reset multiple nodes at the same time? There will likely be conflict because we cannot have multi-machine inventory with the same name...

It might be fixed by rancher/elemental#1249 but we will have to confirm it.

@juadk juadk added the kind/bug Something isn't working label Feb 28, 2024
@juadk juadk added this to Elemental Feb 28, 2024
@fgiudici fgiudici moved this to 🗳️ To Do in Elemental Feb 28, 2024
@frelon frelon linked a pull request Feb 28, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from 🗳️ To Do to ✅ Done in Elemental Feb 28, 2024
@juadk juadk reopened this Feb 29, 2024
@github-project-automation github-project-automation bot moved this from ✅ Done to 🗳️ To Do in Elemental Feb 29, 2024
@juadk
Copy link
Contributor Author

juadk commented Feb 29, 2024

Well, I tested the patch and it mostly fixes my issue but we still have a corner case:
If you do not have a DHCP server and you use machineName: ${System Data/Runtime/Hostname}, when you reset a node, you will get the following:
image

And I tested the fix with a fake DHCP in libvirt:

  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254'/>
      <host mac='52:54:00:2b:d0:50' name='myhostname' ip='192.168.122.5'/>
    </dhcp>

And I got:
image

@fgiudici fgiudici self-assigned this Mar 1, 2024
@fgiudici fgiudici moved this from 🗳️ To Do to 🏃🏼‍♂️ In Progress in Elemental Mar 1, 2024
@fgiudici
Copy link
Member

fgiudici commented Mar 4, 2024

When a machine registers, if there is no MachineInventory tracking obj, a new one is created on the operator side.
The unique identifier used there comes from the Registration authentication: usually, it is the TPM hash.
The Name of the MachineInventory object is the hostname that will be set to the host later on (during k3s/RKE2 provisioning) and will not change anymore (till deletion of the MachineInventory at least).
When configuring the machineName from DHCP, whatever is the hostname of the host during the registration, that is what will end up as the Name of the MachineInventory (and so as the final static hostname on k8s provisioning).
On "normal" boot we set a transient hostname of the kind "Rancher-VWXYZ" when no static name is detected: the transient hostname will be replaced by the DHCP one if any, otherwise will act as a fallback.
We need to do the same during recovery: since from there during reset a new registration can start, we need to ensure that in case the hostname should be set from DHCP and there is no DHCP name provided we have a sane one (i.e., Rancher-VWXYZ").

fgiudici added a commit to fgiudici/elemental that referenced this issue Mar 4, 2024
If a static hostname is not available always set a transient hostname
in the form "Rancher-VWXYZ". Do that also when in recovery mode.

Fixes: rancher/elemental-operator#646

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
@fgiudici fgiudici moved this from 🏃🏼‍♂️ In Progress to 👀 Needs review in Elemental Mar 4, 2024
fgiudici added a commit to rancher/elemental that referenced this issue Mar 5, 2024
If a static hostname is not available always set a transient hostname
in the form "Rancher-VWXYZ". Do that also when in recovery mode.

Fixes: rancher/elemental-operator#646

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
@github-project-automation github-project-automation bot moved this from 👀 Needs review to ✅ Done in Elemental Mar 5, 2024
kkaempf pushed a commit to rancher/elemental that referenced this issue Mar 5, 2024
If a static hostname is not available always set a transient hostname
in the form "Rancher-VWXYZ". Do that also when in recovery mode.

Fixes: rancher/elemental-operator#646

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
fgiudici added a commit to fgiudici/elemental that referenced this issue Apr 17, 2024
If a static hostname is not available always set a transient hostname
in the form "Rancher-VWXYZ". Do that also when in recovery mode.

Fixes: rancher/elemental-operator#646

(cherry picked from commit 5e6bc8f)

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
fgiudici added a commit to rancher/elemental that referenced this issue Apr 17, 2024
Always ensure a Rancher-vWXYZ transient hostname (#1264)

If a static hostname is not available always set a transient hostname
in the form "Rancher-VWXYZ". Do that also when in recovery mode.

Fixes: rancher/elemental-operator#646

(cherry picked from commit 5e6bc8f)

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
kind/bug Something isn't working
Projects
Archived in project
2 participants