Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add topology field for MinReadySeconds #7362

Merged
merged 1 commit into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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