diff --git a/CHANGELOG.md b/CHANGELOG.md index d29b0a305..81f061d27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## Master +- Add Maintenance mode annotation for ArangoDeployment + ## [0.4.2](https://github.com/arangodb/kube-arangodb/tree/0.4.2) (2019-11-12) - AntiAffinity for operator pods. - Add CRD API v1 with support for v1alpha. diff --git a/docs/design/README.md b/docs/design/README.md index baa2c92e3..61fb869bb 100644 --- a/docs/design/README.md +++ b/docs/design/README.md @@ -8,3 +8,4 @@ - [Scaling](./scaling.md) - [Status](./status.md) - [Upgrading](./upgrading.md) +- [Maintenance](./maintenance.md) \ No newline at end of file diff --git a/docs/design/maintenance.md b/docs/design/maintenance.md new file mode 100644 index 000000000..afbf9f6af --- /dev/null +++ b/docs/design/maintenance.md @@ -0,0 +1,14 @@ +# Maintenance + +## ArangoDeployment + +Maintenance on ArangoDeployment can be enabled using annotation. + +Key: `deployment.arangodb.com/maintenance` +Value: `true` + +To enable maintenance mode for ArangoDeployment kubectl command can be used: +`kubectl annotate arangodeployment deployment deployment.arangodb.com/maintenance=true` + +To disable maintenance mode for ArangoDeployment kubectl command can be used: +`kubectl annotate --overwrite arangodeployment deployment deployment.arangodb.com/maintenance-` \ No newline at end of file diff --git a/go.mod b/go.mod index 3df06c872..6672b09ee 100644 --- a/go.mod +++ b/go.mod @@ -55,7 +55,7 @@ require ( github.com/helm/helm v2.14.3+incompatible // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jessevdk/go-assets v0.0.0-20160921144138-4f4301a06e15 - github.com/jessevdk/go-assets-builder v0.0.0-20130903091706-b8483521738f // indirect + github.com/jessevdk/go-assets-builder v0.0.0-20130903091706-b8483521738f github.com/jessevdk/go-flags v1.4.0 // indirect github.com/jonboulle/clockwork v0.1.0 // indirect github.com/juju/errgo v0.0.0-20140925100237-08cceb5d0b53 // indirect diff --git a/pkg/deployment/deployment_inspector.go b/pkg/deployment/deployment_inspector.go index fc6ae9052..8d912ae23 100644 --- a/pkg/deployment/deployment_inspector.go +++ b/pkg/deployment/deployment_inspector.go @@ -37,6 +37,10 @@ var ( inspectDeploymentDurationGauges = metrics.MustRegisterGaugeVec(metricsComponent, "inspect_deployment_duration", "Amount of time taken by a single inspection of a deployment (in sec)", metrics.DeploymentName) ) +const ( + arangoDeploymentMaintenanceAnnotation = "deployment.arangodb.com/maintenance" +) + // inspectDeployment inspects the entire deployment, creates // a plan to update if needed and inspects underlying resources. // This function should be called when: @@ -68,6 +72,14 @@ func (d *Deployment) inspectDeployment(lastInterval util.Interval) util.Interval d.CreateEvent(k8sutil.NewErrorEvent("ArangoDeployment finalizer inspection failed", err, d.apiObject)) } } else { + // Check if maintenance annotation is set + if updated != nil && updated.Annotations != nil { + if v, ok := updated.Annotations[arangoDeploymentMaintenanceAnnotation]; ok && v == "true" { + // Disable checks if we will enter maintenance mode + log.Info().Str("deployment", deploymentName).Msg("Deployment in maintenance mode") + return nextInterval + } + } // Is the deployment in failed state, if so, give up. if d.GetPhase() == api.DeploymentPhaseFailed { log.Debug().Msg("Deployment is in Failed state.") diff --git a/tools/tools.go b/tools/tools.go new file mode 100644 index 000000000..ab6798200 --- /dev/null +++ b/tools/tools.go @@ -0,0 +1,23 @@ +// +// DISCLAIMER +// +// Copyright 2020 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package tools + +import _ "github.com/jessevdk/go-assets-builder"