From 3752f725ead3ab15e32d3a992503c0f90ceac2ba Mon Sep 17 00:00:00 2001 From: Robert-Stam <47088745+Robert-Stam@users.noreply.github.com> Date: Mon, 16 Sep 2024 15:32:13 +0200 Subject: [PATCH] Added RecreateNodeAnnotationKey const (#16) * Added RecreateNodeAnnotationKey const And improved documentation for RestartedAtAnnotationKey * Improved documentation * Added one more case * improved comments. * removed space * not --> none * switched order * more line shuffling * added requirement of CM * Addressed comments (annot will be placed on pod) * Value from annot is free to use. Added Status.ScaleDownNodeIndex field And improved some comments * added non-empty --- api/v1/qdrantcluster_types.go | 19 +++++++++++++++++-- api/v1/zz_generated.deepcopy.go | 5 +++++ .../crds/qdrant.io_qdrantclusters.yaml | 13 ++++++++++--- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/api/v1/qdrantcluster_types.go b/api/v1/qdrantcluster_types.go index d1789c6..03872a3 100644 --- a/api/v1/qdrantcluster_types.go +++ b/api/v1/qdrantcluster_types.go @@ -15,8 +15,18 @@ const ( ) const ( - // The Annotation key to trigger a restart. + // RestartedAtAnnotationKey is the annotation key to trigger a restart. + // The annotation should be placed on the QdrantCluster instance. + // The value should be a [RFC3339 formatted] date. + // If the value is updated it will retrigger the restart. + // For historical reasons the key doesn't start with `operator.qdrant.com/` RestartedAtAnnotationKey = "restartedAt" + // RecreateNodeAnnotationKey is the annotation key to recreate a certain node. + // The annotation should be placed on the pod created by the operator (for the node that need to be recreated). + // It is allowed to add this annotation to multiple pods, the operator will handle them all. + // The value should be non-empty, but is free to use, and will be used in Events. + // This feature requires that the cluster-manager is enabled. + RecreateNodeAnnotationKey = "operator.qdrant.com/recreate-node" ) // GetQdrantClusterCrdForHash creates a QdrantCluster for the use of creating a hash for the provided QdrantCluster, @@ -693,17 +703,22 @@ type QdrantClusterStatus struct { // +optional AvailableNodeIndexes []int `json:"availableNodeIndexes,omitempty"` // BootstrapNode specifies the node in the cluster which will be used for bootstrapping a new node. - // Should be 0...n-1 (default = 0) + // Should be a value from AvailableNodeIndexes. + // As default the value from AvailableNodeIndexes[0] will be used. // +optional BootstrapNode int `json:"bootstrapNode,omitempty"` // If set the operator will scale down 1 peer and reset the bool. // If you want to remove more then 1 peer, you need to repeat setting this bool // +optional ScaleDownAllowed bool `json:"scaleDownAllowed,omitempty"` + // The node index used in a scale down (see ScaleDownAllowed) + // If this field is not set the last index in AvailableNodeIndexes will be used. + ScaleDownNodeIndex *int `json:"ScaleDownNodeIndex,omitempty"` // Conditions specifies the conditions of different checks on the cluster // +optional Conditions []metav1.Condition `json:"conditions,omitempty"` // Operations tracks list of recent operation on the cluster. Operator uses this field to track the progress of an operation. + // In operator V2 this field is deprecated and Kubernetes events are used instead. // +optional Operations []Operation `json:"operations,omitempty"` // Nodes specifies the status of the nodes in the cluster diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 4d58b40..f05c36b 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -887,6 +887,11 @@ func (in *QdrantClusterStatus) DeepCopyInto(out *QdrantClusterStatus) { *out = make([]int, len(*in)) copy(*out, *in) } + if in.ScaleDownNodeIndex != nil { + in, out := &in.ScaleDownNodeIndex, &out.ScaleDownNodeIndex + *out = new(int) + **out = **in + } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions *out = make([]metav1.Condition, len(*in)) diff --git a/charts/qdrant-operator-crds/crds/qdrant.io_qdrantclusters.yaml b/charts/qdrant-operator-crds/crds/qdrant.io_qdrantclusters.yaml index bdc8207..9f9ce53 100644 --- a/charts/qdrant-operator-crds/crds/qdrant.io_qdrantclusters.yaml +++ b/charts/qdrant-operator-crds/crds/qdrant.io_qdrantclusters.yaml @@ -914,6 +914,11 @@ spec: status: description: QdrantClusterStatus defines the observed state of QdrantCluster properties: + ScaleDownNodeIndex: + description: |- + The node index used in a scale down (see ScaleDownAllowed) + If this field is not set the last index in AvailableNodeIndexes will be used. + type: integer availableNodeIndexes: description: |- AvailableNodeIndexes specifies the indexes of the individual nodes in the cluster @@ -928,7 +933,8 @@ spec: bootstrapNode: description: |- BootstrapNode specifies the node in the cluster which will be used for bootstrapping a new node. - Should be 0...n-1 (default = 0) + Should be a value from AvailableNodeIndexes. + As default the value from AvailableNodeIndexes[0] will be used. type: integer conditions: description: Conditions specifies the conditions of different checks @@ -1015,8 +1021,9 @@ spec: description: Nodes specifies the status of the nodes in the cluster type: object operations: - description: Operations tracks list of recent operation on the cluster. - Operator uses this field to track the progress of an operation. + description: |- + Operations tracks list of recent operation on the cluster. Operator uses this field to track the progress of an operation. + In operator V2 this field is deprecated and Kubernetes events are used instead. items: properties: completionTime: