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 guestinfo.hostname to config of a VM #2071

Conversation

odvarkadaniel
Copy link

What this PR does / why we need it:
The VMs in the vCenter are currently without a DNSName (they don't have a config data at key guestinfo.hostname) while using an ignition to set the VM up. With setting this field up, we can also append an internal DNS address to the list of machine's addresses.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2013

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:

Set a DNSName for VMs to a corresponding machine's name.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 22, 2023
@k8s-ci-robot k8s-ci-robot requested review from srm09 and vrabbi July 22, 2023 12:33
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 22, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @odvarkadaniel!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-vsphere 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-vsphere has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @odvarkadaniel. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 22, 2023
@zhanggbj
Copy link
Contributor

/ok-to-test

@k8s-ci-robot
Copy link
Contributor

@zhanggbj: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/ok-to-test

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.

@sbueringer
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 25, 2023
@randomvariable
Copy link
Member

I wouldn't mind some additional eyes from

/assign @akutz

@odvarkadaniel odvarkadaniel force-pushed the set-guestinfo-hostname-machines branch from ab9fc6c to f403d45 Compare July 25, 2023 12:06
@akutz
Copy link
Contributor

akutz commented Jul 26, 2023

I wouldn't mind some additional eyes from

/assign @akutz

Is this CAPV as a stand-alone management cluster?

Also, please see coreos/afterburn#888 as it will likely be useful in the future.

@akutz
Copy link
Contributor

akutz commented Jul 26, 2023

/hold

Please see #2071 (comment). Changes needed.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 26, 2023
@odvarkadaniel
Copy link
Author

I wouldn't mind some additional eyes from
/assign @akutz

Is this CAPV as a stand-alone management cluster?

Also, please see coreos/afterburn#888 as it will likely be useful in the future.

Do I get that right that I will need to get the necessary data from the newly introduced netplan config file which will be stored as guestinfo.metadata?

@randomvariable
Copy link
Member

Do I get that right that I will need to get the necessary data from the newly introduced netplan config file which will be stored as guestinfo.metadata?

Yup that's correct. Given the complexity of networking on-prem environments, we decided that netplan had the required expressivity, and we'll be encouraging all bootstrap providers to adopt it. I would sync up with Flatcar counterparts in Ignition.

@odvarkadaniel
Copy link
Author

Hi, I just came back from PTO.

I have chatted with folks from flatcar forum and I don't really understand what needs to be done here in order for this to get merged as this file exists and I suspect this is going to be plugged in as guestinfo.metadata and the field local-hostname is still going to be used to get the data necessary for this change.

As of right now we just take the metadata file from guestinfo.metadata and parse the local-hostname value out of it and assign it to guestinfo.hostname to see it on the VM in vCenter, which, as far as I understand, stays the same.

Thank you for clarifying this situation in case I am missing something.

@chrischdi
Copy link
Member

/assign @randomvariable

for helping to clarify. Thanks!

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 5, 2023
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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.

@odvarkadaniel
Copy link
Author

Hi, I just came back from PTO.

I have chatted with folks from flatcar forum and I don't really understand what needs to be done here in order for this to get merged as this file exists and I suspect this is going to be plugged in as guestinfo.metadata and the field local-hostname is still going to be used to get the data necessary for this change.

As of right now we just take the metadata file from guestinfo.metadata and parse the local-hostname value out of it and assign it to guestinfo.hostname to see it on the VM in vCenter, which, as far as I understand, stays the same.

Thank you for clarifying this situation in case I am missing something.

Can you please follow up on this, @randomvariable? Thank you!

@jepio
Copy link

jepio commented Sep 25, 2023

Do I get that right that I will need to get the necessary data from the newly introduced netplan config file which will be stored as guestinfo.metadata?

Yup that's correct. Given the complexity of networking on-prem environments, we decided that netplan had the required expressivity, and we'll be encouraging all bootstrap providers to adopt it. I would sync up with Flatcar counterparts in Ignition.

So if I understand this PR and #2013 correctly - @odvarkadaniel issue is not about setting the hostname of the guest, but about exposing that value through vCenter.

Given that we are aligned on using guestinfo.metadata to pass cloud-init/netplan yaml (with the local-hostname field) on the CAPV side, will vCenter be able to handle that? As in: will vCenter parse out the hostname from that location and display it in the webui or does the guest have an interface to push it's hostname to vCenter?

@odvarkadaniel
Copy link
Author

Do I get that right that I will need to get the necessary data from the newly introduced netplan config file which will be stored as guestinfo.metadata?

Yup that's correct. Given the complexity of networking on-prem environments, we decided that netplan had the required expressivity, and we'll be encouraging all bootstrap providers to adopt it. I would sync up with Flatcar counterparts in Ignition.

So if I understand this PR and #2013 correctly - @odvarkadaniel issue is not about setting the hostname of the guest, but about exposing that value through vCenter.

Given that we are aligned on using guestinfo.metadata to pass cloud-init/netplan yaml (with the local-hostname field) on the CAPV side, will vCenter be able to handle that? As in: will vCenter parse out the hostname from that location and display it in the webui or does the guest have an interface to push it's hostname to vCenter?

With the current config file stored in the field guestinfo.metadata, I am able to set the hostname value to vCenter's VM with the changes provided (I have used this fix multiple times to achieve the VM to have hostname set). What this PR should IMO introduce is the parsing of the config data at field local-hostname to set this value to guestinfo.hostname over at vCenter's VM.

What my question is, with all the other PRs mentioned in this one, what is actually getting changed? The netplan config will stay the same as it is now, as far as I understand, which is why I don't understand what direction this needs to be moved as the current change should fix the issue (set hostname on vCenter's VM).

@jepio
Copy link

jepio commented Sep 25, 2023

With the current config file stored in the field guestinfo.metadata, I am able to set the hostname value to vCenter's VM with the changes provided (I have used this fix multiple times to achieve the VM to have hostname set). What this PR should IMO introduce is the parsing of the config data at field local-hostname to set this value to guestinfo.hostname over at vCenter's VM.

What my question is, with all the other PRs mentioned in this one, what is actually getting changed? The netplan config will stay the same as it is now, as far as I understand, which is why I don't understand what direction this needs to be moved as the current change should fix the issue (set hostname on vCenter's VM).

Sorry, but I can't follow. Let's forget guestinfo.hostname for a second. What usecase is currently broken for you? guestinfo.metadata.local_hostname is where CAPV places the hostname right now. Cloud-init processes it and sets the VM hostname to that value. The Flatcar template currently has a systemd service that performs that operation, and in future this will be handled by afterburn.

@odvarkadaniel
Copy link
Author

Sorry, but I can't follow. Let's forget guestinfo.hostname for a second. What usecase is currently broken for you? guestinfo.metadata.local_hostname is where CAPV places the hostname right now. Cloud-init processes it and sets the VM hostname to that value. The Flatcar template currently has a systemd service that performs that operation, and in future this will be handled by afterburn.

Ah, totally forgot to mention that this is for Ignition, sorry. The ignition bootstrapping method currently does not set the hostname on the VM as cloud-init does. This just adds the same thing as cloud-init does, but for Ignition.

We are running into an issue, where MachineSet provisions a Machine and a new VM gets created in the vCenter, but never gets ignited due to a failure cause by empty hostname.

@jepio
Copy link

jepio commented Sep 25, 2023 via email

@odvarkadaniel
Copy link
Author

odvarkadaniel commented Sep 25, 2023

Do you have an error message/log that shows what's going on? As far as I know neither ignition, nor afterburn care about the value of guestinfo.hostname. Flatcar also uses ignition and in CAPV it has a systemd service defined in ignition data that sets the node hostname. Without this kubeadm join doesn't work, but ignition itself does. Do you use the same ignition template from this repo? Would that approach work for your case as well?

I have been testing this with our openshift downstream version of CAPV (which should be identical to upstream) with our ignition config files. We do stuff a little bit different downstream, which comes to this issue, I thought it could also be useful adding this upstream (assign value to guestinfo.hostname for ignition from CAPV), so this is not a bug in here, just a feature that would help us downstream work with MachineSets.

@jepio
Copy link

jepio commented Sep 25, 2023 via email

@odvarkadaniel
Copy link
Author

Sorry for confusion, it's been a long time since I worked on this.

I think that our machine-approver operator is preventing the machine from getting created as the newly created machine is currently missing an InternalDNS name (link). This piece of code is also enforcing us to have the InternalDNS name set to the machine's name, which is then also used in the ignition config file. CAPV is already setting the InternalDNS for cloud-init already, but not for ignition as far as I remember.

@jepio
Copy link

jepio commented Sep 26, 2023

So it sounds like you really want this part of the PR merged:

+		machineAddresses = append(machineAddresses, clusterv1.MachineAddress{
+			Type:    clusterv1.MachineInternalDNS,
+			Address: ctx.Machine.Name,
+		})

@odvarkadaniel
Copy link
Author

So it sounds like you really want this part of the PR merged:

+		machineAddresses = append(machineAddresses, clusterv1.MachineAddress{
+			Type:    clusterv1.MachineInternalDNS,
+			Address: ctx.Machine.Name,
+		})

Yes, that seems to fix this issue for us. Didn't realise at first that upstream's ignition template already has a service that sets the hostname on the VM.

@jepio
Copy link

jepio commented Sep 26, 2023

I think that part should be OK to merge. Would you agree @akutz ?

@odvarkadaniel : in the meantime, are you able to help or find someone at Red Hat who could take care of the points blocking coreos/afterburn#888 (comment) from getting merged? Those are: reviews and packaging dependencies in Fedora. Then we can build on that PR to also handle the local-hostname field.

@odvarkadaniel
Copy link
Author

I think that part should be OK to merge. Would you agree @akutz ?

@odvarkadaniel : in the meantime, are you able to help or find someone at Red Hat who could take care of the points blocking coreos/afterburn#888 (comment) from getting merged? Those are: reviews and packaging dependencies in Fedora. Then we can build on that PR to also handle the local-hostname field.

We are discussing this in the original issue linked to this PR.

Of course, I will ask about the coreos/afterburner PR.

@odvarkadaniel
Copy link
Author

@jepio, Just to update you on the afterburner PR - I talked to folks from coreos team and they are currently not working on it nor on their radar as this is not a priority for them currently.

@jepio
Copy link

jepio commented Sep 27, 2023

@jepio, Just to update you on the afterburner PR - I talked to folks from coreos team and they are currently not working on it nor on their radar as this is not a priority for them currently.

I see. That afterburn PR would help CAPV cover more scenarios, which would also benefit Openshift.

…ceiver

🌱 Use pointer receiver consistently in vspheremachine controller
@odvarkadaniel odvarkadaniel force-pushed the set-guestinfo-hostname-machines branch from f403d45 to fef5f54 Compare November 20, 2023 16:56
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from randomvariable. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 20, 2023
@k8s-ci-robot
Copy link
Contributor

@odvarkadaniel: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-provider-vsphere-e2e-main-oldpreset f403d45 link true /test pull-cluster-api-provider-vsphere-e2e-main-oldpreset
pull-cluster-api-provider-vsphere-test-integration-main fef5f54 link true /test pull-cluster-api-provider-vsphere-test-integration-main
pull-cluster-api-provider-vsphere-e2e-main fef5f54 link true /test pull-cluster-api-provider-vsphere-e2e-main
pull-cluster-api-provider-vsphere-test-main fef5f54 link true /test pull-cluster-api-provider-vsphere-test-main
pull-cluster-api-provider-vsphere-verify-main fef5f54 link true /test pull-cluster-api-provider-vsphere-verify-main
pull-cluster-api-provider-vsphere-apidiff-main fef5f54 link false /test pull-cluster-api-provider-vsphere-apidiff-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Guestinfo.hostname field in vCenter not set when using ignition for VMs
8 participants