Skip to content

WIP: migrate deprecated datacenter field to location#2054

Open
buraksekili wants to merge 1 commit into
kubermatic:mainfrom
buraksekili:fix/hetzner-datacenter-deprecation
Open

WIP: migrate deprecated datacenter field to location#2054
buraksekili wants to merge 1 commit into
kubermatic:mainfrom
buraksekili:fix/hetzner-datacenter-deprecation

Conversation

@buraksekili

@buraksekili buraksekili commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Hetzner removed the datacenter property from its Servers API in July 2026, so any MachineDeployment that still sets cloudProviderSpec.datacenter either fails to provision or lands in Hetzner's default location. This PR migrates datacenter to location on admission by deriving the location from the datacenter name prefix (nbg1-dc3 becomes nbg1), removes all calls to the removed datacenter endpoints, and keeps the field parseable through a deprecation window so existing specs do not break on strict unmarshal. Hard removal of the field is left for a later release.

Which issue(s) this PR fixes:
Fixes #2053

What type of PR is this?
/kind bug
/kind deprecation

Special notes for your reviewer:

Numeric datacenter values are rejected instead of migrated because Hetzner datacenter IDs do not map to location IDs (datacenter 4 is fsn1-dc14 while location 4 is ash). Create derives the location itself for specs that bypass the webhook, so runtime placement stays correct even with the webhook disabled. hcloud-go is bumped from v2.13.1 to v2.44.0 with no other dependency churn and no call site changes. The new TestHetznerProvisioningE2EDatacenterMigration runs in the existing hetzner presubmit because its name matches the job's -run filter. The dc metrics label is gone; dashboards using it need updating.

Does this PR introduce a user-facing change? Then add your Release Note here:

machine-controller no longer sends the removed `datacenter` field to the Hetzner API. Hetzner specs setting `cloudProviderSpec.datacenter` are migrated to `location` automatically on admission, and the `dc` metrics label was removed. Update your specs to use `location`; the `datacenter` field will be removed in a future release.

Documentation:

NONE

Test issue:

Prerequisites: cluster running this machine-controller build with a Hetzner project token.

1. Create a MachineDeployment with cloudProviderSpec.datacenter set to nbg1-dc3 and no location.
2. Verify the webhook rewrote the spec: location is nbg1 and datacenter is empty.
   get machinedeployment <name> -o jsonpath='{.spec.template.spec.providerSpec.value.cloudProviderSpec}'
3. Verify the server is created in nbg1 and the node joins the cluster.
4. Create a MachineDeployment with only location set to fsn1 and verify it provisions unchanged.

Signed-off-by: Burak Sekili <32663655+buraksekili@users.noreply.github.com>
@kubermatic-bot kubermatic-bot added docs/none Denotes a PR that doesn't need documentation (changes). release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. kind/deprecation Categorizes issue or PR as related to a feature/enhancement marked for deprecation. labels Jul 9, 2026
@kubermatic-bot

Copy link
Copy Markdown
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 assign ahmadhamzh 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

@kubermatic-bot kubermatic-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 9, 2026
@buraksekili buraksekili changed the title fix(hetzner): migrate deprecated datacenter field to location WIP: migrate deprecated datacenter field to location Jul 9, 2026
@kubermatic-bot kubermatic-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. docs/none Denotes a PR that doesn't need documentation (changes). kind/bug Categorizes issue or PR as related to a bug. kind/deprecation Categorizes issue or PR as related to a feature/enhancement marked for deprecation. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hetzner: drop deprecated datacenter field in favor of location

2 participants