Skip to content

Commit 6a3dde9

Browse files
authored
[Feature] Optional Graceful Restart (#1278)
1 parent 7e5ab5b commit 6a3dde9

File tree

6 files changed

+53
-5
lines changed

6 files changed

+53
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- (Improvement) Cleanout calculation - picks members with the lowest number of shards
2323
- (Improvement) Add new field to CR for more precise calculation of DC2DC replication progress
2424
- (Maintenance) Bump GO Modules
25+
- (Feature) Optional Graceful Restart
2526

2627
## [1.2.24](https://github.com/arangodb/kube-arangodb/tree/1.2.24) (2023-01-25)
2728
- (Bugfix) Fix deployment creation on ARM64

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ Feature-wise production readiness table:
6464
| Version Check | 1.1.4 | >= 3.6.0 | Community, Enterprise | 1.1.4 | Alpha | False | --deployment.feature.upgrade-version-check | N/A |
6565
| Version Check | 1.2.23 | >= 3.6.0 | Community, Enterprise | 1.1.4 | Production | True | --deployment.feature.upgrade-version-check | N/A |
6666
| Operator Maintenance Management Support | 1.2.0 | >= 3.6.0 | Community, Enterprise | 1.0.7 | Production | True | --deployment.feature.maintenance | N/A |
67+
| Graceful Restart | 1.2.5 | >= 3.6.0 | Community, Enterprise | 1.0.7 | Production | True | --deployment.feature.graceful-shutdown | N/A |
68+
| Optional Graceful Restart | 1.2.25 | >= 3.6.0 | Community, Enterprise | 1.2.5 | Beta | True | --deployment.feature.optional-graceful-shutdown | N/A |
6769
| Operator Internal Metrics Exporter | 1.2.0 | >= 3.6.0 | Community, Enterprise | 1.2.0 | Production | True | --deployment.feature.metrics-exporter | N/A |
6870
| Operator Ephemeral Volumes | 1.2.2 | >= 3.7.0 | Community, Enterprise | 1.2.2 | Alpha | False | --deployment.feature.ephemeral-volumes | N/A |
6971
| Spec Default Restore | 1.2.21 | >= 3.7.0 | Community, Enterprise | 1.2.21 | Beta | True | --deployment.feature.deployment-spec-defaults-restore | If set to False Operator will not change ArangoDeployment Spec |

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ replace (
2020
k8s.io/component-base => k8s.io/component-base v0.22.15
2121
k8s.io/kubernetes => k8s.io/kubernetes v0.22.15
2222
k8s.io/metrics => k8s.io/metrics v0.22.15
23+
24+
gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.1
2325
)
2426

2527
require (

go.sum

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -972,9 +972,8 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
972972
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
973973
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
974974
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
975-
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
976-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
977-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
975+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
976+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
978977
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
979978
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
980979
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

pkg/deployment/features/graceful.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package features
2222

2323
func init() {
2424
registerFeature(gracefulShutdown)
25+
registerFeature(optionalGracefulShutdown)
2526
}
2627

2728
var gracefulShutdown = &feature{
@@ -33,6 +34,19 @@ var gracefulShutdown = &feature{
3334
hidden: true,
3435
}
3536

37+
var optionalGracefulShutdown = &feature{
38+
name: "optional-graceful-shutdown",
39+
description: "Define graceful shutdown, using finalizers, is optional and can fail in case of connection issues",
40+
version: "3.6.0",
41+
enterpriseRequired: false,
42+
enabledByDefault: false,
43+
hidden: true,
44+
}
45+
3646
func GracefulShutdown() Feature {
3747
return gracefulShutdown
3848
}
49+
50+
func OptionalGracefulShutdown() Feature {
51+
return optionalGracefulShutdown
52+
}

pkg/deployment/reconcile/helper_shutdown.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func getShutdownHelper(a actionImpl) (ActionCore, api.MemberStatus, bool) {
7979
}
8080

8181
if features.GracefulShutdown().Enabled() {
82-
return shutdownHelperAPI{actionImpl: a, memberStatus: m}, m, true
82+
return getShutdownHelperAPI(a, m), m, true
8383
}
8484

8585
serverGroup := a.actionCtx.GetSpec().GetServerGroupSpec(a.action.Group)
@@ -88,10 +88,40 @@ func getShutdownHelper(a actionImpl) (ActionCore, api.MemberStatus, bool) {
8888
case api.ServerGroupShutdownMethodDelete:
8989
return shutdownHelperDelete{actionImpl: a, memberStatus: m}, m, true
9090
default:
91-
return shutdownHelperAPI{actionImpl: a, memberStatus: m}, m, true
91+
return getShutdownHelperAPI(a, m), m, true
9292
}
9393
}
9494

95+
func getShutdownHelperAPI(a actionImpl, member api.MemberStatus) ActionCore {
96+
act := shutdownHelperAPI{actionImpl: a, memberStatus: member}
97+
98+
if !features.OptionalGracefulShutdown().Enabled() {
99+
return act
100+
}
101+
102+
return shutdownHelperOptionalAPI{action: act}
103+
}
104+
105+
type shutdownHelperOptionalAPI struct {
106+
action shutdownHelperAPI
107+
}
108+
109+
func (s shutdownHelperOptionalAPI) Start(ctx context.Context) (bool, error) {
110+
return false, nil
111+
}
112+
113+
func (s shutdownHelperOptionalAPI) CheckProgress(ctx context.Context) (bool, bool, error) {
114+
if done, abort, err := s.action.CheckProgress(ctx); err != nil || abort || done {
115+
return done, abort, err
116+
}
117+
118+
if _, err := s.action.Start(ctx); err != nil {
119+
return false, false, nil
120+
}
121+
122+
return false, false, nil
123+
}
124+
95125
type shutdownHelperAPI struct {
96126
actionImpl
97127
memberStatus api.MemberStatus

0 commit comments

Comments
 (0)