Skip to content

Commit 6a80f0b

Browse files
Add volumeDetachTimeout to Machine
1 parent 70c9771 commit 6a80f0b

26 files changed

+122
-11
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.VolumeDetachTimeout = restored.Spec.VolumeDetachTimeout
101102
dst.Status.NodeInfo = restored.Status.NodeInfo
102103
return nil
103104
}
@@ -141,6 +142,7 @@ func (src *MachineSet) ConvertTo(dstRaw conversion.Hub) error {
141142
return err
142143
}
143144
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
145+
dst.Spec.Template.Spec.VolumeDetachTimeout = restored.Spec.Template.Spec.VolumeDetachTimeout
144146
dst.Status.Conditions = restored.Status.Conditions
145147
return nil
146148
}
@@ -195,6 +197,7 @@ func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error {
195197
}
196198

197199
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
200+
dst.Spec.Template.Spec.VolumeDetachTimeout = restored.Spec.Template.Spec.VolumeDetachTimeout
198201
dst.Status.Conditions = restored.Status.Conditions
199202
return nil
200203
}

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/condition_consts.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ const (
124124
// WaitingExternalHookReason (Severity=Info) provide evidence that we are waiting for an external hook to complete.
125125
WaitingExternalHookReason = "WaitingExternalHook"
126126

127-
// VolumeDetachSucceededCondition reports a machine waiting for volumes to be detached.
128-
VolumeDetachSucceededCondition ConditionType = "VolumeDetachSucceeded"
127+
// VolumeDetachFinishedCondition reports a machine node volume detachment finished either by waiting for volumes to be
128+
// detached or left alone due to volume detach timeout exceeded.
129+
VolumeDetachFinishedCondition ConditionType = "VolumeDetachFinished"
129130

130131
// WaitingForVolumeDetachReason (Severity=Info) provide evidence that a machine node waiting for volumes to be attached.
131132
WaitingForVolumeDetachReason = "WaitingForVolumeDetach"

api/v1alpha4/conversion.go

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

156156
dst.Spec.NodeDeletionTimeout = restored.Spec.NodeDeletionTimeout
157+
dst.Spec.VolumeDetachTimeout = restored.Spec.VolumeDetachTimeout
157158
return nil
158159
}
159160

@@ -198,6 +199,7 @@ func (src *MachineSet) ConvertTo(dstRaw conversion.Hub) error {
198199
}
199200

200201
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
202+
dst.Spec.Template.Spec.VolumeDetachTimeout = restored.Spec.Template.Spec.VolumeDetachTimeout
201203
return nil
202204
}
203205

@@ -238,6 +240,7 @@ func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error {
238240
}
239241

