Skip to content

Commit 411efad

Browse files
authored
[Feature] EnforcedResignLeadership action (#1439)
1 parent 5693d82 commit 411efad

15 files changed

+368
-58
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- (Bugfix) Fix ArangoBackup Create Backoff & ArangoBackupPolicy propagation
1111
- (Maintenance) Add IndexMethod Documentation
1212
- (Bugfix) Fix VersionCheck args propagation
13+
- (Feature) EnforcedResignLeadership action
1314

1415
## [1.2.33](https://github.com/arangodb/kube-arangodb/tree/1.2.33) (2023-09-27)
1516
- (Maintenance) Bump golang.org/x/net to v0.13.0

README.md

Lines changed: 27 additions & 26 deletions
Large diffs are not rendered by default.

docs/generated/actions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
| EncryptionKeyRefresh | no | 10m0s | no | Enterprise Only | Refresh the encryption keys on member |
3030
| EncryptionKeyRemove | no | 10m0s | no | Enterprise Only | Remove the encryption key to the pool |
3131
| EncryptionKeyStatusUpdate | no | 10m0s | no | Enterprise Only | Update status of encryption propagation |
32+
| EnforceResignLeadership | no | 45m0s | yes | Community & Enterprise | Run the ResignLeadership job on DBServer and checks data compatibility after |
3233
| Idle | no | 10m0s | no | Community & Enterprise | Define idle operation in case if preconditions are not meet |
3334
| JWTAdd | no | 10m0s | no | Enterprise Only | Adds new JWT to the pool |
3435
| JWTClean | no | 10m0s | no | Enterprise Only | Remove JWT key from the pool |
@@ -122,6 +123,7 @@ spec:
122123
EncryptionKeyRefresh: 10m0s
123124
EncryptionKeyRemove: 10m0s
124125
EncryptionKeyStatusUpdate: 10m0s
126+
EnforceResignLeadership: 45m0s
125127
Idle: 10m0s
126128
JWTAdd: 10m0s
127129
JWTClean: 10m0s

internal/actions.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ actions:
2929
description: Run the ResignLeadership job on DBServer
3030
timeout: 30m
3131
optional: true
32+
EnforceResignLeadership:
33+
description: Run the ResignLeadership job on DBServer and checks data compatibility after
34+
timeout: 45m
35+
optional: true
3236
KillMemberPod:
3337
description: Execute Delete on Pod (put pod in Terminating state)
3438
scopes:

internal/features.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,10 @@ features:
220220
releases:
221221
- operatorVersion: 1.2.33
222222
state: Production
223+
- name: Enforced ResignLeadership
224+
enabled: true
225+
remarks: Enforce ResignLeadership and ensure that Leaders are moved from restarted DBServer
226+
flag: --deployment.feature.enforced-resign-leadership
227+
releases:
228+
- operatorVersion: 1.2.34
229+
state: Production

pkg/apis/deployment/v1/actions.generated.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ const (
9898
// ActionEncryptionKeyStatusUpdateDefaultTimeout define default timeout for action ActionEncryptionKeyStatusUpdate
9999
ActionEncryptionKeyStatusUpdateDefaultTimeout time.Duration = ActionsDefaultTimeout
100100

101+
// ActionEnforceResignLeadershipDefaultTimeout define default timeout for action ActionEnforceResignLeadership
102+
ActionEnforceResignLeadershipDefaultTimeout time.Duration = 2700 * time.Second // 45m0s
103+
101104
// ActionIdleDefaultTimeout define default timeout for action ActionIdle
102105
ActionIdleDefaultTimeout time.Duration = ActionsDefaultTimeout
103106

@@ -353,6 +356,9 @@ const (
353356
// ActionTypeEncryptionKeyStatusUpdate in scopes Normal. Update status of encryption propagation
354357
ActionTypeEncryptionKeyStatusUpdate ActionType = "EncryptionKeyStatusUpdate"
355358

359+
// ActionTypeEnforceResignLeadership in scopes Normal. Run the ResignLeadership job on DBServer and checks data compatibility after
360+
ActionTypeEnforceResignLeadership ActionType = "EnforceResignLeadership"
361+
356362
// ActionTypeIdle in scopes Normal. Define idle operation in case if preconditions are not meet
357363
ActionTypeIdle ActionType = "Idle"
358364

@@ -587,6 +593,8 @@ func (a ActionType) DefaultTimeout() time.Duration {
587593
return ActionEncryptionKeyRemoveDefaultTimeout
588594
case ActionTypeEncryptionKeyStatusUpdate:
589595
return ActionEncryptionKeyStatusUpdateDefaultTimeout
596+
case ActionTypeEnforceResignLeadership:
597+
return ActionEnforceResignLeadershipDefaultTimeout
590598
case ActionTypeIdle:
591599
return ActionIdleDefaultTimeout
592600
case ActionTypeJWTAdd:
@@ -761,6 +769,8 @@ func (a ActionType) Priority() ActionPriority {
761769
return ActionPriorityNormal
762770
case ActionTypeEncryptionKeyStatusUpdate:
763771
return ActionPriorityNormal
772+
case ActionTypeEnforceResignLeadership:
773+
return ActionPriorityNormal
764774
case ActionTypeIdle:
765775
return ActionPriorityNormal
766776
case ActionTypeJWTAdd:
@@ -947,6 +957,8 @@ func (a ActionType) Optional() bool {
947957
return false
948958
case ActionTypeEncryptionKeyStatusUpdate:
949959
return false
960+
case ActionTypeEnforceResignLeadership:
961+
return true
950962
case ActionTypeIdle:
951963
return false
952964
case ActionTypeJWTAdd:

pkg/apis/deployment/v2alpha1/actions.generated.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ const (
9898
// ActionEncryptionKeyStatusUpdateDefaultTimeout define default timeout for action ActionEncryptionKeyStatusUpdate
9999
ActionEncryptionKeyStatusUpdateDefaultTimeout time.Duration = ActionsDefaultTimeout
100100

101+
// ActionEnforceResignLeadershipDefaultTimeout define default timeout for action ActionEnforceResignLeadership
102+
ActionEnforceResignLeadershipDefaultTimeout time.Duration = 2700 * time.Second // 45m0s
103+
101104
// ActionIdleDefaultTimeout define default timeout for action ActionIdle
102105
ActionIdleDefaultTimeout time.Duration = ActionsDefaultTimeout
103106

@@ -353,6 +356,9 @@ const (
353356
// ActionTypeEncryptionKeyStatusUpdate in scopes Normal. Update status of encryption propagation
354357
ActionTypeEncryptionKeyStatusUpdate ActionType = "EncryptionKeyStatusUpdate"
355358

359+
// ActionTypeEnforceResignLeadership in scopes Normal. Run the ResignLeadership job on DBServer and checks data compatibility after
360+
ActionTypeEnforceResignLeadership ActionType = "EnforceResignLeadership"
361+
356362
// ActionTypeIdle in scopes Normal. Define idle operation in case if preconditions are not meet
357363
ActionTypeIdle ActionType = "Idle"
358364

@@ -587,6 +593,8 @@ func (a ActionType) DefaultTimeout() time.Duration {
587593
return ActionEncryptionKeyRemoveDefaultTimeout
588594
case ActionTypeEncryptionKeyStatusUpdate:
589595
return ActionEncryptionKeyStatusUpdateDefaultTimeout
596+
case ActionTypeEnforceResignLeadership:
597+
return ActionEnforceResignLeadershipDefaultTimeout
590598
case ActionTypeIdle:
591599
return ActionIdleDefaultTimeout
592600
case ActionTypeJWTAdd:
@@ -761,6 +769,8 @@ func (a ActionType) Priority() ActionPriority {
761769
return ActionPriorityNormal
762770
case ActionTypeEncryptionKeyStatusUpdate:
763771
return ActionPriorityNormal
772+
case ActionTypeEnforceResignLeadership:
773+
return ActionPriorityNormal
764774
case ActionTypeIdle:
765775
return ActionPriorityNormal
766776
case ActionTypeJWTAdd:
@@ -947,6 +957,8 @@ func (a ActionType) Optional() bool {
947957
return false
948958
case ActionTypeEncryptionKeyStatusUpdate:
949959
return false
960+
case ActionTypeEnforceResignLeadership:
961+
return true
950962
case ActionTypeIdle:
951963
return false
952964
case ActionTypeJWTAdd:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package features
22+
23+
func init() {
24+
registerFeature(enforcedResignLeadership)
25+
}
26+
27+
var enforcedResignLeadership = &feature{
28+
name: "enforced-resign-leadership",
29+
description: "Enforce ResignLeadership and ensure that Leaders are moved from restarted DBServer",
30+
version: "3.7.0",
31+
enterpriseRequired: false,
32+
enabledByDefault: true,
33+
}
34+
35+
// EnforcedResignLeadership returns enforced ResignLeadership.
36+
func EnforcedResignLeadership() Feature {
37+
return enforcedResignLeadership
38+
}

pkg/deployment/reconcile/action.register.generated.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ var (
9393
_ Action = &actionEncryptionKeyStatusUpdate{}
9494
_ actionFactory = newEncryptionKeyStatusUpdateAction
9595

96+
_ Action = &actionEnforceResignLeadership{}
97+
_ actionFactory = newEnforceResignLeadershipAction
98+
9699
_ Action = &actionIdle{}
97100
_ actionFactory = newIdleAction
98101

@@ -599,6 +602,20 @@ func init() {
599602
registerAction(action, function)
600603
}
601604

605+
// EnforceResignLeadership
606+
{
607+
// Get Action type
608+
action := api.ActionTypeEnforceResignLeadership
609+
610+
// Get Action defition
611+
function := newEnforceResignLeadershipAction
612+
613+
// Wrap action main function
614+
615+
// Register action
616+
registerAction(action, function)
617+
}
618+
602619
// Idle
603620
{
604621
// Get Action type

pkg/deployment/reconcile/action.register.generated_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ func Test_Actions(t *testing.T) {
276276
})
277277
})
278278

279+
t.Run("EnforceResignLeadership", func(t *testing.T) {
280+
ActionsExistence(t, api.ActionTypeEnforceResignLeadership)
281+
t.Run("Internal", func(t *testing.T) {
282+
require.False(t, api.ActionTypeEnforceResignLeadership.Internal())
283+
})
284+
t.Run("Optional", func(t *testing.T) {
285+
require.True(t, api.ActionTypeEnforceResignLeadership.Optional())
286+
})
287+
})
288+
279289
t.Run("Idle", func(t *testing.T) {
280290
ActionsExistence(t, api.ActionTypeIdle)
281291
t.Run("Internal", func(t *testing.T) {

0 commit comments

Comments
 (0)