Skip to content

Introduce v1beta2 conditions for HetznerBareMetalMachine #1951

@abdullah599

Description

@abdullah599

base branch v1.1.x

Summary

Add v1beta2 conditions to HetznerBareMetalMachine while keeping the existing v1beta1 conditions unchanged.

What would you like to add

HetznerBareMetalMachine is an infrastructure machine object that manages the lifecycle of a Hetzner bare metal server by associating with a HetznerBareMetalHost and tracking its provisioning state.

Today the machine lifecycle is surfaced through v1beta1 conditions:

Condition Purpose
HCloudTokenAvailable Hetzner API credentials are valid and reachable
BootstrapReady Bootstrap data has been provided by CAPI
HostAssociateSucceeded Machine has been associated with a HetznerBareMetalHost
HostReady Mirrors the associated host's Ready condition

These conditions are still needed and must keep their current behavior. At the same time, the CAPI v1beta2 transition requires HetznerBareMetalMachine to expose v1beta2 conditions in parallel.

The condition-setting code lives in two places:

  1. Controller (controllers/hetznerbaremetalmachine_controller.go): Sets HCloudTokenAvailable in a defer block on ErrUnauthorized, and via the shared hcloudTokenErrorResult helper for secret-not-found and token-validation errors.
  2. Baremetal service (pkg/services/baremetal/baremetal/baremetal.go): Sets BootstrapReady, HostAssociateSucceeded, and HostReady during the Reconcile flow. HostReady is mirrored from the associated host's ReadyCondition.

Deletion also needs to be visible more clearly. Today the machine sets Status.Phase = MachinePhaseDeleting but does not set a dedicated condition. We want a v1beta2 Deleting condition for HetznerBareMetalMachine, since this resource has a finalizer and a delete reconciliation path.

The Solution

Follow the same structure used for HCloudMachine:

  • Add status.v1beta2.conditions to HetznerBareMetalMachine.
  • Keep writing the existing v1beta1 conditions exactly as today.
  • Add direct v1beta2conditions.Set(...) calls in the same controller and service code paths that already set the v1beta1 conditions.
  • Add a controller local patch step for HetznerBareMetalMachine that computes:
    • the legacy v1beta1 summary
    • the v1beta2 Ready summary
    • the owned v1beta2 condition set for patching
  • Add a dedicated v1beta2 Deleting condition.

Final Conditions

The final v1beta2 conditions added for HetznerBareMetalMachine are:

Constant Type Polarity Notes
HetznerBareMetalMachineReadyV1Beta2Condition clusterv1.ReadyV1Beta2Condition Positive Summary condition
HetznerBareMetalMachineHCloudTokenAvailableV1Beta2Condition HCloudTokenAvailable Positive True when HCloud credentials are valid and reachable
HetznerBareMetalMachineBootstrapReadyV1Beta2Condition BootstrapReady Positive True when bootstrap data is available
HetznerBareMetalMachineHostAssociateSucceededV1Beta2Condition HostAssociateSucceeded Positive True when a host has been associated
HetznerBareMetalMachineHostReadyV1Beta2Condition HostReady Positive Mirrors associated host's Ready condition
HetznerBareMetalMachineDeletingV1Beta2Condition clusterv1.DeletingV1Beta2Condition Negative Dedicated deletion signal

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions