Skip to content

Commit 6d3050c

Browse files
authored
[Bugfix] Fix restart procedure in case of failing members (#884)
1 parent 3cf0fa8 commit 6d3050c

File tree

14 files changed

+262
-121
lines changed

14 files changed

+262
-121
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- Add metrics for the plan actions
1616
- Add ArangoClusterSynchronization Operator
1717
- Update licenses
18+
- Fix restart procedure in case of failing members
1819

1920
## [1.2.6](https://github.com/arangodb/kube-arangodb/tree/1.2.6) (2021-12-15)
2021
- Add ArangoBackup backoff functionality

pkg/apis/deployment/v1/server_group_spec.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ package v1
2323
import (
2424
"math"
2525
"strings"
26+
"time"
2627

2728
"github.com/arangodb/kube-arangodb/pkg/util/errors"
2829

@@ -148,6 +149,8 @@ type ServerGroupSpec struct {
148149
InternalPort *int `json:"internalPort,omitempty"`
149150
// AllowMemberRecreation allows to recreate member. Value is used only for Coordinator and DBServer with default to True, for all other groups set to false.
150151
AllowMemberRecreation *bool `json:"allowMemberRecreation,omitempty"`
152+
// TerminationGracePeriodSeconds override default TerminationGracePeriodSeconds for pods - via silent rotation
153+
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
151154
}
152155

153156
// ServerGroupSpecSecurityContext contains specification for pod security context
@@ -700,3 +703,12 @@ func (s ServerGroupSpec) GetShutdownDelay(group ServerGroup) int {
700703
}
701704
return *s.ShutdownDelay
702705
}
706+
707+
// GetTerminationGracePeriod returns termination grace period as Duration
708+
func (s ServerGroupSpec) GetTerminationGracePeriod(group ServerGroup) time.Duration {
709+
if v := s.TerminationGracePeriodSeconds; v == nil {
710+
return group.DefaultTerminationGracePeriod()
711+
} else {
712+
return time.Second * time.Duration(*v)
713+
}
714+
}

pkg/apis/deployment/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/deployment/v2alpha1/server_group_spec.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ package v2alpha1
2323
import (
2424
"math"
2525
"strings"
26+
"time"
2627

2728
"github.com/arangodb/kube-arangodb/pkg/util/errors"
2829

@@ -148,6 +149,8 @@ type ServerGroupSpec struct {
148149
InternalPort *int `json:"internalPort,omitempty"`
149150
// AllowMemberRecreation allows to recreate member. Value is used only for Coordinator and DBServer with default to True, for all other groups set to false.
150151
AllowMemberRecreation *bool `json:"allowMemberRecreation,omitempty"`
152+
// TerminationGracePeriodSeconds override default TerminationGracePeriodSeconds for pods - via silent rotation
153+
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
151154
}
152155

153156
// ServerGroupSpecSecurityContext contains specification for pod security context
@@ -700,3 +703,12 @@ func (s ServerGroupSpec) GetShutdownDelay(group ServerGroup) int {
700703
}
701704
return *s.ShutdownDelay
702705
}
706+
707+
// GetTerminationGracePeriod returns termination grace period as Duration
708+
func (s ServerGroupSpec) GetTerminationGracePeriod(group ServerGroup) time.Duration {
709+
if v := s.TerminationGracePeriodSeconds; v == nil {
710+
return group.DefaultTerminationGracePeriod()
711+
} else {
712+
return time.Second * time.Duration(*v)
713+
}
714+
}

pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/deployment/reconcile/plan_builder_bootstrap.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ package reconcile
2323
import (
2424
"context"
2525

26-
core "k8s.io/api/core/v1"
27-
2826
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
2927
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
3028
inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
@@ -35,12 +33,11 @@ func createBootstrapPlan(ctx context.Context,
3533
log zerolog.Logger, apiObject k8sutil.APIObject,
3634
spec api.DeploymentSpec, status api.DeploymentStatus,
3735
cachedStatus inspectorInterface.Inspector, context PlanBuilderContext) api.Plan {
38-
3936
if !status.Conditions.IsTrue(api.ConditionTypeReady) {
4037
return nil
4138
}
4239

43-
if condition, hasBootstrap := status.Conditions.Get(api.ConditionTypeBootstrapCompleted); !hasBootstrap || condition.Status == core.ConditionTrue {
40+
if status.Conditions.IsTrue(api.ConditionTypeBootstrapCompleted) {
4441
return nil
4542
}
4643

pkg/deployment/reconcile/plan_builder_normal.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func createNormalPlan(ctx context.Context, log zerolog.Logger, apiObject k8sutil
6262
// Check for members to be removed
6363
ApplyIfEmpty(createReplaceMemberPlan).
6464
// Check for the need to rotate one or more members
65+
ApplyIfEmpty(createMarkToRemovePlan).
6566
ApplyIfEmpty(createRotateOrUpgradePlan).
6667
// Disable maintenance if upgrade process was done. Upgrade task throw IDLE Action if upgrade is pending
6768
ApplyIfEmpty(createMaintenanceManagementPlan).

0 commit comments

Comments
 (0)