Skip to content

Commit a27f71c

Browse files
✨ Add nodeVolumeDetachTimeout property to Machine
1 parent fd11302 commit a27f71c

27 files changed

+273
-6
lines changed

api/v1alpha3/conversion.go

+3
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func (src *Machine) ConvertTo(dstRaw conversion.Hub) error {
9898
}
9999

100100
dst.Spec.NodeDeletionTimeout = restored.Spec.NodeDeletionTimeout
101+
dst.Spec.NodeVolumeDetachTimeout = restored.Spec.NodeVolumeDetachTimeout
101102
dst.Status.NodeInfo = restored.Status.NodeInfo
102103
dst.Status.CertificatesExpiryDate = restored.Status.CertificatesExpiryDate
103104
return nil
@@ -142,6 +143,7 @@ func (src *MachineSet) ConvertTo(dstRaw conversion.Hub) error {
142143
return err
143144
}
144145
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
146+
dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout
145147
dst.Status.Conditions = restored.Status.Conditions
146148
return nil
147149
}
@@ -196,6 +198,7 @@ func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error {
196198
}
197199

198200
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
201+
dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout
199202
dst.Status.Conditions = restored.Status.Conditions
200203
return nil
201204
}

api/v1alpha3/zz_generated.conversion.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha4/conversion.go

+3
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ func (src *Machine) ConvertTo(dstRaw conversion.Hub) error {
160160

161161
dst.Spec.NodeDeletionTimeout = restored.Spec.NodeDeletionTimeout
162162
dst.Status.CertificatesExpiryDate = restored.Status.CertificatesExpiryDate
163+
dst.Spec.NodeVolumeDetachTimeout = restored.Spec.NodeVolumeDetachTimeout
163164
return nil
164165
}
165166

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

206207
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
208+
dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout
207209
return nil
208210
}
209211

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

246248
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
249+
dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout
247250
return nil
248251
}
249252

