Skip to content

Commit

Permalink
Fix failure domains
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed Aug 10, 2023
1 parent 017cd16 commit dd5ccf6
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 45 deletions.
2 changes: 0 additions & 2 deletions api/v1alpha4/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ func (src *ClusterClass) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.Workers.MachineDeployments[i].Strategy = restored.Spec.Workers.MachineDeployments[i].Strategy
}

dst.Spec.Workers.MachinePools = restored.Spec.Workers.MachinePools

dst.Status = restored.Status

return nil
Expand Down
6 changes: 3 additions & 3 deletions api/v1beta1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ type MachinePoolTopology struct {
// the values are hashed together.
Name string `json:"name"`

// FailureDomain is the failure domain the machine pools will be created in.
// Must match a key in the FailureDomain map stored on the cluster object.
// FailureDomains is the list of failure domains the machine pool will be created in.
// Must match a key in the FailureDomains map stored on the cluster object.
// +optional
FailureDomain *string `json:"failureDomain,omitempty"`
FailureDomains []string `json:"failureDomains,omitempty"`

// NodeDrainTimeout is the total amount of time that the controller will spend on draining a node.
// The default value is 0, meaning that the node can be drained without any time limitations.
Expand Down
8 changes: 4 additions & 4 deletions api/v1beta1/clusterclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ type MachineDeploymentClass struct {
MachineHealthCheck *MachineHealthCheckClass `json:"machineHealthCheck,omitempty"`

// FailureDomain is the failure domain the machines will be created in.
// Must match a key in the FailureDomain map stored on the cluster object.
// Must match a key in the FailureDomains map stored on the cluster object.
// NOTE: This value can be overridden while defining a Cluster.Topology using this MachineDeploymentClass.
// +optional
FailureDomain *string `json:"failureDomain,omitempty"`
Expand Down Expand Up @@ -261,11 +261,11 @@ type MachinePoolClass struct {
// MachinePools objects representing a pool of worker nodes.
Template MachinePoolClassTemplate `json:"template"`

// FailureDomain is the failure domain the machine pools will be created in.
// Must match a key in the FailureDomain map stored on the cluster object.
// FailureDomains is the list of failure domains the MachinePool should be attached to.
// Must match a key in the FailureDomains map stored on the cluster object.
// NOTE: This value can be overridden while defining a Cluster.Topology using this MachinePoolClass.
// +optional
FailureDomain *string `json:"failureDomain,omitempty"`
FailureDomains []string `json:"failureDomains,omitempty"`

// NodeDrainTimeout is the total amount of time that the controller will spend on draining a node.
// The default value is 0, meaning that the node can be drained without any time limitations.
Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ const (

// TopologyReconciledMachinePoolsCreatePendingReason (Severity=Info) documents reconciliation of a Cluster topology
// not yet completed because at least one of the MachinePools is yet to be created.
// This generally happens because new MachinePool creations are held off while the ControlPlane is not stable.
TopologyReconciledMachinePoolsCreatePendingReason = "MachinePoolsCreatePending"

// TopologyReconciledMachinePoolsUpgradeDeferredReason (Severity=Info) documents reconciliation of a Cluster topology
Expand Down
16 changes: 8 additions & 8 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 25 additions & 9 deletions api/v1beta1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions config/crd/bases/cluster.x-k8s.io_clusters.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions internal/controllers/topology/cluster/desired_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -975,9 +975,9 @@ func computeMachinePool(_ context.Context, s *scope.Scope, desiredControlPlaneSt
version := computeMachinePoolVersion(s, desiredControlPlaneState, machinePoolTopology, currentMachinePool)

// Compute values that can be set both in the MachinePoolClass and in the MachinePoolTopology
failureDomain := machinePoolClass.FailureDomain
if machinePoolTopology.FailureDomain != nil {
failureDomain = machinePoolTopology.FailureDomain
failureDomains := machinePoolClass.FailureDomains
if machinePoolTopology.FailureDomains != nil {
failureDomains = machinePoolTopology.FailureDomains
}

nodeDrainTimeout := machinePoolClass.NodeDrainTimeout
Expand Down Expand Up @@ -1015,15 +1015,14 @@ func computeMachinePool(_ context.Context, s *scope.Scope, desiredControlPlaneSt
Namespace: s.Current.Cluster.Namespace,
},
Spec: expv1.MachinePoolSpec{
ClusterName: s.Current.Cluster.Name,
//Replicas: ,
ClusterName: s.Current.Cluster.Name,
FailureDomains: failureDomains,
Template: clusterv1.MachineTemplateSpec{
Spec: clusterv1.MachineSpec{
ClusterName: s.Current.Cluster.Name,
Version: pointer.String(version),
Bootstrap: clusterv1.Bootstrap{ConfigRef: desiredBootstrapTemplateRef},
InfrastructureRef: *desiredInfraMachineTemplateRef,
FailureDomain: failureDomain,
NodeDrainTimeout: nodeDrainTimeout,
NodeVolumeDetachTimeout: nodeVolumeDetachTimeout,
NodeDeletionTimeout: nodeDeletionTimeout,
Expand Down

0 comments on commit dd5ccf6

Please sign in to comment.