Skip to content

fix: conditionally set explicit hostname in Nova server create to prevent .novalocal suffix - #414

Closed
benedikt-haug wants to merge 1 commit into
gardener:masterfrom
benedikt-haug:fix/set-explicit-hostname
Closed

benedikt-haug wants to merge 1 commit into
gardener:masterfrom
benedikt-haug:fix/set-explicit-hostname

Conversation

@benedikt-haug

Copy link
Copy Markdown
Contributor

Motivation

When Nova derives the OS hostname from the server display name, it appends the [api] dhcp_domain (commonly .novalocal). For Gardener shoot workers, the full machine name can exceed the 63-byte RFC 1123 label limit that Kubernetes enforces for the kubernetes.io/hostname node label, causing pod scheduling failures:

unable to parse requirement: values[0][kubernetes.io/hostname]:
Invalid value: "shoot--staging--kbo8cp525p-worker-ndrej-z3-58f8b-2t9lq.novalocal":
must be no more than 63 bytes

Additionally, the .novalocal suffix causes hostname instability across reboots (see gardener/gardener-extension-provider-openstack#569): cloud-init re-applies the FQDN on reboot, racing with the ExecStartPre workaround that strips the domain, leading to inconsistent hostnames and kubelet startup failures.

Background

Since Nova Wallaby (API microversion 2.90), the hostname field in POST /servers allows decoupling the OS hostname from the display name. When set, Nova uses this value directly in the metadata service — without appending dhcp_domain. The display name (Name) remains unaffected.

This was confirmed via a manual PoC against an OpenStack deployment (Nova max microversion 2.100):

  • hostname field accepted with MV 2.90
  • OS-EXT-SRV-ATTR:hostname stored the explicit value without .novalocal
  • Normal VMs (without hostname field) remained unaffected

References:

Changes

  1. pkg/client/nova.go: Pin the Nova compute client to microversion 2.90, enabling the hostname field in server create/update requests.

  2. pkg/driver/executor/executor.go: Pass machineName as the explicit hostname in servers.CreateOpts, decoupling the OS hostname from the display name.

Effects

Aspect Before After
Nova display name shoot--...-2t9lq unchanged
OS hostname in VM shoot--...-2t9lq.novalocal (potentially >63 bytes) shoot--...-2t9lq (≤63 bytes)
kubernetes.io/hostname label may exceed 63-byte limit stays within limit
Hostname stability across reboots unstable (race condition, see #569) stable (short name from metadata)
Normal VMs (no hostname field) .novalocal appended unchanged

Compatibility

  • Requires Nova ≥ Wallaby (microversion 2.90). Older deployments will reject the microversion negotiation.
  • hostname validation by Nova: ≤63 chars, alphanumeric + dashes only, no trailing dash. Gardener machine names comply by construction (RFC 1123).
  • Existing nodes keep their old hostname; only new VMs are affected.

Fixes gardener/gardener-extension-provider-openstack#569

🤖 Generated with AI assistance — the code changes, analysis, and PoC verification were performed by an AI agent. The approach was validated manually against a live OpenStack deployment.

@benedikt-haug
benedikt-haug requested review from a team as code owners September 9, 2026 14:54
@gardener-prow gardener-prow Bot added the do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. label Sep 9, 2026
@gardener-prow

gardener-prow Bot commented Sep 9, 2026

Copy link
Copy Markdown

Welcome @benedikt-haug!

It looks like this is your first PR to gardener/machine-controller-manager-provider-openstack 🎉. 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 gardener/machine-controller-manager-provider-openstack has its own contribution guidelines.

Thank you, and welcome to Gardener. 😃

@gardener-prow

gardener-prow Bot commented Sep 9, 2026

Copy link
Copy Markdown

[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 assign thiyyakat for approval. For more information see the Code Review Process.

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

Details 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

@gardener-prow gardener-prow Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 9, 2026
@federated-github-access

Copy link
Copy Markdown
Contributor

The PR needs to be labeled with ok-to-test by a maintainer to trigger the automated validation of the change

@aaronfern

Copy link
Copy Markdown
Member

Thanks for the PR @benedikt-haug!

The only reservation I have is that this will now fail with any openstack deployment that does not have the 2.90 microversion supported.
Can we not use utils.GetSupportedMicroversions() to ensure that the required microversion is supported? If yes then Hostname can be set, else we can skip setting Hostname
wdyt?

@benedikt-haug
benedikt-haug force-pushed the fix/set-explicit-hostname branch from 659a9c6 to 242f34f Compare October 1, 2026 12:11
@benedikt-haug benedikt-haug changed the title fix: set explicit hostname in Nova server create to prevent .novalocal suffix fix: conditionally set explicit hostname in Nova server create to prevent .novalocal suffix Oct 1, 2026
@benedikt-haug

benedikt-haug commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

@aaronfern
Fair point! I tried to let my agent write a fix that incorporates your feedback, please have a look <3

@gardener-prow gardener-prow Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 1, 2026
@federated-github-access

Copy link
Copy Markdown
Contributor

The PR needs to be labeled with ok-to-test by a maintainer to trigger the automated validation of the change

1 similar comment
@federated-github-access

Copy link
Copy Markdown
Contributor

The PR needs to be labeled with ok-to-test by a maintainer to trigger the automated validation of the change

Comment thread pkg/client/nova.go Outdated
Comment thread pkg/client/nova.go Outdated
Comment thread pkg/driver/executor/executor_test.go
@benedikt-haug
benedikt-haug force-pushed the fix/set-explicit-hostname branch from 242f34f to b031f9f Compare October 5, 2026 11:09
@gardener-prow gardener-prow Bot removed the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 5, 2026
@federated-github-access

Copy link
Copy Markdown
Contributor

The PR needs to be labeled with ok-to-test by a maintainer to trigger the automated validation of the change

@gardener-prow gardener-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 5, 2026
@benedikt-haug

Copy link
Copy Markdown
Contributor Author

@aaronfern Thanks for the review!
I hope I got my agent to incorporate your feedback, but given the risen complexity I don't think I still fully graph these changes myself :(

@aaronfern aaronfern left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One last comment. Otherwise looks good to me

Comment thread pkg/driver/executor/executor_test.go Outdated
Expect(server.InternalIPs).To(ConsistOf(serverIPv4, serverIPv6))
})

It("should not set hostname when SupportsHostnameOverride returns false", func() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could this be renamed to be more accurate?

Suggested change
It("should not set hostname when SupportsHostnameOverride returns false", func() {
It("should succeed
when SupportsHostnameOverride returns false", func() {

@aaronfern

Copy link
Copy Markdown
Member

@benedikt-haug, It also looks like the verify step in one of our workflows fails. Can you please run make generate and push those changes too?

Comment thread pkg/client/nova.go
Comment on lines +48 to +61
// create requests is honoured by Nova. Without this, Nova derives
// the hostname from the display name and appends [api] dhcp_domain
// (e.g. ".novalocal"), which can push the OS hostname beyond the
// 63-byte RFC 1123 label limit enforced by Kubernetes for the
// kubernetes.io/hostname node label.
// Fall back gracefully if the Nova deployment does not support 2.90.
supported, err := utils.GetSupportedMicroversions(ctx, compute)
if err != nil {
klog.Warningf("failed to determine Nova microversion support: %v", err)
} else if ok, err := supported.IsSupported("2.90"); err != nil {
klog.Warningf("failed to check Nova microversion 2.90 support: %v", err)
} else if ok {
compute.Microversion = "2.90"
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is a function in the SDK, utils.RequireMicroversion() that does something very similar.

I suspect that it won't be much cleaner to use it, so I'll leave it up to you. Once @aaronfern's remarks are addressed lgtm

…vent .novalocal suffix

Instead of hard-pinning microversion 2.90 unconditionally, use
utils.GetSupportedMicroversions to check at runtime whether the Nova
deployment supports 2.90+. Only then set the hostname field in server
create requests. Fall back gracefully to the previous behavior on
older Nova deployments that don't support 2.90.
@benedikt-haug
benedikt-haug force-pushed the fix/set-explicit-hostname branch from b031f9f to 5cc97a1 Compare October 8, 2026 15:06
@gardener-prow gardener-prow Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 8, 2026
@federated-github-access

Copy link
Copy Markdown
Contributor

The PR needs to be labeled with ok-to-test by a maintainer to trigger the automated validation of the change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shoot worker node hostname changes after machine reboot

3 participants