Skip to content

✨ Add nodeVolumeDetachTimeout property to Machine #6413

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

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
3 changes: 3 additions & 0 deletions api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (src *Machine) ConvertTo(dstRaw conversion.Hub) error {
}

dst.Spec.NodeDeletionTimeout = restored.Spec.NodeDeletionTimeout
dst.Spec.NodeVolumeDetachTimeout = restored.Spec.NodeVolumeDetachTimeout
dst.Status.NodeInfo = restored.Status.NodeInfo
dst.Status.CertificatesExpiryDate = restored.Status.CertificatesExpiryDate
return nil
Expand Down Expand Up @@ -142,6 +143,7 @@ func (src *MachineSet) ConvertTo(dstRaw conversion.Hub) error {
return err
}
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout
dst.Status.Conditions = restored.Status.Conditions
return nil
}
Expand Down Expand Up @@ -196,6 +198,7 @@ func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error {
}

dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout
dst.Status.Conditions = restored.Status.Conditions
return nil
}
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha3/zz_generated.conversion.go

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

3 changes: 3 additions & 0 deletions api/v1alpha4/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func (src *Machine) ConvertTo(dstRaw conversion.Hub) error {

dst.Spec.NodeDeletionTimeout = restored.Spec.NodeDeletionTimeout
dst.Status.CertificatesExpiryDate = restored.Status.CertificatesExpiryDate
dst.Spec.NodeVolumeDetachTimeout = restored.Spec.NodeVolumeDetachTimeout
return nil
}

Expand Down Expand Up @@ -204,6 +205,7 @@ func (src *MachineSet) ConvertTo(dstRaw conversion.Hub) error {
}

dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout
return nil
}

Expand Down Expand Up @@ -244,6 +246,7 @@ func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error {
}

dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout
return nil
}

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.

