From f12e86f4eed77f2729598b2bf07efbbef8662b5c Mon Sep 17 00:00:00 2001 From: ZhiweiYin Date: Mon, 25 Sep 2023 17:28:00 +0800 Subject: [PATCH] add clusterDeleting condition and deletion-priority label Signed-off-by: ZhiweiYin --- cluster/v1/types.go | 13 +++++++++++++ utils/constants.go | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 utils/constants.go diff --git a/cluster/v1/types.go b/cluster/v1/types.go index 499ca72d1..bb9892c98 100644 --- a/cluster/v1/types.go +++ b/cluster/v1/types.go @@ -257,3 +257,16 @@ const ( // relating to the ManagedCluster is removed when the ManagedCluster is deleted. ManagedClusterFinalizer = "cluster.open-cluster-management.io/api-resource-cleanup" ) + +const ( + // ManagedClusterConditionDeleting is a condition which means the cluster is in deletion process. + ManagedClusterConditionDeleting string = "ManagedClusterIsDeleting" + + // ConditionDeletingReasonResourceRemaining is a reason for the condition ManagedClusterIsDeleting, which means + // there are resources are remaining during deletion process. + ConditionDeletingReasonResourceRemaining string = "ResourceRemaining" + + // ConditionDeletingReasonResourceError is a reason for the condition ManagedClusterIsDeleting, which means + // meet errors during the deletion process. + ConditionDeletingReasonResourceError string = "DeletingError" +) diff --git a/utils/constants.go b/utils/constants.go new file mode 100644 index 000000000..6170c5634 --- /dev/null +++ b/utils/constants.go @@ -0,0 +1,13 @@ +package utils + +const ( + // LabelDeletionPriority is a label for the resources deployed in cluster ns which are waiting to be cleaned up + // after cluster is deleted. + // The value is an integer value, The larger the value, the later the order of deletion. + // The deletion order is : + // 1. delete resources without this label firstly. + // 2. delete resources with invalid value of this label. + // 3. delete resources following the priority value. For example, there are 2 manifestWorks, one value is set 100 + // and another is set 10, the manifestWorks with 10 will be deleted before the one with 100. + LabelDeletionPriority string = "open-cluster-management.io/deletion-priority" +)