Skip to content

Commit

Permalink
✨ Add topology field for MinReadySeconds
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Jansen <[email protected]>
  • Loading branch information
farodin91 committed Oct 10, 2022
1 parent df0fb87 commit 2815007
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/v1alpha4/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (src *Cluster) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.Topology.Workers.MachineDeployments[i].NodeDrainTimeout = restored.Spec.Topology.Workers.MachineDeployments[i].NodeDrainTimeout
dst.Spec.Topology.Workers.MachineDeployments[i].NodeVolumeDetachTimeout = restored.Spec.Topology.Workers.MachineDeployments[i].NodeVolumeDetachTimeout
dst.Spec.Topology.Workers.MachineDeployments[i].NodeDeletionTimeout = restored.Spec.Topology.Workers.MachineDeployments[i].NodeDeletionTimeout
dst.Spec.Topology.Workers.MachineDeployments[i].MinReadySeconds = restored.Spec.Topology.Workers.MachineDeployments[i].MinReadySeconds
dst.Spec.Topology.Workers.MachineDeployments[i].MachineHealthCheck = restored.Spec.Topology.Workers.MachineDeployments[i].MachineHealthCheck
}
}
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha4/zz_generated.conversion.go

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

7 changes: 7 additions & 0 deletions api/v1beta1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ type MachineDeploymentTopology struct {
// +optional
NodeDeletionTimeout *metav1.Duration `json:"nodeDeletionTimeout,omitempty"`

// Minimum number of seconds for which a newly created machine should
// be ready.
// Defaults to 0 (machine will be considered available as soon as it
// is ready)
// +optional
MinReadySeconds *int32 `json:"minReadySeconds,omitempty"`

// Variables can be used to customize the MachineDeployment through patches.
// +optional
Variables *MachineDeploymentVariables `json:"variables,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

7 changes: 7 additions & 0 deletions api/v1beta1/zz_generated.openapi.go

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

6 changes: 6 additions & 0 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.

3 changes: 2 additions & 1 deletion internal/controllers/topology/cluster/desired_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ func computeMachineDeployment(_ context.Context, s *scope.Scope, desiredControlP
Namespace: s.Current.Cluster.Namespace,
},
Spec: clusterv1.MachineDeploymentSpec{
ClusterName: s.Current.Cluster.Name,
ClusterName: s.Current.Cluster.Name,
MinReadySeconds: machineDeploymentTopology.MinReadySeconds,
Template: clusterv1.MachineTemplateSpec{
ObjectMeta: clusterv1.ObjectMeta{
Labels: mergeMap(machineDeploymentTopology.Metadata.Labels, machineDeploymentBlueprint.Metadata.Labels),
Expand Down
3 changes: 3 additions & 0 deletions internal/controllers/topology/cluster/desired_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,7 @@ func TestComputeMachineDeployment(t *testing.T) {
nodeDrainTimeout := metav1.Duration{Duration: 10 * time.Second}
nodeVolumeDetachTimeout := metav1.Duration{Duration: 10 * time.Second}
nodeDeletionTimeout := metav1.Duration{Duration: 10 * time.Second}
minReadySeconds := int32(5)
mdTopology := clusterv1.MachineDeploymentTopology{
Metadata: clusterv1.ObjectMeta{
Labels: map[string]string{"foo": "baz"},
Expand All @@ -1339,6 +1340,7 @@ func TestComputeMachineDeployment(t *testing.T) {
NodeDrainTimeout: &nodeDrainTimeout,
NodeVolumeDetachTimeout: &nodeVolumeDetachTimeout,
NodeDeletionTimeout: &nodeDeletionTimeout,
MinReadySeconds: &minReadySeconds,
}

t.Run("Generates the machine deployment and the referenced templates", func(t *testing.T) {
Expand All @@ -1365,6 +1367,7 @@ func TestComputeMachineDeployment(t *testing.T) {

actualMd := actual.Object
g.Expect(*actualMd.Spec.Replicas).To(Equal(replicas))
g.Expect(*actualMd.Spec.MinReadySeconds).To(Equal(minReadySeconds))
g.Expect(*actualMd.Spec.Template.Spec.FailureDomain).To(Equal(failureDomain))
g.Expect(*actualMd.Spec.Template.Spec.NodeDrainTimeout).To(Equal(nodeDrainTimeout))
g.Expect(*actualMd.Spec.Template.Spec.NodeDeletionTimeout).To(Equal(nodeDeletionTimeout))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spec:
name: "md-0"
nodeDeletionTimeout: "30s"
nodeVolumeDetachTimeout: "5m"
minReadySeconds: 5
replicas: ${WORKER_MACHINE_COUNT}
failureDomain: fd4
variables:
Expand Down

0 comments on commit 2815007

Please sign in to comment.