Skip to content

Commit 0df664e

Browse files
authored
[Bugfix] Fix bootstrap phase (#663)
1 parent 8c2d4be commit 0df664e

17 files changed

+388
-190
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Change Log
22

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

56
## [1.1.1](https://github.com/arangodb/kube-arangodb/tree/1.1.1) (2020-11-04)
67
- Allow to mount EmptyDir

Diff for: pkg/apis/deployment/v1/bootstrap.go

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ const (
3434
// PasswordSecretName contains user password secret name
3535
type PasswordSecretName string
3636

37+
func (p PasswordSecretName) Get() string {
38+
return string(p)
39+
}
40+
3741
const (
3842
// PasswordSecretNameNone is magic value for no action
3943
PasswordSecretNameNone PasswordSecretName = "None"

Diff for: pkg/apis/deployment/v1/deployment_spec.go

+2
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ type DeploymentSpec struct {
110110
Recovery *ArangoDeploymentRecoverySpec `json:"recovery,omitempty"`
111111

112112
Bootstrap BootstrapSpec `json:"bootstrap,omitempty"`
113+
114+
Timeouts *Timeouts `json:"timeouts,omitempty"`
113115
}
114116

115117
// GetRestoreFrom returns the restore from string or empty string if not set

Diff for: pkg/apis/deployment/v1/plan.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ const (
127127
ActionTypeEnableMaintenance ActionType = "EnableMaintenance"
128128
// ActionTypeEnableMaintenance disables maintenance on cluster.
129129
ActionTypeDisableMaintenance ActionType = "DisableMaintenance"
130+
// ActionTypeBootstrapUpdate update bootstrap status to true
131+
ActionTypeBootstrapUpdate ActionType = "BootstrapUpdate"
132+
// ActionTypeBootstrapSetPassword set password to the bootstrapped user
133+
ActionTypeBootstrapSetPassword ActionType = "BootstrapSetPassword"
130134
)
131135

132136
const (
@@ -182,9 +186,9 @@ func (a Action) AddParam(key, value string) Action {
182186
}
183187

184188
// GetParam returns action parameter
185-
func (a Action) GetParam(key string) (interface{}, bool) {
189+
func (a Action) GetParam(key string) (string, bool) {
186190
if a.Params == nil {
187-
return nil, false
191+
return "", false
188192
}
189193

190194
i, ok := a.Params[key]

Diff for: pkg/apis/deployment/v1/timeouts.go

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
// Author Adam Janikowski
21+
//
22+
23+
package v1
24+
25+
import (
26+
"time"
27+
28+
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
29+
)
30+
31+
const (
32+
addMemberTimeout = time.Minute * 5
33+
)
34+
35+
type Timeouts struct {
36+
AddMember *Timeout `json:"addMember,omitempty"`
37+
}
38+
39+
func (t *Timeouts) Get() Timeouts {
40+
if t == nil {
41+
return Timeouts{}
42+
}
43+
44+
return *t
45+
}
46+
47+
type Timeout meta.Duration
48+
49+
func (t *Timeout) Get(d time.Duration) time.Duration {
50+
if t == nil {
51+
return d
52+
}
53+
54+
return t.Duration
55+
}

Diff for: pkg/deployment/bootstrap.go

-147
This file was deleted.

Diff for: pkg/deployment/deployment_inspector.go

-5
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,6 @@ func (d *Deployment) inspectDeploymentWithError(ctx context.Context, lastInterva
257257
return minInspectionInterval, errors.Wrapf(err, "AccessPackage creation failed")
258258
}
259259

260-
// Ensure deployment bootstrap
261-
if err := d.EnsureBootstrap(); err != nil {
262-
return minInspectionInterval, errors.Wrapf(err, "Bootstrap failed")
263-
}
264-
265260
// Inspect deployment for obsolete members
266261
if err := d.resources.CleanupRemovedMembers(); err != nil {
267262
return minInspectionInterval, errors.Wrapf(err, "Removed member cleanup failed")

Diff for: pkg/deployment/reconcile/action.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type Action interface {
4242
// Returns: ready, abort, error.
4343
CheckProgress(ctx context.Context) (bool, bool, error)
4444
// Timeout returns the amount of time after which this action will timeout.
45-
Timeout() time.Duration
45+
Timeout(deploymentSpec api.DeploymentSpec) time.Duration
4646
// Return the MemberID used / created in this action
4747
MemberID() string
4848
}

Diff for: pkg/deployment/reconcile/action_add_member.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package reconcile
2424

2525
import (
2626
"context"
27+
"time"
2728

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

42-
a.actionImpl = newActionImpl(log, action, actionCtx, addMemberTimeout, &a.newMemberID)
43+
a.actionImpl = newBaseActionImpl(log, action, actionCtx, func(deploymentSpec api.DeploymentSpec) time.Duration {
44+
return deploymentSpec.Timeouts.Get().AddMember.Get(addMemberTimeout)
45+
}, &a.newMemberID)
4346

4447
return a
4548
}

0 commit comments

Comments
 (0)