Skip to content

Commit 57337fb

Browse files
authored
GT-509 Remove scale_down_candidate annotation (#1471)
1 parent 70d22ed commit 57337fb

File tree

10 files changed

+24
-77
lines changed

10 files changed

+24
-77
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- (Feature) Add ArangoMember Message and extend ArangoMember CRD
1616
- (Documentation) Use OpenAPI-compatible type names in docs
1717
- (Improvement) Use agency cache lock in metrics exporter
18+
- (Maintenance) Remove `scale_down_candidate` annotation
1819

1920
## [1.2.34](https://github.com/arangodb/kube-arangodb/tree/1.2.34) (2023-10-16)
2021
- (Bugfix) Fix make manifests-crd-file command

docs/scaling.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# Scaling your ArangoDB deployment
22

3-
The ArangoDB Kubernetes Operator supports up and down scaling of
4-
the number of DB-Servers & Coordinators.
3+
The ArangoDB Kubernetes Operator allows easily scale the number of DB-Servers and Coordinators up or down as needed.
54

6-
The scale up or down, change the number of servers in the custom
7-
resource.
5+
The scale up or down, change the number of servers in the custom resource.
86

9-
E.g. change `spec.dbservers.count` from `3` to `4`.
7+
E.g., change `spec.dbservers.count` from `3` to `4`.
108

119
Then apply the updated resource using:
1210

1311
```bash
14-
kubectl apply -f yourCustomResourceFile.yaml
12+
kubectl apply -f {your-arango-deployment}.yaml
1513
```
1614

1715
Inspect the status of the custom resource to monitor the progress of the scaling operation.
@@ -25,18 +23,24 @@ Make sure to specify the desired number when creating CR first time.
2523
### Scale-up
2624

2725
When increasing the `count`, operator will try to create missing pods.
28-
When scaling up, make sure that you have enough computational resources / nodes, otherwise pod will stuck in Pending state.
26+
When scaling up, make sure that you have enough computational resources / nodes, otherwise pod will be stuck in Pending state.
2927

3028

3129
### Scale-down
3230

33-
Scaling down is always done 1 server at a time.
31+
Scaling down is always done one server at a time.
3432

3533
Scale down is possible only when all other actions on ArangoDeployment are finished.
3634

37-
The internal process followed by the ArangoDB operator when scaling up is as follows:
38-
- It chooses a member to be evicted. First it will try to remove unhealthy members or fall-back to the member with highest deletion_priority.
35+
The internal process followed by the ArangoDB operator when scaling down is as follows:
36+
- It chooses a member to be evicted. First, it will try to remove unhealthy members or fall-back to the member with
37+
the highest `deletion_priority` (check [Use deletion_priority to control scale-down order](#use-deletion_priority-to-control-scale-down-order)).
3938
- Making an internal calls, it forces the server to resign leadership.
4039
In case of DB servers it means that all shard leaders will be switched to other servers.
41-
- Wait until server is cleaned out from cluster.
40+
- Wait until server is cleaned out from the cluster.
4241
- Pod finalized.
42+
43+
#### Use deletion_priority to control scale-down order
44+
45+
You can use `.spec.deletion_priority` field in `ArangoMember` CR to control the order in which servers are scaled down.
46+
Refer to [ArangoMember API Reference](/docs/api/ArangoMember.V1.md#specdeletionpriority-integer) for more details.

pkg/apis/deployment/annotations.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,4 @@ const (
2828
ArangoDeploymentPodReplaceAnnotation = ArangoDeploymentAnnotationPrefix + "/replace"
2929
ArangoDeploymentPodDeleteNow = ArangoDeploymentAnnotationPrefix + "/delete_now"
3030
ArangoDeploymentPlanCleanAnnotation = "plan." + ArangoDeploymentAnnotationPrefix + "/clean"
31-
32-
// Deprecated: use ArangoMemberSpec.DeletionPriority instead
33-
ArangoDeploymentPodScaleDownCandidateAnnotation = ArangoDeploymentAnnotationPrefix + "/scale_down_candidate"
3431
)

pkg/apis/deployment/v1/conditions.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ const (
7676
ConditionTypeMemberVolumeUnschedulable ConditionType = "MemberVolumeUnschedulable"
7777
// ConditionTypeMarkedToRemove indicates that the member is marked to be removed.
7878
ConditionTypeMarkedToRemove ConditionType = "MarkedToRemove"
79-
// ConditionTypeScaleDownCandidate indicates that the member will be picked in ScaleDown operaion.
79+
// ConditionTypeScaleDownCandidate indicates that the member will be picked in ScaleDown operation (Currently not used).
80+
// Deprecated: will be removed in 1.3.0
8081
ConditionTypeScaleDownCandidate ConditionType = "ScaleDownCandidate"
8182
// ConditionTypeUpgradeFailed indicates that upgrade failed
8283
ConditionTypeUpgradeFailed ConditionType = "UpgradeFailed"

pkg/apis/deployment/v1/member_status_list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ func (l *MemberStatusList) removeByID(id string) error {
139139
type MemberToRemoveSelector func(m MemberStatusList) (string, error)
140140

141141
// SelectMemberToRemove selects a member from the given list that should
142-
// be removed in a scale down action.
142+
// be removed in a ScaleDown action.
143143
// Returns an error if the list is empty.
144+
// Deprecated: will be removed in 1.3.0 since ScaleDown annotation is already removed
144145
func (l MemberStatusList) SelectMemberToRemove(selectors ...MemberToRemoveSelector) (MemberStatus, error) {
145146
if len(l) > 0 {
146147
// Try to find member with phase to be removed

pkg/apis/deployment/v2alpha1/conditions.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ const (
7676
ConditionTypeMemberVolumeUnschedulable ConditionType = "MemberVolumeUnschedulable"
7777
// ConditionTypeMarkedToRemove indicates that the member is marked to be removed.
7878
ConditionTypeMarkedToRemove ConditionType = "MarkedToRemove"
79-
// ConditionTypeScaleDownCandidate indicates that the member will be picked in ScaleDown operaion.
79+
// ConditionTypeScaleDownCandidate indicates that the member will be picked in ScaleDown operation (Currently not used).
80+
// Deprecated: will be removed in 1.3.0
8081
ConditionTypeScaleDownCandidate ConditionType = "ScaleDownCandidate"
8182
// ConditionTypeUpgradeFailed indicates that upgrade failed
8283
ConditionTypeUpgradeFailed ConditionType = "UpgradeFailed"

pkg/apis/deployment/v2alpha1/member_status_list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ func (l *MemberStatusList) removeByID(id string) error {
139139
type MemberToRemoveSelector func(m MemberStatusList) (string, error)
140140

141141
// SelectMemberToRemove selects a member from the given list that should
142-
// be removed in a scale down action.
142+
// be removed in a ScaleDown action.
143143
// Returns an error if the list is empty.
144+
// Deprecated: will be removed in 1.3.0 since ScaleDown annotation is already removed
144145
func (l MemberStatusList) SelectMemberToRemove(selectors ...MemberToRemoveSelector) (MemberStatus, error) {
145146
if len(l) > 0 {
146147
// Try to find member with phase to be removed

pkg/deployment/reconcile/plan_builder_high.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ func (r *Reconciler) createHighPlan(ctx context.Context, apiObject k8sutil.APIOb
6464
ApplyIfEmpty(r.updateMemberConditionTypeMemberVolumeUnschedulableCondition).
6565
ApplyIfEmpty(r.createRebalancerCheckPlanCore).
6666
ApplyIfEmpty(r.createMemberFailedRestoreHighPlan).
67-
ApplyIfEmpty(r.scaleDownCandidate).
6867
ApplyIfEmpty(r.volumeMemberReplacement).
6968
ApplyWithBackOff(BackOffCheck, time.Minute, r.emptyPlanBuilder)).
7069
ApplyIfEmptyWithBackOff(TimezoneCheck, time.Minute, r.createTimezoneUpdatePlan).

pkg/deployment/reconcile/plan_builder_scale.go

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ package reconcile
2323
import (
2424
"context"
2525

26-
"github.com/arangodb/kube-arangodb/pkg/apis/deployment"
2726
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
2827
"github.com/arangodb/kube-arangodb/pkg/deployment/actions"
2928
"github.com/arangodb/kube-arangodb/pkg/deployment/reconcile/shared"
@@ -166,47 +165,3 @@ func (r *Reconciler) createReplaceMemberPlan(ctx context.Context, apiObject k8su
166165
func filterScaleUP(a api.Action) bool {
167166
return a.Type == api.ActionTypeAddMember
168167
}
169-
170-
func (r *Reconciler) scaleDownCandidate(ctx context.Context, apiObject k8sutil.APIObject,
171-
spec api.DeploymentSpec, status api.DeploymentStatus,
172-
context PlanBuilderContext) api.Plan {
173-
var plan api.Plan
174-
175-
for _, m := range status.Members.AsList() {
176-
cache, ok := context.ACS().ClusterCache(m.Member.ClusterID)
177-
if !ok {
178-
continue
179-
}
180-
181-
annotationExists := false
182-
183-
am, ok := cache.ArangoMember().V1().GetSimple(m.Member.ArangoMemberName(context.GetName(), m.Group))
184-
if !ok {
185-
continue
186-
}
187-
188-
//nolint:staticcheck
189-
if _, ok := am.Annotations[deployment.ArangoDeploymentPodScaleDownCandidateAnnotation]; ok {
190-
annotationExists = true
191-
}
192-
193-
if pod, ok := cache.Pod().V1().GetSimple(m.Member.Pod.GetName()); ok {
194-
//nolint:staticcheck
195-
if _, ok := pod.Annotations[deployment.ArangoDeploymentPodScaleDownCandidateAnnotation]; ok {
196-
annotationExists = true
197-
}
198-
}
199-
200-
conditionExists := m.Member.Conditions.IsTrue(api.ConditionTypeScaleDownCandidate)
201-
202-
if annotationExists != conditionExists {
203-
if annotationExists {
204-
plan = append(plan, shared.UpdateMemberConditionActionV2("Marked as ScaleDownCandidate", api.ConditionTypeScaleDownCandidate, m.Group, m.Member.ID, true, "Marked as ScaleDownCandidate", "", ""))
205-
} else {
206-
plan = append(plan, shared.RemoveMemberConditionActionV2("Unmarked as ScaleDownCandidate", api.ConditionTypeScaleDownCandidate, m.Group, m.Member.ID))
207-
}
208-
}
209-
}
210-
211-
return plan
212-
}

pkg/deployment/reconcile/plan_builder_scale_funcs.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
func planBuilderScaleDownFilter(context PlanBuilderContext, status api.DeploymentStatus, group api.ServerGroup, in api.MemberStatusList) (api.MemberStatus, error) {
2929
return NewScaleFilter(context, status, group, in).
3030
Filter(planBuilderScaleDownSelectMarkedToRemove).
31-
Filter(planBuilderScaleDownSelectScaleDownCandidateCondition).
3231
Filter(planBuilderScaleDownSelectCleanedOutCondition).
3332
Filter(planBuilderScaleDownCleanedServers).
3433
Filter(planBuilderScaleDownToBeCleanedServers).
@@ -107,18 +106,6 @@ func planBuilderScaleDownSelectCleanedOutCondition(context PlanBuilderContext, s
107106
return r, len(r) > 0, nil
108107
}
109108

110-
func planBuilderScaleDownSelectScaleDownCandidateCondition(context PlanBuilderContext, status api.DeploymentStatus, group api.ServerGroup, in api.MemberStatusList) (api.MemberStatusList, bool, error) {
111-
r := make(api.MemberStatusList, 0, len(in))
112-
113-
for _, el := range in {
114-
if el.Conditions.IsTrue(api.ConditionTypeScaleDownCandidate) {
115-
r = append(r, el)
116-
}
117-
}
118-
119-
return r, len(r) > 0, nil
120-
}
121-
122109
func planBuilderScaleDownCleanedServers(context PlanBuilderContext, status api.DeploymentStatus, group api.ServerGroup, in api.MemberStatusList) (api.MemberStatusList, bool, error) {
123110
if group != api.ServerGroupDBServers {
124111
return nil, false, nil

0 commit comments

Comments
 (0)