Skip to content

Support Cluster API failure domains for availability zone spreading - #397

Open
pulish wants to merge 3 commits into
mainfrom
ionoscloudcluster/failure-domains
Open

Support Cluster API failure domains for availability zone spreading#397
pulish wants to merge 3 commits into
mainfrom
ionoscloudcluster/failure-domains

Conversation

@pulish

@pulish pulish commented Aug 13, 2026

Copy link
Copy Markdown

Summary

  • Add opt-in spec.failureDomains []AvailabilityZone (restricted to ZONE_1/ZONE_2) to IonosCloudCluster, mirrored into status.failureDomains (clusterv1.FailureDomains, all marked ControlPlane: true) so Cluster API's core KubeadmControlPlane/MachineDeployment controllers can round-robin Machine.spec.failureDomain across the configured zones — the same contract AWS/Azure/GCP providers implement.
  • IonosCloudMachine server creation now resolves the effective availabilityZone from the owning Machine.spec.failureDomain whenever the machine spec is left at the default AUTO, so Cluster API's assignment actually lands as real VM placement. An explicit non-AUTO availabilityZone on the machine spec always takes precedence.
  • Regenerated deepcopy and CRDs via make generate/make manifests.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./... -short (all packages pass)
  • New unit tests: resolveAvailabilityZone (server_test.go) and syncFailureDomains (ionoscloudcluster_controller_test.go)
  • Opt in a real cluster (e.g. set spec.failureDomains: [ZONE_1, ZONE_2] on its IonosCloudCluster) and confirm new machines land in the expected zones

🤖 Generated with Claude Code

Add an opt-in spec.failureDomains field to IonosCloudCluster, mirrored
to status.failureDomains so Cluster API's core controllers assign
Machine.spec.failureDomain round-robin across the configured zones.
The IonosCloudMachine server creation path now honors that assignment,
overriding the default AUTO placement with the assigned ZONE_1/ZONE_2
when no explicit availabilityZone is set on the machine spec.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds opt-in Cluster API failure domain support so that Machines can be spread across IONOS Cloud availability zones, and ensures the Machine controller honors Cluster API’s Machine.spec.failureDomain assignment when the infra machine is otherwise configured for AUTO placement.

Changes:

  • Add spec.failureDomains to IonosCloudCluster and mirror it into status.failureDomains (for consumption by Cluster API core controllers).
  • Resolve server availabilityZone from the owning Machine.spec.failureDomain when the infra machine spec uses AUTO, while keeping explicit non-AUTO machine settings authoritative.
  • Regenerate CRDs/deepcopy code and add unit tests for both failure domain syncing and availability zone resolution.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/service/cloud/server.go Derives effective server availability zone from Machine.spec.failureDomain when infra spec is AUTO.
internal/service/cloud/server_test.go Adds unit tests covering availability zone resolution precedence and edge cases.
internal/controller/ionoscloudcluster_controller.go Mirrors spec.failureDomains into status.failureDomains for Cluster API consumption.
internal/controller/ionoscloudcluster_controller_test.go Adds unit tests validating syncFailureDomains behavior.
config/crd/bases/infrastructure.cluster.x-k8s.io_ionoscloudclustertemplates.yaml Updates template CRD schema to include failureDomains validation.
config/crd/bases/infrastructure.cluster.x-k8s.io_ionoscloudclusters.yaml Updates cluster CRD schema for spec.failureDomains and status.failureDomains.
api/v1alpha1/zz_generated.deepcopy.go Regenerates deepcopy logic for new spec/status fields.
api/v1alpha1/ionoscloudcluster_types.go Adds FailureDomains to spec and FailureDomains to status with validation markers.
Files not reviewed (1)
  • api/v1alpha1/zz_generated.deepcopy.go: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +69 to +73
// Leave unset to keep the current behavior of letting IONOS Cloud automatically place VMs.
//+kubebuilder:validation:MaxItems=2
//+kubebuilder:validation:XValidation:rule="self.all(z, z in ['ZONE_1', 'ZONE_2'])",message="failureDomains may only contain ZONE_1 or ZONE_2"
//+optional
FailureDomains []AvailabilityZone `json:"failureDomains,omitempty"`

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch — added a CEL uniqueness rule (size(self) < 2 || self[0] != self[1]) and regenerated the CRDs in e67036c.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants