Skip to content

Commit

Permalink
GT-495 Make scale_down_candidate annotation obsolete (#1429)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwierzbo authored Oct 13, 2023
1 parent 411efad commit 999afcb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- (Maintenance) Add IndexMethod Documentation
- (Bugfix) Fix VersionCheck args propagation
- (Feature) EnforcedResignLeadership action
- (Maintenance) Make scale_down_candidate annotation obsolete

## [1.2.33](https://github.com/arangodb/kube-arangodb/tree/1.2.33) (2023-09-27)
- (Maintenance) Bump golang.org/x/net to v0.13.0
Expand Down
18 changes: 10 additions & 8 deletions pkg/apis/deployment/annotations.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -21,12 +21,14 @@
package deployment

const (
ArangoDeploymentAnnotationPrefix = "deployment.arangodb.com"
ArangoDeploymentPodMaintenanceAnnotation = ArangoDeploymentAnnotationPrefix + "/maintenance"
ArangoDeploymentPodChangeArchAnnotation = ArangoDeploymentAnnotationPrefix + "/arch"
ArangoDeploymentPodRotateAnnotation = ArangoDeploymentAnnotationPrefix + "/rotate"
ArangoDeploymentPodReplaceAnnotation = ArangoDeploymentAnnotationPrefix + "/replace"
ArangoDeploymentPodDeleteNow = ArangoDeploymentAnnotationPrefix + "/delete_now"
ArangoDeploymentAnnotationPrefix = "deployment.arangodb.com"
ArangoDeploymentPodMaintenanceAnnotation = ArangoDeploymentAnnotationPrefix + "/maintenance"
ArangoDeploymentPodChangeArchAnnotation = ArangoDeploymentAnnotationPrefix + "/arch"
ArangoDeploymentPodRotateAnnotation = ArangoDeploymentAnnotationPrefix + "/rotate"
ArangoDeploymentPodReplaceAnnotation = ArangoDeploymentAnnotationPrefix + "/replace"
ArangoDeploymentPodDeleteNow = ArangoDeploymentAnnotationPrefix + "/delete_now"
ArangoDeploymentPlanCleanAnnotation = "plan." + ArangoDeploymentAnnotationPrefix + "/clean"

// Deprecated: use ArangoMemberSpec.DeletionPriority instead
ArangoDeploymentPodScaleDownCandidateAnnotation = ArangoDeploymentAnnotationPrefix + "/scale_down_candidate"
ArangoDeploymentPlanCleanAnnotation = "plan." + ArangoDeploymentAnnotationPrefix + "/clean"
)
3 changes: 3 additions & 0 deletions pkg/apis/deployment/v1/arango_member_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type ArangoMemberSpec struct {
// Template keeps template which is gonna be applied on the Pod.
Template *ArangoMemberPodTemplate `json:"template,omitempty"`

// DeletionPriority define Deletion Priority.
// Higher value means higher priority. Default is 0.
// Example: set 1 for Coordinator which should be deleted first and scale down coordinators by one.
DeletionPriority *int `json:"deletion_priority,omitempty"`
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/deployment/v2alpha1/arango_member_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type ArangoMemberSpec struct {
// Template keeps template which is gonna be applied on the Pod.
Template *ArangoMemberPodTemplate `json:"template,omitempty"`

// DeletionPriority define Deletion Priority.
// Higher value means higher priority. Default is 0.
// Example: set 1 for Coordinator which should be deleted first and scale down coordinators by one.
DeletionPriority *int `json:"deletion_priority,omitempty"`
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/deployment/reconcile/plan_builder_scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,13 @@ func (r *Reconciler) scaleDownCandidate(ctx context.Context, apiObject k8sutil.A
continue
}

//nolint:staticcheck
if _, ok := am.Annotations[deployment.ArangoDeploymentPodScaleDownCandidateAnnotation]; ok {
annotationExists = true
}

if pod, ok := cache.Pod().V1().GetSimple(m.Member.Pod.GetName()); ok {
//nolint:staticcheck
if _, ok := pod.Annotations[deployment.ArangoDeploymentPodScaleDownCandidateAnnotation]; ok {
annotationExists = true
}
Expand Down

0 comments on commit 999afcb

Please sign in to comment.