8 changes: 8 additions & 0 deletions api/v1beta1/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const (
// ExcludeNodeDrainingAnnotation annotation explicitly skips node draining if set.
ExcludeNodeDrainingAnnotation = "machine.cluster.x-k8s.io/exclude-node-draining"

// ExcludeWaitForNodeVolumeDetachAnnotation annotation explicitly skips the waiting for node volume detaching if set.
ExcludeWaitForNodeVolumeDetachAnnotation = "machine.cluster.x-k8s.io/exclude-wait-for-node-volume-detach"

// MachineSetLabelName is the label set on machines if they're controlled by MachineSet.
MachineSetLabelName = "cluster.x-k8s.io/set-name"

Expand Down Expand Up @@ -103,6 +106,11 @@ type MachineSpec struct {
// +optional
NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

It'd be good to start a section may be here https://cluster-api.sigs.k8s.io/tasks/automated-machine-management/index.html and document the different available timeouts and illustrating examples for their use cases. This can be a follow up though.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes absolutely, I would also prefer to do it in a follow-up PR if there are no objections. Thanks for reminding.


// NodeVolumeDetachTimeout is the total amount of time that the controller will spend on waiting for all volumes
// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
// +optional
NodeVolumeDetachTimeout *metav1.Duration `json:"nodeVolumeDetachTimeout,omitempty"`

// NodeDeletionTimeout defines how long the controller will attempt to delete the Node that the Machine
// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
// Defaults to 10 seconds.
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.

6 changes: 6 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_machinedeployments.yaml

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_machinepools.yaml

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_machines.yaml

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_machinesets.yaml

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

1 change: 1 addition & 0 deletions controlplane/kubeadm/api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.MachineTemplate.NodeDeletionTimeout = restored.Spec.MachineTemplate.NodeDeletionTimeout
dst.Spec.KubeadmConfigSpec.Files = restored.Spec.KubeadmConfigSpec.Files
dst.Spec.KubeadmConfigSpec.Users = restored.Spec.KubeadmConfigSpec.Users
dst.Spec.MachineTemplate.NodeVolumeDetachTimeout = restored.Spec.MachineTemplate.NodeVolumeDetachTimeout
dst.Status.Version = restored.Status.Version

if restored.Spec.KubeadmConfigSpec.Users != nil {
Expand Down
2 changes: 2 additions & 0 deletions controlplane/kubeadm/api/v1alpha4/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error {

dst.Spec.MachineTemplate.NodeDeletionTimeout = restored.Spec.MachineTemplate.NodeDeletionTimeout
dst.Spec.RolloutBefore = restored.Spec.RolloutBefore
dst.Spec.MachineTemplate.NodeVolumeDetachTimeout = restored.Spec.MachineTemplate.NodeVolumeDetachTimeout

return nil
}
Expand Down Expand Up @@ -139,6 +140,7 @@ func (src *KubeadmControlPlaneTemplate) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.Template.Spec.MachineTemplate = restored.Spec.Template.Spec.MachineTemplate
} else if restored.Spec.Template.Spec.MachineTemplate != nil {
dst.Spec.Template.Spec.MachineTemplate.NodeDeletionTimeout = restored.Spec.Template.Spec.MachineTemplate.NodeDeletionTimeout
dst.Spec.Template.Spec.MachineTemplate.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.MachineTemplate.NodeVolumeDetachTimeout
}

dst.Spec.Template.Spec.RolloutBefore = restored.Spec.Template.Spec.RolloutBefore
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ type KubeadmControlPlaneMachineTemplate struct {
// +optional
NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`

// NodeVolumeDetachTimeout is the total amount of time that the controller will spend on waiting for all volumes
// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
// +optional
NodeVolumeDetachTimeout *metav1.Duration `json:"nodeVolumeDetachTimeout,omitempty"`

// NodeDeletionTimeout defines how long the machine controller will attempt to delete the Node that the Machine
// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
// If no value is provided, the default value for this property of the Machine resource will be used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error {
{spec, "machineTemplate", "infrastructureRef", "name"},
{spec, "machineTemplate", "infrastructureRef", "kind"},
{spec, "machineTemplate", "nodeDrainTimeout"},
{spec, "machineTemplate", "nodeVolumeDetachTimeout"},
{spec, "machineTemplate", "nodeDeletionTimeout"},
{spec, "replicas"},
{spec, "version"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
Namespace: "foo",
Name: "infraTemplate",
},
NodeDrainTimeout: &metav1.Duration{Duration: time.Second},
NodeDeletionTimeout: &metav1.Duration{Duration: time.Second},
NodeDrainTimeout: &metav1.Duration{Duration: time.Second},
NodeVolumeDetachTimeout: &metav1.Duration{Duration: time.Second},
NodeDeletionTimeout: &metav1.Duration{Duration: time.Second},
},
Replicas: pointer.Int32Ptr(1),
RolloutStrategy: &RolloutStrategy{
Expand Down Expand Up @@ -398,6 +399,7 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
validUpdate.Spec.MachineTemplate.InfrastructureRef.APIVersion = "test/v1alpha2"
validUpdate.Spec.MachineTemplate.InfrastructureRef.Name = "orange"
validUpdate.Spec.MachineTemplate.NodeDrainTimeout = &metav1.Duration{Duration: 10 * time.Second}
validUpdate.Spec.MachineTemplate.NodeVolumeDetachTimeout = &metav1.Duration{Duration: 10 * time.Second}
validUpdate.Spec.MachineTemplate.NodeDeletionTimeout = &metav1.Duration{Duration: 10 * time.Second}
validUpdate.Spec.Replicas = pointer.Int32Ptr(5)
now := metav1.NewTime(time.Now())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ type KubeadmControlPlaneTemplateMachineTemplate struct {
// +optional
NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`

// NodeVolumeDetachTimeout is the total amount of time that the controller will spend on waiting for all volumes
// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
// +optional
NodeVolumeDetachTimeout *metav1.Duration `json:"nodeVolumeDetachTimeout,omitempty"`

// NodeDeletionTimeout defines how long the machine controller will attempt to delete the Node that the Machine
// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
// If no value is provided, the default value for this property of the Machine resource will be used.
Expand Down
10 changes: 10 additions & 0 deletions controlplane/kubeadm/api/v1beta1/zz_generated.deepcopy.go

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

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ documentation][scale].
that the controller will spend on draining a control plane node.
The default value is 0, meaning that the node can be drained without any time limitations.

* `machineTemplate.nodeVolumeDetachTimeout` - is a *metav1.Duration defining how long the controller
will spend on waiting for all volumes to be detached.
The default value is 0, meaning that the volume can be detached without any time limitations.

* `machineTemplate.nodeDeletionTimeout` - is a *metav1.Duration defining how long the controller
will attempt to delete the Node that is hosted by a Machine after the Machine is marked for
deletion. A duration of 0 will retry deletion indefinitely. It defaults to 10 seconds on the
Expand Down
4 changes: 3 additions & 1 deletion docs/book/src/developer/providers/v1.2-to-v1.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ in Cluster API are kept in sync with the versions used by `sigs.k8s.io/controlle

### API Changes

-
- A new timeout `nodeVolumeDetachTimeout` has been introduced that defines how long the controller will spend on waiting for all volumes to be detached.
The default value is 0, meaning that the volume can be detached without any time limitations.
- A new annotation `machine.cluster.x-k8s.io/exclude-wait-for-node-volume-detach` has been introduced that allows explicitly skip the waiting for node volume detaching.

### Other

Expand Down
1 change: 1 addition & 0 deletions exp/api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error {
return err
}
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout
return nil
}

Expand Down
1 change: 1 addition & 0 deletions exp/api/v1alpha4/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error {
return err
}
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout
return nil
}

Expand Down
Loading