Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Migrate CRD to apiextensions.k8s.io/v1
- Add customizable log levels per service
- Move Upgrade as InitContainer and fix Direct Image discovery mode
- Allow to remove currently executed plan by annotation

## [1.1.2](https://github.com/arangodb/kube-arangodb/tree/1.1.2) (2020-11-11)
- Fix Bootstrap phase and move it under Plan
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/deployment/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ const (
ArangoDeploymentPodMaintenanceAnnotation = ArangoDeploymentAnnotationPrefix + "/maintenance"
ArangoDeploymentPodRotateAnnotation = ArangoDeploymentAnnotationPrefix + "/rotate"
ArangoDeploymentPodReplaceAnnotation = ArangoDeploymentAnnotationPrefix + "/replace"
ArangoDeploymentPlanCleanAnnotation = "plan." + ArangoDeploymentAnnotationPrefix + "/clean"
)
23 changes: 23 additions & 0 deletions pkg/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import (
"sync/atomic"
"time"

"github.com/arangodb/kube-arangodb/pkg/deployment/patch"
"k8s.io/apimachinery/pkg/types"

"github.com/arangodb/kube-arangodb/pkg/operator/scope"

monitoringClient "github.com/coreos/prometheus-operator/pkg/client/versioned/typed/monitoring/v1"
Expand Down Expand Up @@ -511,3 +514,23 @@ func (d *Deployment) SetNumberOfServers(ctx context.Context, noCoordinators, noD
func (d *Deployment) getArangoDeployment() *api.ArangoDeployment {
return d.apiObject
}

func (d *Deployment) ApplyPatch(p ...patch.Item) error {
parser := patch.Patch(p)

data, err := parser.Marshal()
if err != nil {
return err
}

c := d.deps.DatabaseCRCli.DatabaseV1().ArangoDeployments(d.apiObject.GetNamespace())

depl, err := c.Patch(d.apiObject.GetName(), types.JSONPatchType, data)
if err != nil {
return err
}

d.apiObject = depl

return nil
}
17 changes: 16 additions & 1 deletion pkg/deployment/deployment_inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
"context"
"time"

"github.com/arangodb/kube-arangodb/pkg/deployment/patch"

operatorErrors "github.com/arangodb/kube-arangodb/pkg/util/errors"

"github.com/arangodb/kube-arangodb/pkg/deployment/resources/inspector"
Expand Down Expand Up @@ -99,6 +101,8 @@ func (d *Deployment) inspectDeployment(lastInterval util.Interval) util.Interval
return nextInterval
}

d.apiObject = updated

if inspectNextInterval, err := d.inspectDeploymentWithError(ctx, nextInterval, cachedStatus); err != nil {
if !operatorErrors.IsReconcile(err) {
nextInterval = inspectNextInterval
Expand Down Expand Up @@ -210,7 +214,18 @@ func (d *Deployment) inspectDeploymentWithError(ctx context.Context, lastInterva
}

// Create scale/update plan
if err, updated := d.reconciler.CreatePlan(ctx, cachedStatus); err != nil {
if _, ok := d.apiObject.Annotations[deployment.ArangoDeploymentPlanCleanAnnotation]; ok {
if err := d.ApplyPatch(patch.ItemRemove(patch.NewPath("metadata", "annotations", deployment.ArangoDeploymentPlanCleanAnnotation))); err != nil {
return minInspectionInterval, errors.Wrapf(err, "Unable to create remove annotation patch")
}

if err := d.WithStatusUpdate(func(s *api.DeploymentStatus) bool {
s.Plan = nil
return true
}, true); err != nil {
return minInspectionInterval, errors.Wrapf(err, "Unable clean plan")
}
} else if err, updated := d.reconciler.CreatePlan(ctx, cachedStatus); err != nil {
return minInspectionInterval, errors.Wrapf(err, "Plan creation failed")
} else if updated {
return minInspectionInterval, nil
Expand Down