From 5ce802076cce46920bec2f6ab10c4c8b62fa4efc Mon Sep 17 00:00:00 2001 From: nasusoba Date: Mon, 20 May 2024 13:42:35 +0800 Subject: [PATCH] add nodeDeletionTimeout and nodeVolumeDetachTimeout Signed-off-by: nasusoba --- controlplane/api/v1beta1/conversion.go | 2 ++ controlplane/api/v1beta1/zz_generated.conversion.go | 2 ++ controlplane/api/v1beta2/kthreescontrolplane_types.go | 9 +++++++++ controlplane/api/v1beta2/zz_generated.deepcopy.go | 10 ++++++++++ ...olplane.cluster.x-k8s.io_kthreescontrolplanes.yaml | 11 +++++++++++ ...cluster.x-k8s.io_kthreescontrolplanetemplates.yaml | 11 +++++++++++ controlplane/controllers/scale.go | 6 ++++-- 7 files changed, 49 insertions(+), 2 deletions(-) diff --git a/controlplane/api/v1beta1/conversion.go b/controlplane/api/v1beta1/conversion.go index 9098e5ec..42ab1b8f 100644 --- a/controlplane/api/v1beta1/conversion.go +++ b/controlplane/api/v1beta1/conversion.go @@ -89,6 +89,8 @@ func (in *KThreesControlPlane) ConvertTo(dstRaw ctrlconversion.Hub) error { dst.Spec.KThreesConfigSpec.ServerConfig.CloudProviderName = restored.Spec.KThreesConfigSpec.ServerConfig.CloudProviderName dst.Spec.KThreesConfigSpec.ServerConfig.DeprecatedDisableExternalCloudProvider = restored.Spec.KThreesConfigSpec.ServerConfig.DeprecatedDisableExternalCloudProvider dst.Spec.KThreesConfigSpec.ServerConfig.DisableCloudController = restored.Spec.KThreesConfigSpec.ServerConfig.DisableCloudController + dst.Spec.MachineTemplate.NodeVolumeDetachTimeout = restored.Spec.MachineTemplate.NodeVolumeDetachTimeout + dst.Spec.MachineTemplate.NodeDeletionTimeout = restored.Spec.MachineTemplate.NodeDeletionTimeout return nil } diff --git a/controlplane/api/v1beta1/zz_generated.conversion.go b/controlplane/api/v1beta1/zz_generated.conversion.go index 69c2361d..561e3ce9 100644 --- a/controlplane/api/v1beta1/zz_generated.conversion.go +++ b/controlplane/api/v1beta1/zz_generated.conversion.go @@ -211,6 +211,8 @@ func autoConvert_v1beta2_KThreesControlPlaneMachineTemplate_To_v1beta1_KThreesCo out.ObjectMeta = in.ObjectMeta // WARNING: in.InfrastructureRef requires manual conversion: does not exist in peer-type // WARNING: in.NodeDrainTimeout requires manual conversion: does not exist in peer-type + // WARNING: in.NodeVolumeDetachTimeout requires manual conversion: does not exist in peer-type + // WARNING: in.NodeDeletionTimeout requires manual conversion: does not exist in peer-type return nil } diff --git a/controlplane/api/v1beta2/kthreescontrolplane_types.go b/controlplane/api/v1beta2/kthreescontrolplane_types.go index cf953a95..c58fc840 100644 --- a/controlplane/api/v1beta2/kthreescontrolplane_types.go +++ b/controlplane/api/v1beta2/kthreescontrolplane_types.go @@ -101,6 +101,15 @@ type KThreesControlPlaneMachineTemplate struct { // NOTE: NodeDrainTimeout is different from `kubectl drain --timeout` // +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. + // +optional + NodeDeletionTimeout *metav1.Duration `json:"nodeDeletionTimeout,omitempty"` } // RemediationStrategy allows to define how control plane machine remediation happens. diff --git a/controlplane/api/v1beta2/zz_generated.deepcopy.go b/controlplane/api/v1beta2/zz_generated.deepcopy.go index 248a01f6..4eb0b337 100644 --- a/controlplane/api/v1beta2/zz_generated.deepcopy.go +++ b/controlplane/api/v1beta2/zz_generated.deepcopy.go @@ -95,6 +95,16 @@ func (in *KThreesControlPlaneMachineTemplate) DeepCopyInto(out *KThreesControlPl *out = new(v1.Duration) **out = **in } + if in.NodeVolumeDetachTimeout != nil { + in, out := &in.NodeVolumeDetachTimeout, &out.NodeVolumeDetachTimeout + *out = new(v1.Duration) + **out = **in + } + if in.NodeDeletionTimeout != nil { + in, out := &in.NodeDeletionTimeout, &out.NodeDeletionTimeout + *out = new(v1.Duration) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesControlPlaneMachineTemplate. diff --git a/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanes.yaml b/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanes.yaml index d14e4eb3..7bcc9ea7 100644 --- a/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanes.yaml +++ b/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanes.yaml @@ -892,12 +892,23 @@ spec: More info: http://kubernetes.io/docs/user-guide/labels type: object type: object + nodeDeletionTimeout: + description: |- + 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. + type: string nodeDrainTimeout: description: |- NodeDrainTimeout is the total amount of time that the controller will spend on draining a controlplane node The default value is 0, meaning that the node can be drained without any time limitations. NOTE: NodeDrainTimeout is different from `kubectl drain --timeout` type: string + nodeVolumeDetachTimeout: + description: |- + 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. + type: string required: - infrastructureRef type: object diff --git a/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanetemplates.yaml b/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanetemplates.yaml index 0facc523..06b0ee5e 100644 --- a/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanetemplates.yaml +++ b/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanetemplates.yaml @@ -332,12 +332,23 @@ spec: More info: http://kubernetes.io/docs/user-guide/labels type: object type: object + nodeDeletionTimeout: + description: |- + 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. + type: string nodeDrainTimeout: description: |- NodeDrainTimeout is the total amount of time that the controller will spend on draining a controlplane node The default value is 0, meaning that the node can be drained without any time limitations. NOTE: NodeDrainTimeout is different from `kubectl drain --timeout` type: string + nodeVolumeDetachTimeout: + description: |- + 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. + type: string required: - infrastructureRef type: object diff --git a/controlplane/controllers/scale.go b/controlplane/controllers/scale.go index df78779d..48d25384 100644 --- a/controlplane/controllers/scale.go +++ b/controlplane/controllers/scale.go @@ -372,8 +372,10 @@ func (r *KThreesControlPlaneReconciler) generateMachine(ctx context.Context, kcp Bootstrap: clusterv1.Bootstrap{ ConfigRef: bootstrapRef, }, - FailureDomain: failureDomain, - NodeDrainTimeout: kcp.Spec.MachineTemplate.NodeDrainTimeout, + FailureDomain: failureDomain, + NodeDrainTimeout: kcp.Spec.MachineTemplate.NodeDrainTimeout, + NodeVolumeDetachTimeout: kcp.Spec.MachineTemplate.NodeVolumeDetachTimeout, + NodeDeletionTimeout: kcp.Spec.MachineTemplate.NodeDeletionTimeout, }, }