240242
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
243+
dst.Spec.Template.Spec.VolumeDetachTimeout = restored.Spec.Template.Spec.VolumeDetachTimeout
241244
return nil
242245
}
243246

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/condition_consts.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ const (
124124
// WaitingExternalHookReason (Severity=Info) provide evidence that we are waiting for an external hook to complete.
125125
WaitingExternalHookReason = "WaitingExternalHook"
126126

127-
// VolumeDetachSucceededCondition reports a machine waiting for volumes to be detached.
128-
VolumeDetachSucceededCondition ConditionType = "VolumeDetachSucceeded"
127+
// VolumeDetachFinishedCondition reports a machine node volume detachment finished either by waiting for volumes to be
128+
// detached or left alone due to volume detach timeout exceeded.
129+
VolumeDetachFinishedCondition ConditionType = "VolumeDetachFinished"
129130

130131
// WaitingForVolumeDetachReason (Severity=Info) provide evidence that a machine node waiting for volumes to be attached.
131132
WaitingForVolumeDetachReason = "WaitingForVolumeDetach"

api/v1beta1/machine_types.go

+5
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ type MachineSpec struct {
9797
// +optional
9898
NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`
9999

100+
// VolumeDetachTimeout is the total amount of time that the controller will spend on waiting for a volume
101+
// to be detached. The default value is 0, meaning that the volume can be detached without any time limitations.
102+
// +optional
103+
VolumeDetachTimeout *metav1.Duration `json:"volumeDetachTimeout,omitempty"`
104+
100105
// NodeDeletionTimeout defines how long the controller will attempt to delete the Node that the Machine
101106
// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
102107
// 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.

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

+6
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,12 @@ spec:
13251325
description: Version defines the desired Kubernetes version.
13261326
This field is meant to be optionally used by bootstrap providers.
13271327
type: string
1328+
volumeDetachTimeout:
1329+
description: VolumeDetachTimeout is the total amount of time
1330+
that the controller will spend on waiting for a volume to
1331+
be detached. The default value is 0, meaning that the volume
1332+
can be detached without any time limitations.
1333+
type: string
13281334
required:
13291335
- bootstrap
13301336
- clusterName

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

+6
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,12 @@ spec:
12051205
description: Version defines the desired Kubernetes version.
12061206
This field is meant to be optionally used by bootstrap providers.
12071207
type: string
1208+
volumeDetachTimeout:
1209+
description: VolumeDetachTimeout is the total amount of time
1210+
that the controller will spend on waiting for a volume to
1211+
be detached. The default value is 0, meaning that the volume
1212+
can be detached without any time limitations.
1213+
type: string
12081214
required:
12091215
- bootstrap
12101216
- clusterName

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

+6
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,12 @@ spec:
918918
description: Version defines the desired Kubernetes version. This
919919
field is meant to be optionally used by bootstrap providers.
920920
type: string
921+
volumeDetachTimeout:
922+
description: VolumeDetachTimeout is the total amount of time that
923+
the controller will spend on waiting for a volume to be detached.
924+
The default value is 0, meaning that the volume can be detached
925+
without any time limitations.
926+
type: string
921927
required:
922928
- bootstrap
923929
- clusterName

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

+6
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,12 @@ spec:
11311131
description: Version defines the desired Kubernetes version.
11321132
This field is meant to be optionally used by bootstrap providers.
11331133
type: string
1134+
volumeDetachTimeout:
1135+
description: VolumeDetachTimeout is the total amount of time
1136+
that the controller will spend on waiting for a volume to
1137+
be detached. The default value is 0, meaning that the volume
1138+
can be detached without any time limitations.
1139+
type: string
11341140
required:
11351141
- bootstrap
11361142
- clusterName

controlplane/kubeadm/api/v1alpha3/conversion.go

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error {
4141
dst.Spec.MachineTemplate.ObjectMeta = restored.Spec.MachineTemplate.ObjectMeta
4242
dst.Spec.MachineTemplate.NodeDeletionTimeout = restored.Spec.MachineTemplate.NodeDeletionTimeout
4343
dst.Spec.KubeadmConfigSpec.Users = restored.Spec.KubeadmConfigSpec.Users
44+
dst.Spec.MachineTemplate.VolumeDetachTimeout = restored.Spec.MachineTemplate.VolumeDetachTimeout
4445
dst.Status.Version = restored.Status.Version
4546

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

controlplane/kubeadm/api/v1alpha4/conversion.go

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

6767
dst.Spec.MachineTemplate.NodeDeletionTimeout = restored.Spec.MachineTemplate.NodeDeletionTimeout
68+
dst.Spec.MachineTemplate.VolumeDetachTimeout = restored.Spec.MachineTemplate.VolumeDetachTimeout
6869

6970
return nil
7071
}
@@ -135,6 +136,7 @@ func (src *KubeadmControlPlaneTemplate) ConvertTo(dstRaw conversion.Hub) error {
135136
dst.Spec.Template.Spec.MachineTemplate = restored.Spec.Template.Spec.MachineTemplate
136137
} else if restored.Spec.Template.Spec.MachineTemplate != nil {
137138
dst.Spec.Template.Spec.MachineTemplate.NodeDeletionTimeout = restored.Spec.Template.Spec.MachineTemplate.NodeDeletionTimeout
139+
dst.Spec.Template.Spec.MachineTemplate.VolumeDetachTimeout = restored.Spec.Template.Spec.MachineTemplate.VolumeDetachTimeout
138140
}
139141

140142
return nil

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
@@ -102,6 +102,11 @@ type KubeadmControlPlaneMachineTemplate struct {
102102
// +optional
103103
NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`
104104

105+
// VolumeDetachTimeout is the total amount of time that the controller will spend on waiting for a volume
106+
// to be detached. The default value is 0, meaning that the volume can be detached without any time limitations.
107+
// +optional
108+
VolumeDetachTimeout *metav1.Duration `json:"volumeDetachTimeout,omitempty"`
109+
105110
// NodeDeletionTimeout defines how long the machine controller will attempt to delete the Node that the Machine
106111
// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
107112
// 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
@@ -155,6 +155,7 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error {
155155
{spec, "machineTemplate", "infrastructureRef", "name"},
156156
{spec, "machineTemplate", "infrastructureRef", "kind"},
157157
{spec, "machineTemplate", "nodeDrainTimeout"},
158+
{spec, "machineTemplate", "volumeDetachTimeout"},
158159
{spec, "machineTemplate", "nodeDeletionTimeout"},
159160
{spec, "replicas"},
160161
{spec, "version"},

controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
252252
Name: "infraTemplate",
253253
},
254254
NodeDrainTimeout: &metav1.Duration{Duration: time.Second},
255+
VolumeDetachTimeout: &metav1.Duration{Duration: time.Second},
255256
NodeDeletionTimeout: &metav1.Duration{Duration: time.Second},
256257
},
257258
Replicas: pointer.Int32Ptr(1),
@@ -378,6 +379,7 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
378379
validUpdate.Spec.MachineTemplate.InfrastructureRef.APIVersion = "test/v1alpha2"
379380
validUpdate.Spec.MachineTemplate.InfrastructureRef.Name = "orange"
380381
validUpdate.Spec.MachineTemplate.NodeDrainTimeout = &metav1.Duration{Duration: 10 * time.Second}
382+
validUpdate.Spec.MachineTemplate.VolumeDetachTimeout = &metav1.Duration{Duration: 10 * time.Second}
381383
validUpdate.Spec.MachineTemplate.NodeDeletionTimeout = &metav1.Duration{Duration: 10 * time.Second}
382384
validUpdate.Spec.Replicas = pointer.Int32Ptr(5)
383385
now := metav1.NewTime(time.Now())

controlplane/kubeadm/api/v1beta1/kubeadmcontrolplanetemplate_types.go

+5
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ type KubeadmControlPlaneTemplateMachineTemplate struct {
100100
// +optional
101101
NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`
102102

103+
// VolumeDetachTimeout is the total amount of time that the controller will spend on waiting for a volume
104+
// to be detached. The default value is 0, meaning that the volume can be detached without any time limitations.
105+
// +optional
106+
VolumeDetachTimeout *metav1.Duration `json:"volumeDetachTimeout,omitempty"`
107+
103108
// NodeDeletionTimeout defines how long the machine controller will attempt to delete the Node that the Machine
104109
// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
105110
// 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
Original file line numberDiff line numberDiff line change
@@ -3568,6 +3568,12 @@ spec:
35683568
any time limitations. NOTE: NodeDrainTimeout is different from
35693569
`kubectl drain --timeout`'
35703570
type: string
3571+
volumeDetachTimeout:
3572+
description: VolumeDetachTimeout is the total amount of time that
3573+
the controller will spend on waiting for a volume to be detached.
3574+
The default value is 0, meaning that the volume can be detached
3575+
without any time limitations.
3576+
type: string
35713577
required:
35723578
- infrastructureRef
35733579
type: object

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

+6
Original file line numberDiff line numberDiff line change
@@ -2330,6 +2330,12 @@ spec:
23302330
be drained without any time limitations. NOTE: NodeDrainTimeout
23312331
is different from `kubectl drain --timeout`'
23322332
type: string
2333+
volumeDetachTimeout:
2334+
description: VolumeDetachTimeout is the total amount of
2335+
time that the controller will spend on waiting for a
2336+
volume to be detached. The default value is 0, meaning
2337+
that the volume can be detached without any time limitations.
2338+
type: string
23332339
type: object
23342340
rolloutAfter:
23352341
description: RolloutAfter is a field to indicate a rollout

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.volumeDetachTimeout` - is a *metav1.Duration defining how long the controller
102+
will spend on waiting for a volume 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

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.VolumeDetachTimeout = restored.Spec.Template.Spec.VolumeDetachTimeout
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.VolumeDetachTimeout = restored.Spec.Template.Spec.VolumeDetachTimeout
3940
return nil
4041
}
4142

0 commit comments

Comments
 (0)