Skip to content

Commit 1a64aeb

Browse files
Add volumeDetachTimeout to Machine
1 parent 90923e7 commit 1a64aeb

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
@@ -1338,6 +1338,12 @@ spec:
13381338
description: Version defines the desired Kubernetes version.
13391339
This field is meant to be optionally used by bootstrap providers.
13401340
type: string
1341+
volumeDetachTimeout:
1342+
description: VolumeDetachTimeout is the total amount of time
1343+
that the controller will spend on waiting for a volume to
1344+
be detached. The default value is 0, meaning that the volume
1345+
can be detached without any time limitations.
1346+
type: string
13411347
required:
13421348
- bootstrap
13431349
- clusterName

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

+6
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,12 @@ spec:
12151215
description: Version defines the desired Kubernetes version.
12161216
This field is meant to be optionally used by bootstrap providers.
12171217
type: string
1218+
volumeDetachTimeout:
1219+
description: VolumeDetachTimeout is the total amount of time
1220+
that the controller will spend on waiting for a volume to
1221+
be detached. The default value is 0, meaning that the volume
1222+
can be detached without any time limitations.
1223+
type: string
12181224
required:
12191225
- bootstrap
12201226
- clusterName

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

+6
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,12 @@ spec:
926926
description: Version defines the desired Kubernetes version. This
927927
field is meant to be optionally used by bootstrap providers.
928928
type: string
929+
volumeDetachTimeout:
930+
description: VolumeDetachTimeout is the total amount of time that
931+
the controller will spend on waiting for a volume to be detached.
932+
The default value is 0, meaning that the volume can be detached
933+
without any time limitations.
934+
type: string
929935
required:
930936
- bootstrap
931937
- clusterName

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

+6
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,12 @@ spec:
11441144
description: Version defines the desired Kubernetes version.
11451145
This field is meant to be optionally used by bootstrap providers.
11461146
type: string
1147+
volumeDetachTimeout:
1148+
description: VolumeDetachTimeout is the total amount of time
1149+
that the controller will spend on waiting for a volume to
1150+
be detached. The default value is 0, meaning that the volume
1151+
can be detached without any time limitations.
1152+
type: string
11471153
required:
11481154
- bootstrap
11491155
- clusterName

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.VolumeDetachTimeout = restored.Spec.MachineTemplate.VolumeDetachTimeout
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
@@ -67,6 +67,7 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error {
6767
}
6868

6969
dst.Spec.MachineTemplate.NodeDeletionTimeout = restored.Spec.MachineTemplate.NodeDeletionTimeout
70+
dst.Spec.MachineTemplate.VolumeDetachTimeout = restored.Spec.MachineTemplate.VolumeDetachTimeout
7071

7172
return nil
7273
}
@@ -138,6 +139,7 @@ func (src *KubeadmControlPlaneTemplate) ConvertTo(dstRaw conversion.Hub) error {
138139
dst.Spec.Template.Spec.MachineTemplate = restored.Spec.Template.Spec.MachineTemplate
139140
} else if restored.Spec.Template.Spec.MachineTemplate != nil {
140141
dst.Spec.Template.Spec.MachineTemplate.NodeDeletionTimeout = restored.Spec.Template.Spec.MachineTemplate.NodeDeletionTimeout
142+
dst.Spec.Template.Spec.MachineTemplate.VolumeDetachTimeout = restored.Spec.Template.Spec.MachineTemplate.VolumeDetachTimeout
141143
}
142144

143145
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
@@ -159,6 +159,7 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error {
159159
{spec, "machineTemplate", "infrastructureRef", "name"},
160160
{spec, "machineTemplate", "infrastructureRef", "kind"},
161161
{spec, "machineTemplate", "nodeDrainTimeout"},
162+
{spec, "machineTemplate", "volumeDetachTimeout"},
162163
{spec, "machineTemplate", "nodeDeletionTimeout"},
163164
{spec, "replicas"},
164165
{spec, "version"},

controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
262262
Name: "infraTemplate",
263263
},
264264
NodeDrainTimeout: &metav1.Duration{Duration: time.Second},
265+
VolumeDetachTimeout: &metav1.Duration{Duration: time.Second},
265266
NodeDeletionTimeout: &metav1.Duration{Duration: time.Second},
266267
},
267268
Replicas: pointer.Int32Ptr(1),
@@ -388,6 +389,7 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
388389
validUpdate.Spec.MachineTemplate.InfrastructureRef.APIVersion = "test/v1alpha2"
389390
validUpdate.Spec.MachineTemplate.InfrastructureRef.Name = "orange"
390391
validUpdate.Spec.MachineTemplate.NodeDrainTimeout = &metav1.Duration{Duration: 10 * time.Second}
392+
validUpdate.Spec.MachineTemplate.VolumeDetachTimeout = &metav1.Duration{Duration: 10 * time.Second}
391393
validUpdate.Spec.MachineTemplate.NodeDeletionTimeout = &metav1.Duration{Duration: 10 * time.Second}
392394
validUpdate.Spec.Replicas = pointer.Int32Ptr(5)
393395
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
@@ -3577,6 +3577,12 @@ spec:
35773577
any time limitations. NOTE: NodeDrainTimeout is different from
35783578
`kubectl drain --timeout`'
35793579
type: string
3580+
volumeDetachTimeout:
3581+
description: VolumeDetachTimeout is the total amount of time that
3582+
the controller will spend on waiting for a volume to be detached.
3583+
The default value is 0, meaning that the volume can be detached
3584+
without any time limitations.
3585+
type: string
35803586
required:
35813587
- infrastructureRef
35823588
type: object

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

+6
Original file line numberDiff line numberDiff line change
@@ -2337,6 +2337,12 @@ spec:
23372337
be drained without any time limitations. NOTE: NodeDrainTimeout
23382338
is different from `kubectl drain --timeout`'
23392339
type: string
2340+
volumeDetachTimeout:
2341+
description: VolumeDetachTimeout is the total amount of
2342+
time that the controller will spend on waiting for a
2343+
volume to be detached. The default value is 0, meaning
2344+
that the volume can be detached without any time limitations.
2345+
type: string
23402346
type: object
23412347
rolloutAfter:
23422348
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)