api/v1alpha4/zz_generated.conversion.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/machine_types.go

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ const (
3333
// ExcludeNodeDrainingAnnotation annotation explicitly skips node draining if set.
3434
ExcludeNodeDrainingAnnotation = "machine.cluster.x-k8s.io/exclude-node-draining"
3535

36+
// ExcludeWaitForNodeVolumeDetachAnnotation annotation explicitly skips the waiting for node volume detaching if set.
37+
ExcludeWaitForNodeVolumeDetachAnnotation = "machine.cluster.x-k8s.io/exclude-wait-for-node-volume-detach"
38+
3639
// MachineSetLabelName is the label set on machines if they're controlled by MachineSet.
3740
MachineSetLabelName = "cluster.x-k8s.io/set-name"
3841

@@ -103,6 +106,11 @@ type MachineSpec struct {
103106
// +optional
104107
NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`
105108

109+
// NodeVolumeDetachTimeout is the total amount of time that the controller will spend on waiting for all volumes
110+
// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
111+
// +optional
112+
NodeVolumeDetachTimeout *metav1.Duration `json:"nodeVolumeDetachTimeout,omitempty"`
113+
106114
// NodeDeletionTimeout defines how long the controller will attempt to delete the Node that the Machine
107115
// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
108116
// Defaults to 10 seconds.

api/v1beta1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/zz_generated.openapi.go

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cluster.x-k8s.io_machinepools.yaml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cluster.x-k8s.io_machines.yaml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cluster.x-k8s.io_machinesets.yaml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/kubeadm/api/v1alpha3/conversion.go

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error {
4242
dst.Spec.MachineTemplate.NodeDeletionTimeout = restored.Spec.MachineTemplate.NodeDeletionTimeout
4343
dst.Spec.KubeadmConfigSpec.Files = restored.Spec.KubeadmConfigSpec.Files
4444
dst.Spec.KubeadmConfigSpec.Users = restored.Spec.KubeadmConfigSpec.Users
45+
dst.Spec.MachineTemplate.NodeVolumeDetachTimeout = restored.Spec.MachineTemplate.NodeVolumeDetachTimeout
4546
dst.Status.Version = restored.Status.Version
4647

4748
if restored.Spec.KubeadmConfigSpec.Users != nil {

controlplane/kubeadm/api/v1alpha4/conversion.go

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error {
6868

6969
dst.Spec.MachineTemplate.NodeDeletionTimeout = restored.Spec.MachineTemplate.NodeDeletionTimeout
7070
dst.Spec.RolloutBefore = restored.Spec.RolloutBefore
71+
dst.Spec.MachineTemplate.NodeVolumeDetachTimeout = restored.Spec.MachineTemplate.NodeVolumeDetachTimeout
7172

7273
return nil
7374
}
@@ -139,6 +140,7 @@ func (src *KubeadmControlPlaneTemplate) ConvertTo(dstRaw conversion.Hub) error {
139140
dst.Spec.Template.Spec.MachineTemplate = restored.Spec.Template.Spec.MachineTemplate
140141
} else if restored.Spec.Template.Spec.MachineTemplate != nil {
141142
dst.Spec.Template.Spec.MachineTemplate.NodeDeletionTimeout = restored.Spec.Template.Spec.MachineTemplate.NodeDeletionTimeout
143+
dst.Spec.Template.Spec.MachineTemplate.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.MachineTemplate.NodeVolumeDetachTimeout
142144
}
143145

144146
dst.Spec.Template.Spec.RolloutBefore = restored.Spec.Template.Spec.RolloutBefore

controlplane/kubeadm/api/v1alpha4/zz_generated.conversion.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go

+5
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ type KubeadmControlPlaneMachineTemplate struct {
106106
// +optional
107107
NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`
108108

109+
// NodeVolumeDetachTimeout is the total amount of time that the controller will spend on waiting for all volumes
110+
// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
111+
// +optional
112+
NodeVolumeDetachTimeout *metav1.Duration `json:"nodeVolumeDetachTimeout,omitempty"`
113+
109114
// NodeDeletionTimeout defines how long the machine controller will attempt to delete the Node that the Machine
110115
// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
111116
// If no value is provided, the default value for this property of the Machine resource will be used.

controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error {
161161
{spec, "machineTemplate", "infrastructureRef", "name"},
162162
{spec, "machineTemplate", "infrastructureRef", "kind"},
163163
{spec, "machineTemplate", "nodeDrainTimeout"},
164+
{spec, "machineTemplate", "nodeVolumeDetachTimeout"},
164165
{spec, "machineTemplate", "nodeDeletionTimeout"},
165166
{spec, "replicas"},
166167
{spec, "version"},

controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,9 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
271271
Namespace: "foo",
272272
Name: "infraTemplate",
273273
},
274-
NodeDrainTimeout: &metav1.Duration{Duration: time.Second},
275-
NodeDeletionTimeout: &metav1.Duration{Duration: time.Second},
274+
NodeDrainTimeout: &metav1.Duration{Duration: time.Second},
275+
NodeVolumeDetachTimeout: &metav1.Duration{Duration: time.Second},
276+
NodeDeletionTimeout: &metav1.Duration{Duration: time.Second},
276277
},
277278
Replicas: pointer.Int32Ptr(1),
278279
RolloutStrategy: &RolloutStrategy{
@@ -398,6 +399,7 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
398399
validUpdate.Spec.MachineTemplate.InfrastructureRef.APIVersion = "test/v1alpha2"
399400
validUpdate.Spec.MachineTemplate.InfrastructureRef.Name = "orange"
400401
validUpdate.Spec.MachineTemplate.NodeDrainTimeout = &metav1.Duration{Duration: 10 * time.Second}
402+
validUpdate.Spec.MachineTemplate.NodeVolumeDetachTimeout = &metav1.Duration{Duration: 10 * time.Second}
401403
validUpdate.Spec.MachineTemplate.NodeDeletionTimeout = &metav1.Duration{Duration: 10 * time.Second}
402404
validUpdate.Spec.Replicas = pointer.Int32Ptr(5)
403405
now := metav1.NewTime(time.Now())

controlplane/kubeadm/api/v1beta1/kubeadmcontrolplanetemplate_types.go

+5
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ type KubeadmControlPlaneTemplateMachineTemplate struct {
106106
// +optional
107107
NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`
108108

109+
// NodeVolumeDetachTimeout is the total amount of time that the controller will spend on waiting for all volumes
110+
// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
111+
// +optional
112+
NodeVolumeDetachTimeout *metav1.Duration `json:"nodeVolumeDetachTimeout,omitempty"`
113+
109114
// NodeDeletionTimeout defines how long the machine controller will attempt to delete the Node that the Machine
110115
// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
111116
// If no value is provided, the default value for this property of the Machine resource will be used.

controlplane/kubeadm/api/v1beta1/zz_generated.deepcopy.go

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/book/src/developer/architecture/controllers/control-plane.md

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

101+
* `machineTemplate.nodeVolumeDetachTimeout` - is a *metav1.Duration defining how long the controller
102+
will spend on waiting for all volumes to be detached.
103+
The default value is 0, meaning that the volume can be detached without any time limitations.
104+
101105
* `machineTemplate.nodeDeletionTimeout` - is a *metav1.Duration defining how long the controller
102106
will attempt to delete the Node that is hosted by a Machine after the Machine is marked for
103107
deletion. A duration of 0 will retry deletion indefinitely. It defaults to 10 seconds on the

docs/book/src/developer/providers/v1.2-to-v1.3.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ in Cluster API are kept in sync with the versions used by `sigs.k8s.io/controlle
2828

2929
### API Changes
3030

31-
-
31+
- A new timeout `nodeVolumeDetachTimeout` has been introduced that defines how long the controller will spend on waiting for all volumes to be detached.
32+
The default value is 0, meaning that the volume can be detached without any time limitations.
33+
- 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.
3234

3335
### Other
3436

exp/api/v1alpha3/conversion.go

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error {
7171
return err
7272
}
7373
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
74+
dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout
7475
return nil
7576
}
7677

exp/api/v1alpha4/conversion.go

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error {
3636
return err
3737
}
3838
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
39+
dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout
3940
return nil
4041
}
4142

0 commit comments

Comments
 (0)