Skip to content

Commit 9b73a77

Browse files
authored
[Feature] Maintenance Mode (#516)
1 parent 59277df commit 9b73a77

File tree

6 files changed

+54
-1
lines changed

6 files changed

+54
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Change Log
22

3+
## Master
4+
- Add Maintenance mode annotation for ArangoDeployment
5+
36
## [0.4.2](https://github.com/arangodb/kube-arangodb/tree/0.4.2) (2019-11-12)
47
- AntiAffinity for operator pods.
58
- Add CRD API v1 with support for v1alpha.

docs/design/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
- [Scaling](./scaling.md)
99
- [Status](./status.md)
1010
- [Upgrading](./upgrading.md)
11+
- [Maintenance](./maintenance.md)

docs/design/maintenance.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Maintenance
2+
3+
## ArangoDeployment
4+
5+
Maintenance on ArangoDeployment can be enabled using annotation.
6+
7+
Key: `deployment.arangodb.com/maintenance`
8+
Value: `true`
9+
10+
To enable maintenance mode for ArangoDeployment kubectl command can be used:
11+
`kubectl annotate arangodeployment deployment deployment.arangodb.com/maintenance=true`
12+
13+
To disable maintenance mode for ArangoDeployment kubectl command can be used:
14+
`kubectl annotate --overwrite arangodeployment deployment deployment.arangodb.com/maintenance-`

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ require (
5555
github.com/helm/helm v2.14.3+incompatible // indirect
5656
github.com/inconshreveable/mousetrap v1.0.0 // indirect
5757
github.com/jessevdk/go-assets v0.0.0-20160921144138-4f4301a06e15
58-
github.com/jessevdk/go-assets-builder v0.0.0-20130903091706-b8483521738f // indirect
58+
github.com/jessevdk/go-assets-builder v0.0.0-20130903091706-b8483521738f
5959
github.com/jessevdk/go-flags v1.4.0 // indirect
6060
github.com/jonboulle/clockwork v0.1.0 // indirect
6161
github.com/juju/errgo v0.0.0-20140925100237-08cceb5d0b53 // indirect

pkg/deployment/deployment_inspector.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ var (
3737
inspectDeploymentDurationGauges = metrics.MustRegisterGaugeVec(metricsComponent, "inspect_deployment_duration", "Amount of time taken by a single inspection of a deployment (in sec)", metrics.DeploymentName)
3838
)
3939

40+
const (
41+
arangoDeploymentMaintenanceAnnotation = "deployment.arangodb.com/maintenance"
42+
)
43+
4044
// inspectDeployment inspects the entire deployment, creates
4145
// a plan to update if needed and inspects underlying resources.
4246
// This function should be called when:
@@ -68,6 +72,14 @@ func (d *Deployment) inspectDeployment(lastInterval util.Interval) util.Interval
6872
d.CreateEvent(k8sutil.NewErrorEvent("ArangoDeployment finalizer inspection failed", err, d.apiObject))
6973
}
7074
} else {
75+
// Check if maintenance annotation is set
76+
if updated != nil && updated.Annotations != nil {
77+
if v, ok := updated.Annotations[arangoDeploymentMaintenanceAnnotation]; ok && v == "true" {
78+
// Disable checks if we will enter maintenance mode
79+
log.Info().Str("deployment", deploymentName).Msg("Deployment in maintenance mode")
80+
return nextInterval
81+
}
82+
}
7183
// Is the deployment in failed state, if so, give up.
7284
if d.GetPhase() == api.DeploymentPhaseFailed {
7385
log.Debug().Msg("Deployment is in Failed state.")

tools/tools.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2020 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 tools
22+
23+
import _ "github.com/jessevdk/go-assets-builder"

0 commit comments

Comments
 (0)