Skip to content

Commit

Permalink
[Bugfix] Fix bootstrap phase (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajanikow authored Nov 10, 2020
1 parent 8c2d4be commit 0df664e
Show file tree
Hide file tree
Showing 17 changed files with 388 additions and 190 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Change Log

## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
- Fix Bootstrap phase and move it under Plan

## [1.1.1](https://github.com/arangodb/kube-arangodb/tree/1.1.1) (2020-11-04)
- Allow to mount EmptyDir
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/deployment/v1/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const (
// PasswordSecretName contains user password secret name
type PasswordSecretName string

func (p PasswordSecretName) Get() string {
return string(p)
}

const (
// PasswordSecretNameNone is magic value for no action
PasswordSecretNameNone PasswordSecretName = "None"
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/deployment/v1/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ type DeploymentSpec struct {
Recovery *ArangoDeploymentRecoverySpec `json:"recovery,omitempty"`

Bootstrap BootstrapSpec `json:"bootstrap,omitempty"`

Timeouts *Timeouts `json:"timeouts,omitempty"`
}

// GetRestoreFrom returns the restore from string or empty string if not set
Expand Down
8 changes: 6 additions & 2 deletions pkg/apis/deployment/v1/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ const (
ActionTypeEnableMaintenance ActionType = "EnableMaintenance"
// ActionTypeEnableMaintenance disables maintenance on cluster.
ActionTypeDisableMaintenance ActionType = "DisableMaintenance"
// ActionTypeBootstrapUpdate update bootstrap status to true
ActionTypeBootstrapUpdate ActionType = "BootstrapUpdate"
// ActionTypeBootstrapSetPassword set password to the bootstrapped user
ActionTypeBootstrapSetPassword ActionType = "BootstrapSetPassword"
)

const (
Expand Down Expand Up @@ -182,9 +186,9 @@ func (a Action) AddParam(key, value string) Action {
}

// GetParam returns action parameter
func (a Action) GetParam(key string) (interface{}, bool) {
func (a Action) GetParam(key string) (string, bool) {
if a.Params == nil {
return nil, false
return "", false
}

i, ok := a.Params[key]
Expand Down
55 changes: 55 additions & 0 deletions pkg/apis/deployment/v1/timeouts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// 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
//
// Author Adam Janikowski
//

package v1

import (
"time"

meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
addMemberTimeout = time.Minute * 5
)

type Timeouts struct {
AddMember *Timeout `json:"addMember,omitempty"`
}

func (t *Timeouts) Get() Timeouts {
if t == nil {
return Timeouts{}
}

return *t
}

type Timeout meta.Duration

func (t *Timeout) Get(d time.Duration) time.Duration {
if t == nil {
return d
}

return t.Duration
}
147 changes: 0 additions & 147 deletions pkg/deployment/bootstrap.go

This file was deleted.

5 changes: 0 additions & 5 deletions pkg/deployment/deployment_inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,6 @@ func (d *Deployment) inspectDeploymentWithError(ctx context.Context, lastInterva
return minInspectionInterval, errors.Wrapf(err, "AccessPackage creation failed")
}

// Ensure deployment bootstrap
if err := d.EnsureBootstrap(); err != nil {
return minInspectionInterval, errors.Wrapf(err, "Bootstrap failed")
}

// Inspect deployment for obsolete members
if err := d.resources.CleanupRemovedMembers(); err != nil {
return minInspectionInterval, errors.Wrapf(err, "Removed member cleanup failed")
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/reconcile/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Action interface {
// Returns: ready, abort, error.
CheckProgress(ctx context.Context) (bool, bool, error)
// Timeout returns the amount of time after which this action will timeout.
Timeout() time.Duration
Timeout(deploymentSpec api.DeploymentSpec) time.Duration
// Return the MemberID used / created in this action
MemberID() string
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/deployment/reconcile/action_add_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package reconcile

import (
"context"
"time"

api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/rs/zerolog"
Expand All @@ -39,7 +40,9 @@ func init() {
func newAddMemberAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action {
a := &actionAddMember{}

a.actionImpl = newActionImpl(log, action, actionCtx, addMemberTimeout, &a.newMemberID)
a.actionImpl = newBaseActionImpl(log, action, actionCtx, func(deploymentSpec api.DeploymentSpec) time.Duration {
return deploymentSpec.Timeouts.Get().AddMember.Get(addMemberTimeout)
}, &a.newMemberID)

return a
}
Expand Down
Loading

0 comments on commit 0df664e

Please sign in to comment.