1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

[Bugfix] Fix action timeouts (#1112)

This commit is contained in:
Adam Janikowski 2022-09-19 17:24:54 +02:00 committed by GitHub
parent 92afe451eb
commit 4939634b7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
103 changed files with 3668 additions and 640 deletions

View file

@ -3,6 +3,7 @@
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
- (Feature) Add new field to DeploymentReplicationStatus with details on DC2DC sync status
- (Feature) Early connections support
- (Bugfix) Fix and document action timeouts
## [1.2.16](https://github.com/arangodb/kube-arangodb/tree/1.2.16) (2022-09-14)
- (Feature) Add ArangoDeployment ServerGroupStatus

View file

@ -7,4 +7,5 @@
# ArangoDB Kubernetes Operator Generated Documentation
- [ArangoDB Operator Metrics & Alerts](./generated/metrics/README.md)
- [ArangoDB Operator Metrics & Alerts](./generated/metrics/README.md)
- [ArangoDB Actions](./generated/actions.md)

160
docs/generated/actions.md Normal file
View file

@ -0,0 +1,160 @@
# ArangoDB Operator Metrics
## List
| Action | Timeout | Edition | Description |
|:----------------------------------:|:-------:|:----------------------:|:------------------------------------------------------------------------------------------------------------------:|
| AddMember | 10m0s | Community & Enterprise | Adds new member to the Member list |
| AppendTLSCACertificate | 30m0s | Enterprise Only | Append Certificate into CA TrustStore |
| ArangoMemberUpdatePodSpec | 10m0s | Community & Enterprise | Propagate Member Pod spec (requested) |
| ArangoMemberUpdatePodStatus | 10m0s | Community & Enterprise | Propagate Member Pod status (current) |
| BackupRestore | 15m0s | Enterprise Only | Restore selected Backup |
| BackupRestoreClean | 15m0s | Enterprise Only | Clean restore status in case of restore spec change |
| BootstrapSetPassword | 10m0s | Community & Enterprise | Change password during bootstrap procedure |
| BootstrapUpdate | 10m0s | Community & Enterprise | Update bootstrap status |
| CleanOutMember | 48h0m0s | Community & Enterprise | Run the CleanOut job on member |
| CleanTLSCACertificate | 30m0s | Enterprise Only | Remove Certificate from CA TrustStore |
| CleanTLSKeyfileCertificate | 30m0s | Enterprise Only | Remove old TLS certificate from server |
| ClusterMemberCleanup | 10m0s | Community & Enterprise | Remove member from Cluster if it is gone already (Coordinators) |
| DisableClusterScaling | 10m0s | Community & Enterprise | (Deprecated) Disable Cluster Scaling integration |
| DisableMaintenance | 10m0s | Community & Enterprise | Disable ArangoDB maintenance mode |
| DisableMemberMaintenance | 10m0s | Enterprise Only | Disable ArangoDB DBServer maintenance mode |
| EnableClusterScaling | 10m0s | Community & Enterprise | (Deprecated) Enable Cluster Scaling integration |
| EnableMaintenance | 10m0s | Community & Enterprise | Enable ArangoDB maintenance mode |
| EnableMemberMaintenance | 10m0s | Enterprise Only | Enable ArangoDB DBServer maintenance mode |
| EncryptionKeyAdd | 10m0s | Enterprise Only | Add the encryption key to the pool |
| EncryptionKeyPropagated | 10m0s | Enterprise Only | Update condition of encryption propagation |
| EncryptionKeyRefresh | 10m0s | Enterprise Only | Refresh the encryption keys on member |
| EncryptionKeyRemove | 10m0s | Enterprise Only | Remove the encryption key to the pool |
| EncryptionKeyStatusUpdate | 10m0s | Enterprise Only | Update status of encryption propagation |
| Idle | 10m0s | Community & Enterprise | Define idle operation in case if preconditions are not meet |
| JWTAdd | 10m0s | Enterprise Only | Adds new JWT to the pool |
| JWTClean | 10m0s | Enterprise Only | Remove JWT key from the pool |
| JWTPropagated | 10m0s | Enterprise Only | Update condition of JWT propagation |
| JWTRefresh | 10m0s | Enterprise Only | Refresh current JWT secrets on the member |
| JWTSetActive | 10m0s | Enterprise Only | Change active JWT key on the cluster |
| JWTStatusUpdate | 10m0s | Enterprise Only | Update status of JWT propagation |
| KillMemberPod | 10m0s | Community & Enterprise | Execute Delete on Pod 9put pod in Terminating state) |
| LicenseSet | 10m0s | Community & Enterprise | Update Cluster license (3.9+) |
| MarkToRemoveMember | 10m0s | Community & Enterprise | Marks member to be removed. Used when member Pod is annotated with replace annotation |
| MemberPhaseUpdate | 10m0s | Community & Enterprise | Change member phase |
| MemberRIDUpdate | 10m0s | Community & Enterprise | Update Run ID of member |
| PVCResize | 30m0s | Community & Enterprise | Start the resize procedure. Updates PVC Requests field |
| PVCResized | 15m0s | Community & Enterprise | Waits for PVC resize to be completed |
| RebalancerCheck | 10m0s | Enterprise Only | Check Rebalancer job progress |
| RebalancerClean | 10m0s | Enterprise Only | Cleans Rebalancer jobs |
| RebalancerGenerate | 10m0s | Enterprise Only | Generates the Rebalancer plan |
| RecreateMember | 15m0s | Community & Enterprise | Recreate member with same ID and Data |
| RefreshTLSKeyfileCertificate | 30m0s | Enterprise Only | Recreate Server TLS Certificate secret |
| RemoveMember | 15m0s | Community & Enterprise | Removes member from the Cluster and Status |
| RenewTLSCACertificate | 30m0s | Enterprise Only | Recreate Managed CA secret |
| RenewTLSCertificate | 30m0s | Enterprise Only | Recreate Server TLS Certificate secret |
| ResignLeadership | 30m0s | Community & Enterprise | Run the ResignLeadership job on DBServer |
| ResourceSync | 10m0s | Community & Enterprise | Runs the Resource sync |
| RotateMember | 15m0s | Community & Enterprise | Waits for Pod restart and recreation |
| RotateStartMember | 15m0s | Community & Enterprise | Start member rotation. After this action member is down |
| RotateStopMember | 15m0s | Community & Enterprise | Finalize member rotation. After this action member is started back |
| RuntimeContainerArgsLogLevelUpdate | 10m0s | Community & Enterprise | Change ArangoDB Member log levels in runtime |
| RuntimeContainerImageUpdate | 10m0s | Community & Enterprise | Update Container Image in runtime |
| SetCondition | 10m0s | Community & Enterprise | (Deprecated) Set deployment condition |
| SetConditionV2 | 10m0s | Community & Enterprise | Set deployment condition |
| SetCurrentImage | 6h0m0s | Community & Enterprise | Update deployment current image after image discovery |
| SetMaintenanceCondition | 10m0s | Community & Enterprise | Update ArangoDB maintenance condition |
| SetMemberCondition | 10m0s | Community & Enterprise | (Deprecated) Set member condition |
| SetMemberConditionV2 | 10m0s | Community & Enterprise | Set member condition |
| SetMemberCurrentImage | 10m0s | Community & Enterprise | Update Member current image |
| ShutdownMember | 30m0s | Community & Enterprise | Sends Shutdown requests and waits for container to be stopped |
| TLSKeyStatusUpdate | 10m0s | Enterprise Only | Update Status of TLS propagation process |
| TLSPropagated | 10m0s | Enterprise Only | Update TLS propagation condition |
| TimezoneSecretSet | 30m0s | Community & Enterprise | Set timezone details in cluster |
| TopologyDisable | 10m0s | Enterprise Only | Disable TopologyAwareness |
| TopologyEnable | 10m0s | Enterprise Only | Enable TopologyAwareness |
| TopologyMemberAssignment | 10m0s | Enterprise Only | Update TopologyAwareness Members assignments |
| TopologyZonesUpdate | 10m0s | Enterprise Only | Update TopologyAwareness Zones info |
| UpToDateUpdate | 10m0s | Community & Enterprise | Update UpToDate condition |
| UpdateTLSSNI | 10m0s | Enterprise Only | Update certificate in SNI |
| UpgradeMember | 6h0m0s | Community & Enterprise | Run the Upgrade procedure on member |
| WaitForMemberInSync | 30m0s | Community & Enterprise | Wait for member to be in sync. In case of DBServer waits for shards. In case of Agents to catch-up on Agency index |
| WaitForMemberUp | 30m0s | Community & Enterprise | Wait for member to be responsive |
## ArangoDeployment spec
```yaml
spec:
timeouts:
actions:
AddMember: 10m0s
AppendTLSCACertificate: 30m0s
ArangoMemberUpdatePodSpec: 10m0s
ArangoMemberUpdatePodStatus: 10m0s
BackupRestore: 15m0s
BackupRestoreClean: 15m0s
BootstrapSetPassword: 10m0s
BootstrapUpdate: 10m0s
CleanOutMember: 48h0m0s
CleanTLSCACertificate: 30m0s
CleanTLSKeyfileCertificate: 30m0s
ClusterMemberCleanup: 10m0s
DisableClusterScaling: 10m0s
DisableMaintenance: 10m0s
DisableMemberMaintenance: 10m0s
EnableClusterScaling: 10m0s
EnableMaintenance: 10m0s
EnableMemberMaintenance: 10m0s
EncryptionKeyAdd: 10m0s
EncryptionKeyPropagated: 10m0s
EncryptionKeyRefresh: 10m0s
EncryptionKeyRemove: 10m0s
EncryptionKeyStatusUpdate: 10m0s
Idle: 10m0s
JWTAdd: 10m0s
JWTClean: 10m0s
JWTPropagated: 10m0s
JWTRefresh: 10m0s
JWTSetActive: 10m0s
JWTStatusUpdate: 10m0s
KillMemberPod: 10m0s
LicenseSet: 10m0s
MarkToRemoveMember: 10m0s
MemberPhaseUpdate: 10m0s
MemberRIDUpdate: 10m0s
PVCResize: 30m0s
PVCResized: 15m0s
RebalancerCheck: 10m0s
RebalancerClean: 10m0s
RebalancerGenerate: 10m0s
RecreateMember: 15m0s
RefreshTLSKeyfileCertificate: 30m0s
RemoveMember: 15m0s
RenewTLSCACertificate: 30m0s
RenewTLSCertificate: 30m0s
ResignLeadership: 30m0s
ResourceSync: 10m0s
RotateMember: 15m0s
RotateStartMember: 15m0s
RotateStopMember: 15m0s
RuntimeContainerArgsLogLevelUpdate: 10m0s
RuntimeContainerImageUpdate: 10m0s
SetCondition: 10m0s
SetConditionV2: 10m0s
SetCurrentImage: 6h0m0s
SetMaintenanceCondition: 10m0s
SetMemberCondition: 10m0s
SetMemberConditionV2: 10m0s
SetMemberCurrentImage: 10m0s
ShutdownMember: 30m0s
TLSKeyStatusUpdate: 10m0s
TLSPropagated: 10m0s
TimezoneSecretSet: 30m0s
TopologyDisable: 10m0s
TopologyEnable: 10m0s
TopologyMemberAssignment: 10m0s
TopologyZonesUpdate: 10m0s
UpToDateUpdate: 10m0s
UpdateTLSSNI: 10m0s
UpgradeMember: 6h0m0s
WaitForMemberInSync: 30m0s
WaitForMemberUp: 30m0s
```

351
internal/actions.go Normal file
View file

@ -0,0 +1,351 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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 internal
import (
_ "embed"
"fmt"
"os"
"path"
"sort"
"strings"
"text/template"
"time"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/yaml"
"github.com/arangodb/kube-arangodb/internal/md"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
//go:embed actions.yaml
var actions []byte
//go:embed actions.tmpl
var actionsMD []byte
//go:embed actions.go.tmpl
var actionsGoTemplate []byte
//go:embed actions.register.go.tmpl
var actionsRegisterGoTemplate []byte
//go:embed actions.register.test.go.tmpl
var actionsRegisterTestGoTemplate []byte
type ActionsInput struct {
DefaultTimeout meta.Duration `json:"default_timeout"`
Actions map[string]Action `json:"actions"`
}
func (i ActionsInput) Keys() []string {
z := make([]string, 0, len(i.Actions))
for k := range i.Actions {
z = append(z, k)
}
sort.Strings(z)
return z
}
type Scopes struct {
Normal, High, Resource bool
}
func (s Scopes) String() string {
q := make([]string, 0, 3)
if s.High {
q = append(q, "High")
}
if s.Normal {
q = append(q, "Normal")
}
if s.Resource {
q = append(q, "Resource")
}
if len(q) > 2 {
q = []string{
strings.Join(q[0:len(q)-1], ", "),
q[len(q)-1],
}
}
return strings.Join(q, " and ")
}
func (i ActionsInput) Scopes() map[string]Scopes {
r := map[string]Scopes{}
for k, a := range i.Actions {
r[k] = Scopes{
Normal: a.InScope("normal"),
High: a.InScope("high"),
Resource: a.InScope("resource"),
}
}
return r
}
func (i ActionsInput) StartFailureGracePeriods() map[string]string {
r := map[string]string{}
for k, a := range i.Actions {
if a.StartupFailureGracePeriod == nil {
r[k] = ""
} else {
r[k] = fmt.Sprintf("%d * time.Second", a.StartupFailureGracePeriod.Duration/time.Second)
}
}
return r
}
func (i ActionsInput) HighestScopes() map[string]string {
r := map[string]string{}
for k, a := range i.Scopes() {
if a.High {
r[k] = "High"
} else if a.Normal {
r[k] = "Normal"
} else if a.Resource {
r[k] = "Resource"
} else {
r[k] = "Unknown"
}
}
return r
}
func (i ActionsInput) Descriptions() map[string]string {
r := map[string]string{}
for k, a := range i.Actions {
r[k] = a.Description
}
return r
}
func (i ActionsInput) Timeouts() map[string]string {
r := map[string]string{}
for k, a := range i.Actions {
if a.Timeout != nil {
r[k] = fmt.Sprintf("%d * time.Second // %s", a.Timeout.Duration/time.Second, a.Timeout.Duration.String())
} else {
r[k] = "ActionsDefaultTimeout"
}
}
return r
}
type Action struct {
Timeout *meta.Duration `json:"timeout,omitempty"`
StartupFailureGracePeriod *meta.Duration `json:"startupFailureGracePeriod,omitempty"`
Scopes []string `json:"scopes,omitempty"`
Description string `json:"description"`
Enterprise bool `json:"enterprise"`
}
func (a Action) InScope(scope string) bool {
if a.Scopes == nil {
return strings.Title(scope) == "Normal"
}
for _, x := range a.Scopes {
if strings.Title(scope) == strings.Title(x) {
return true
}
}
return false
}
func RenderActions(root string) error {
var in ActionsInput
if err := yaml.Unmarshal(actions, &in); err != nil {
return err
}
{
actions := path.Join(root, "pkg", "apis", "deployment", "v1", "actions.generated.go")
out, err := os.OpenFile(actions, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
if err != nil {
return err
}
i, err := template.New("actions").Parse(string(actionsGoTemplate))
if err != nil {
return err
}
if err := i.Execute(out, map[string]interface{}{
"actions": in.Keys(),
"scopes": in.Scopes(),
"highestScopes": in.HighestScopes(),
"timeouts": in.Timeouts(),
"descriptions": in.Descriptions(),
"defaultTimeout": fmt.Sprintf("%d * time.Second // %s", in.DefaultTimeout.Duration/time.Second, in.DefaultTimeout.Duration.String()),
}); err != nil {
return err
}
if err := out.Close(); err != nil {
return err
}
}
{
actions := path.Join(root, "pkg", "deployment", "reconcile", "action.register.generated.go")
out, err := os.OpenFile(actions, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
if err != nil {
return err
}
i, err := template.New("actions").Parse(string(actionsRegisterGoTemplate))
if err != nil {
return err
}
if err := i.Execute(out, map[string]interface{}{
"actions": in.Keys(),
"startupFailureGracePeriods": in.StartFailureGracePeriods(),
}); err != nil {
return err
}
if err := out.Close(); err != nil {
return err
}
}
{
actions := path.Join(root, "pkg", "deployment", "reconcile", "action.register.generated_test.go")
out, err := os.OpenFile(actions, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
if err != nil {
return err
}
i, err := template.New("actions").Parse(string(actionsRegisterTestGoTemplate))
if err != nil {
return err
}
if err := i.Execute(out, map[string]interface{}{
"actions": in.Keys(),
"startupFailureGracePeriods": in.StartFailureGracePeriods(),
}); err != nil {
return err
}
if err := out.Close(); err != nil {
return err
}
}
{
actions := path.Join(root, "docs", "generated", "actions.md")
out, err := os.OpenFile(actions, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
if err != nil {
return err
}
i, err := template.New("actions").Parse(string(actionsMD))
if err != nil {
return err
}
action := md.NewColumn("Action", md.ColumnCenterAlign)
timeout := md.NewColumn("Timeout", md.ColumnCenterAlign)
description := md.NewColumn("Description", md.ColumnCenterAlign)
edition := md.NewColumn("Edition", md.ColumnCenterAlign)
t := md.NewTable(
action,
timeout,
edition,
description,
)
for _, k := range in.Keys() {
a := in.Actions[k]
v := in.DefaultTimeout.Duration.String()
if t := a.Timeout; t != nil {
v = t.Duration.String()
}
vr := "Community & Enterprise"
if a.Enterprise {
vr = "Enterprise Only"
}
if err := t.AddRow(map[md.Column]string{
action: k,
timeout: v,
description: a.Description,
edition: vr,
}); err != nil {
return err
}
}
timeouts := api.ActionTimeouts{}
for _, k := range in.Keys() {
a := in.Actions[k]
if a.Timeout != nil {
timeouts[api.ActionType(k)] = api.NewTimeout(a.Timeout.Duration)
} else {
timeouts[api.ActionType(k)] = api.NewTimeout(in.DefaultTimeout.Duration)
}
}
d, err := yaml.Marshal(map[string]interface{}{
"spec": map[string]interface{}{
"timeouts": map[string]interface{}{
"actions": timeouts,
},
},
})
if err != nil {
return err
}
if err := i.Execute(out, map[string]interface{}{
"table": t.Render(),
"example": string(d),
}); err != nil {
return err
}
if err := out.Close(); err != nil {
return err
}
}
return nil
}

61
internal/actions.go.tmpl Normal file
View file

@ -0,0 +1,61 @@
{{- $root := . -}}
//
// Copyright 2016-2022 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 v1
import "time"
const (
// Timeouts
// ActionsDefaultTimeout define default timeout
ActionsDefaultTimeout time.Duration = {{ $root.defaultTimeout }}
{{- range .actions }}
// Action{{ . }}DefaultTimeout define default timeout for action Action{{ . }}
Action{{ . }}DefaultTimeout time.Duration = {{ index $root.timeouts . }}
{{- end }}
// Actions
{{ range .actions }}
// ActionType{{ . }} in scopes {{ index $root.scopes . }}. {{ index $root.descriptions . }}
ActionType{{ . }} ActionType = "{{ . }}"
{{- end }}
)
func ActionDefaultTimeout(in ActionType) time.Duration {
switch in {
{{- range .actions }}
case ActionType{{ . }}:
return Action{{ . }}DefaultTimeout
{{- end }}
default:
return ActionsDefaultTimeout
}
}
func GetActionPriority(in ActionType) ActionPriority {
switch in {
{{- range .actions }}
case ActionType{{ . }}:
return ActionPriority{{ index $root.highestScopes . }}
{{- end }}
default:
return ActionPriorityUnknown
}
}

View file

@ -0,0 +1,53 @@
{{- $root := . -}}
//
// Copyright 2016-2022 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 reconcile
import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
var (
// Ensure implementation
{{- range .actions }}
_ Action = &action{{ . }}{}
_ actionFactory = new{{ . }}Action
{{- end }}
)
func init() {
// Register all actions
{{- range .actions }}
// {{ . }}
{
// Get Action defition
function := new{{ . }}Action
action := api.ActionType{{ . }}
// Wrap action main function
{{- $startupFailureGracePeriod := index $root.startupFailureGracePeriods . -}}
{{- if $startupFailureGracePeriod }}
function = withActionStartFailureGracePeriod(function, {{ $startupFailureGracePeriod }})
{{- end }}
// Register action
registerAction(action, function)
}
{{- end }}
}

View file

@ -0,0 +1,69 @@
{{- $root := . -}}
//
// Copyright 2016-2022 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 reconcile
import (
"testing"
"time"
"github.com/stretchr/testify/require"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func Test_Actions(t *testing.T) {
// Iterate over all actions
{{- range .actions }}
t.Run("{{ . }}", func(t *testing.T) {
ActionsExistence(t, api.ActionType{{ . }})
{{- $startupFailureGracePeriod := index $root.startupFailureGracePeriods . -}}
{{- if $startupFailureGracePeriod }}
ActionsWrapWithActionStartFailureGracePeriod(t, api.ActionType{{ . }}, {{ $startupFailureGracePeriod }})
{{- end }}
})
{{- end }}
}
func ActionsExistence(t *testing.T, action api.ActionType) {
t.Run("Existence", func(t *testing.T) {
_, ok := getActionFactory(action)
require.True(t, ok)
})
}
func ActionsWrapWithActionStartFailureGracePeriod(t *testing.T, action api.ActionType, timeout time.Duration) {
t.Run("WrapWithActionStartFailureGracePeriod", func(t *testing.T) {
f, ok := getActionFactory(action)
require.True(t, ok)
a := extractAction(f)
require.NotNil(t, a)
z, ok := a.(*actionStartFailureGracePeriod)
require.True(t, ok)
require.Equal(t, z.failureGracePeriod, timeout)
})
}
func extractAction(f actionFactory) Action {
return f(api.Action{}, nil)
}

11
internal/actions.tmpl Normal file
View file

@ -0,0 +1,11 @@
# ArangoDB Operator Metrics
## List
{{ .table }}
## ArangoDeployment spec
```yaml
{{ .example }}
```

224
internal/actions.yaml Normal file
View file

@ -0,0 +1,224 @@
---
default_timeout: 10m
actions:
Idle:
description: Define idle operation in case if preconditions are not meet
AddMember:
description: Adds new member to the Member list
timeout: 10m
MarkToRemoveMember:
description: Marks member to be removed. Used when member Pod is annotated with replace annotation
RemoveMember:
description: Removes member from the Cluster and Status
timeout: 15m
RecreateMember:
description: Recreate member with same ID and Data
timeout: 15m
CleanOutMember:
description: Run the CleanOut job on member
timeout: 48h
ShutdownMember:
description: Sends Shutdown requests and waits for container to be stopped
timeout: 30m
startupFailureGracePeriod: 1m
ResignLeadership:
description: Run the ResignLeadership job on DBServer
timeout: 30m
KillMemberPod:
description: Execute Delete on Pod 9put pod in Terminating state)
RotateMember:
description: Waits for Pod restart and recreation
timeout: 15m
startupFailureGracePeriod: 1m
RotateStartMember:
description: Start member rotation. After this action member is down
timeout: 15m
startupFailureGracePeriod: 1m
RotateStopMember:
description: Finalize member rotation. After this action member is started back
timeout: 15m
UpgradeMember:
description: Run the Upgrade procedure on member
timeout: 6h
WaitForMemberUp:
description: Wait for member to be responsive
timeout: 30m
WaitForMemberInSync:
description: Wait for member to be in sync. In case of DBServer waits for shards. In case of Agents to catch-up on Agency index
timeout: 30m
RenewTLSCertificate:
enterprise: true
description: Recreate Server TLS Certificate secret
timeout: 30m
RenewTLSCACertificate:
enterprise: true
description: Recreate Managed CA secret
timeout: 30m
AppendTLSCACertificate:
enterprise: true
description: Append Certificate into CA TrustStore
timeout: 30m
CleanTLSCACertificate:
enterprise: true
description: Remove Certificate from CA TrustStore
timeout: 30m
CleanTLSKeyfileCertificate:
enterprise: true
description: Remove old TLS certificate from server
timeout: 30m
RefreshTLSKeyfileCertificate:
enterprise: true
description: Recreate Server TLS Certificate secret
timeout: 30m
TLSKeyStatusUpdate:
enterprise: true
description: Update Status of TLS propagation process
TLSPropagated:
enterprise: true
description: Update TLS propagation condition
UpdateTLSSNI:
enterprise: true
description: Update certificate in SNI
timeout: 10m
SetCurrentImage:
description: Update deployment current image after image discovery
timeout: 6h
SetMemberCurrentImage:
description: Update Member current image
DisableClusterScaling:
description: (Deprecated) Disable Cluster Scaling integration
EnableClusterScaling:
description: (Deprecated) Enable Cluster Scaling integration
PVCResize:
description: Start the resize procedure. Updates PVC Requests field
timeout: 30m
PVCResized:
description: Waits for PVC resize to be completed
timeout: 15m
UpToDateUpdate:
description: Update UpToDate condition
BackupRestore:
enterprise: true
description: Restore selected Backup
timeout: 15m
BackupRestoreClean:
enterprise: true
description: Clean restore status in case of restore spec change
timeout: 15m
EncryptionKeyAdd:
enterprise: true
description: Add the encryption key to the pool
EncryptionKeyRemove:
enterprise: true
description: Remove the encryption key to the pool
EncryptionKeyRefresh:
enterprise: true
description: Refresh the encryption keys on member
EncryptionKeyStatusUpdate:
enterprise: true
description: Update status of encryption propagation
EncryptionKeyPropagated:
enterprise: true
description: Update condition of encryption propagation
JWTStatusUpdate:
enterprise: true
description: Update status of JWT propagation
JWTSetActive:
enterprise: true
description: Change active JWT key on the cluster
JWTAdd:
enterprise: true
description: Adds new JWT to the pool
JWTClean:
enterprise: true
description: Remove JWT key from the pool
JWTRefresh:
enterprise: true
description: Refresh current JWT secrets on the member
JWTPropagated:
enterprise: true
description: Update condition of JWT propagation
ClusterMemberCleanup:
description: Remove member from Cluster if it is gone already (Coordinators)
EnableMaintenance:
description: Enable ArangoDB maintenance mode
DisableMaintenance:
description: Disable ArangoDB maintenance mode
SetMaintenanceCondition:
description: Update ArangoDB maintenance condition
EnableMemberMaintenance:
enterprise: true
description: Enable ArangoDB DBServer maintenance mode
DisableMemberMaintenance:
enterprise: true
description: Disable ArangoDB DBServer maintenance mode
BootstrapUpdate:
description: Update bootstrap status
BootstrapSetPassword:
description: Change password during bootstrap procedure
MemberPhaseUpdate:
description: Change member phase
scopes:
- High
SetMemberCondition:
description: (Deprecated) Set member condition
scopes:
- High
SetMemberConditionV2:
description: Set member condition
scopes:
- High
SetCondition:
description: (Deprecated) Set deployment condition
scopes:
- High
SetConditionV2:
description: Set deployment condition
scopes:
- High
MemberRIDUpdate:
description: Update Run ID of member
scopes:
- High
ArangoMemberUpdatePodSpec:
description: Propagate Member Pod spec (requested)
scopes:
- High
ArangoMemberUpdatePodStatus:
description: Propagate Member Pod status (current)
scopes:
- High
LicenseSet:
description: Update Cluster license (3.9+)
RuntimeContainerImageUpdate:
description: Update Container Image in runtime
RuntimeContainerArgsLogLevelUpdate:
description: Change ArangoDB Member log levels in runtime
TopologyEnable:
enterprise: true
description: Enable TopologyAwareness
TopologyDisable:
enterprise: true
description: Disable TopologyAwareness
TopologyZonesUpdate:
enterprise: true
description: Update TopologyAwareness Zones info
TopologyMemberAssignment:
enterprise: true
description: Update TopologyAwareness Members assignments
RebalancerGenerate:
enterprise: true
description: Generates the Rebalancer plan
RebalancerCheck:
enterprise: true
description: Check Rebalancer job progress
RebalancerClean:
enterprise: true
description: Cleans Rebalancer jobs
ResourceSync:
description: Runs the Resource sync
TimezoneSecretSet:
description: Set timezone details in cluster
timeout: 30m

35
internal/actions_test.go Normal file
View file

@ -0,0 +1,35 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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 internal
import (
"os"
"testing"
"github.com/stretchr/testify/require"
)
func Test_GenerateActions(t *testing.T) {
root := os.Getenv("ROOT")
require.NotEmpty(t, root)
require.NoError(t, RenderActions(root))
}

View file

@ -28,6 +28,7 @@ import (
)
func Test_GenerateTimezones(t *testing.T) {
t.Skip("Generate once")
root := os.Getenv("ROOT")
require.NotEmpty(t, root)
require.NoError(t, RenderTimezones(root))

View file

@ -0,0 +1,621 @@
//
// Copyright 2016-2022 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 v1
import "time"
const (
// Timeouts
// ActionsDefaultTimeout define default timeout
ActionsDefaultTimeout time.Duration = 600 * time.Second // 10m0s
// ActionAddMemberDefaultTimeout define default timeout for action ActionAddMember
ActionAddMemberDefaultTimeout time.Duration = 600 * time.Second // 10m0s
// ActionAppendTLSCACertificateDefaultTimeout define default timeout for action ActionAppendTLSCACertificate
ActionAppendTLSCACertificateDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
// ActionArangoMemberUpdatePodSpecDefaultTimeout define default timeout for action ActionArangoMemberUpdatePodSpec
ActionArangoMemberUpdatePodSpecDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionArangoMemberUpdatePodStatusDefaultTimeout define default timeout for action ActionArangoMemberUpdatePodStatus
ActionArangoMemberUpdatePodStatusDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionBackupRestoreDefaultTimeout define default timeout for action ActionBackupRestore
ActionBackupRestoreDefaultTimeout time.Duration = 900 * time.Second // 15m0s
// ActionBackupRestoreCleanDefaultTimeout define default timeout for action ActionBackupRestoreClean
ActionBackupRestoreCleanDefaultTimeout time.Duration = 900 * time.Second // 15m0s
// ActionBootstrapSetPasswordDefaultTimeout define default timeout for action ActionBootstrapSetPassword
ActionBootstrapSetPasswordDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionBootstrapUpdateDefaultTimeout define default timeout for action ActionBootstrapUpdate
ActionBootstrapUpdateDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionCleanOutMemberDefaultTimeout define default timeout for action ActionCleanOutMember
ActionCleanOutMemberDefaultTimeout time.Duration = 172800 * time.Second // 48h0m0s
// ActionCleanTLSCACertificateDefaultTimeout define default timeout for action ActionCleanTLSCACertificate
ActionCleanTLSCACertificateDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
// ActionCleanTLSKeyfileCertificateDefaultTimeout define default timeout for action ActionCleanTLSKeyfileCertificate
ActionCleanTLSKeyfileCertificateDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
// ActionClusterMemberCleanupDefaultTimeout define default timeout for action ActionClusterMemberCleanup
ActionClusterMemberCleanupDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionDisableClusterScalingDefaultTimeout define default timeout for action ActionDisableClusterScaling
ActionDisableClusterScalingDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionDisableMaintenanceDefaultTimeout define default timeout for action ActionDisableMaintenance
ActionDisableMaintenanceDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionDisableMemberMaintenanceDefaultTimeout define default timeout for action ActionDisableMemberMaintenance
ActionDisableMemberMaintenanceDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionEnableClusterScalingDefaultTimeout define default timeout for action ActionEnableClusterScaling
ActionEnableClusterScalingDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionEnableMaintenanceDefaultTimeout define default timeout for action ActionEnableMaintenance
ActionEnableMaintenanceDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionEnableMemberMaintenanceDefaultTimeout define default timeout for action ActionEnableMemberMaintenance
ActionEnableMemberMaintenanceDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionEncryptionKeyAddDefaultTimeout define default timeout for action ActionEncryptionKeyAdd
ActionEncryptionKeyAddDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionEncryptionKeyPropagatedDefaultTimeout define default timeout for action ActionEncryptionKeyPropagated
ActionEncryptionKeyPropagatedDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionEncryptionKeyRefreshDefaultTimeout define default timeout for action ActionEncryptionKeyRefresh
ActionEncryptionKeyRefreshDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionEncryptionKeyRemoveDefaultTimeout define default timeout for action ActionEncryptionKeyRemove
ActionEncryptionKeyRemoveDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionEncryptionKeyStatusUpdateDefaultTimeout define default timeout for action ActionEncryptionKeyStatusUpdate
ActionEncryptionKeyStatusUpdateDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionIdleDefaultTimeout define default timeout for action ActionIdle
ActionIdleDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionJWTAddDefaultTimeout define default timeout for action ActionJWTAdd
ActionJWTAddDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionJWTCleanDefaultTimeout define default timeout for action ActionJWTClean
ActionJWTCleanDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionJWTPropagatedDefaultTimeout define default timeout for action ActionJWTPropagated
ActionJWTPropagatedDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionJWTRefreshDefaultTimeout define default timeout for action ActionJWTRefresh
ActionJWTRefreshDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionJWTSetActiveDefaultTimeout define default timeout for action ActionJWTSetActive
ActionJWTSetActiveDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionJWTStatusUpdateDefaultTimeout define default timeout for action ActionJWTStatusUpdate
ActionJWTStatusUpdateDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionKillMemberPodDefaultTimeout define default timeout for action ActionKillMemberPod
ActionKillMemberPodDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionLicenseSetDefaultTimeout define default timeout for action ActionLicenseSet
ActionLicenseSetDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionMarkToRemoveMemberDefaultTimeout define default timeout for action ActionMarkToRemoveMember
ActionMarkToRemoveMemberDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionMemberPhaseUpdateDefaultTimeout define default timeout for action ActionMemberPhaseUpdate
ActionMemberPhaseUpdateDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionMemberRIDUpdateDefaultTimeout define default timeout for action ActionMemberRIDUpdate
ActionMemberRIDUpdateDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionPVCResizeDefaultTimeout define default timeout for action ActionPVCResize
ActionPVCResizeDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
// ActionPVCResizedDefaultTimeout define default timeout for action ActionPVCResized
ActionPVCResizedDefaultTimeout time.Duration = 900 * time.Second // 15m0s
// ActionRebalancerCheckDefaultTimeout define default timeout for action ActionRebalancerCheck
ActionRebalancerCheckDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionRebalancerCleanDefaultTimeout define default timeout for action ActionRebalancerClean
ActionRebalancerCleanDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionRebalancerGenerateDefaultTimeout define default timeout for action ActionRebalancerGenerate
ActionRebalancerGenerateDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionRecreateMemberDefaultTimeout define default timeout for action ActionRecreateMember
ActionRecreateMemberDefaultTimeout time.Duration = 900 * time.Second // 15m0s
// ActionRefreshTLSKeyfileCertificateDefaultTimeout define default timeout for action ActionRefreshTLSKeyfileCertificate
ActionRefreshTLSKeyfileCertificateDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
// ActionRemoveMemberDefaultTimeout define default timeout for action ActionRemoveMember
ActionRemoveMemberDefaultTimeout time.Duration = 900 * time.Second // 15m0s
// ActionRenewTLSCACertificateDefaultTimeout define default timeout for action ActionRenewTLSCACertificate
ActionRenewTLSCACertificateDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
// ActionRenewTLSCertificateDefaultTimeout define default timeout for action ActionRenewTLSCertificate
ActionRenewTLSCertificateDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
// ActionResignLeadershipDefaultTimeout define default timeout for action ActionResignLeadership
ActionResignLeadershipDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
// ActionResourceSyncDefaultTimeout define default timeout for action ActionResourceSync
ActionResourceSyncDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionRotateMemberDefaultTimeout define default timeout for action ActionRotateMember
ActionRotateMemberDefaultTimeout time.Duration = 900 * time.Second // 15m0s
// ActionRotateStartMemberDefaultTimeout define default timeout for action ActionRotateStartMember
ActionRotateStartMemberDefaultTimeout time.Duration = 900 * time.Second // 15m0s
// ActionRotateStopMemberDefaultTimeout define default timeout for action ActionRotateStopMember
ActionRotateStopMemberDefaultTimeout time.Duration = 900 * time.Second // 15m0s
// ActionRuntimeContainerArgsLogLevelUpdateDefaultTimeout define default timeout for action ActionRuntimeContainerArgsLogLevelUpdate
ActionRuntimeContainerArgsLogLevelUpdateDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionRuntimeContainerImageUpdateDefaultTimeout define default timeout for action ActionRuntimeContainerImageUpdate
ActionRuntimeContainerImageUpdateDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionSetConditionDefaultTimeout define default timeout for action ActionSetCondition
ActionSetConditionDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionSetConditionV2DefaultTimeout define default timeout for action ActionSetConditionV2
ActionSetConditionV2DefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionSetCurrentImageDefaultTimeout define default timeout for action ActionSetCurrentImage
ActionSetCurrentImageDefaultTimeout time.Duration = 21600 * time.Second // 6h0m0s
// ActionSetMaintenanceConditionDefaultTimeout define default timeout for action ActionSetMaintenanceCondition
ActionSetMaintenanceConditionDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionSetMemberConditionDefaultTimeout define default timeout for action ActionSetMemberCondition
ActionSetMemberConditionDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionSetMemberConditionV2DefaultTimeout define default timeout for action ActionSetMemberConditionV2
ActionSetMemberConditionV2DefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionSetMemberCurrentImageDefaultTimeout define default timeout for action ActionSetMemberCurrentImage
ActionSetMemberCurrentImageDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionShutdownMemberDefaultTimeout define default timeout for action ActionShutdownMember
ActionShutdownMemberDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
// ActionTLSKeyStatusUpdateDefaultTimeout define default timeout for action ActionTLSKeyStatusUpdate
ActionTLSKeyStatusUpdateDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionTLSPropagatedDefaultTimeout define default timeout for action ActionTLSPropagated
ActionTLSPropagatedDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionTimezoneSecretSetDefaultTimeout define default timeout for action ActionTimezoneSecretSet
ActionTimezoneSecretSetDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
// ActionTopologyDisableDefaultTimeout define default timeout for action ActionTopologyDisable
ActionTopologyDisableDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionTopologyEnableDefaultTimeout define default timeout for action ActionTopologyEnable
ActionTopologyEnableDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionTopologyMemberAssignmentDefaultTimeout define default timeout for action ActionTopologyMemberAssignment
ActionTopologyMemberAssignmentDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionTopologyZonesUpdateDefaultTimeout define default timeout for action ActionTopologyZonesUpdate
ActionTopologyZonesUpdateDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionUpToDateUpdateDefaultTimeout define default timeout for action ActionUpToDateUpdate
ActionUpToDateUpdateDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionUpdateTLSSNIDefaultTimeout define default timeout for action ActionUpdateTLSSNI
ActionUpdateTLSSNIDefaultTimeout time.Duration = 600 * time.Second // 10m0s
// ActionUpgradeMemberDefaultTimeout define default timeout for action ActionUpgradeMember
ActionUpgradeMemberDefaultTimeout time.Duration = 21600 * time.Second // 6h0m0s
// ActionWaitForMemberInSyncDefaultTimeout define default timeout for action ActionWaitForMemberInSync
ActionWaitForMemberInSyncDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
// ActionWaitForMemberUpDefaultTimeout define default timeout for action ActionWaitForMemberUp
ActionWaitForMemberUpDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
// Actions
// ActionTypeAddMember in scopes Normal. Adds new member to the Member list
ActionTypeAddMember ActionType = "AddMember"
// ActionTypeAppendTLSCACertificate in scopes Normal. Append Certificate into CA TrustStore
ActionTypeAppendTLSCACertificate ActionType = "AppendTLSCACertificate"
// ActionTypeArangoMemberUpdatePodSpec in scopes High. Propagate Member Pod spec (requested)
ActionTypeArangoMemberUpdatePodSpec ActionType = "ArangoMemberUpdatePodSpec"
// ActionTypeArangoMemberUpdatePodStatus in scopes High. Propagate Member Pod status (current)
ActionTypeArangoMemberUpdatePodStatus ActionType = "ArangoMemberUpdatePodStatus"
// ActionTypeBackupRestore in scopes Normal. Restore selected Backup
ActionTypeBackupRestore ActionType = "BackupRestore"
// ActionTypeBackupRestoreClean in scopes Normal. Clean restore status in case of restore spec change
ActionTypeBackupRestoreClean ActionType = "BackupRestoreClean"
// ActionTypeBootstrapSetPassword in scopes Normal. Change password during bootstrap procedure
ActionTypeBootstrapSetPassword ActionType = "BootstrapSetPassword"
// ActionTypeBootstrapUpdate in scopes Normal. Update bootstrap status
ActionTypeBootstrapUpdate ActionType = "BootstrapUpdate"
// ActionTypeCleanOutMember in scopes Normal. Run the CleanOut job on member
ActionTypeCleanOutMember ActionType = "CleanOutMember"
// ActionTypeCleanTLSCACertificate in scopes Normal. Remove Certificate from CA TrustStore
ActionTypeCleanTLSCACertificate ActionType = "CleanTLSCACertificate"
// ActionTypeCleanTLSKeyfileCertificate in scopes Normal. Remove old TLS certificate from server
ActionTypeCleanTLSKeyfileCertificate ActionType = "CleanTLSKeyfileCertificate"
// ActionTypeClusterMemberCleanup in scopes Normal. Remove member from Cluster if it is gone already (Coordinators)
ActionTypeClusterMemberCleanup ActionType = "ClusterMemberCleanup"
// ActionTypeDisableClusterScaling in scopes Normal. (Deprecated) Disable Cluster Scaling integration
ActionTypeDisableClusterScaling ActionType = "DisableClusterScaling"
// ActionTypeDisableMaintenance in scopes Normal. Disable ArangoDB maintenance mode
ActionTypeDisableMaintenance ActionType = "DisableMaintenance"
// ActionTypeDisableMemberMaintenance in scopes Normal. Disable ArangoDB DBServer maintenance mode
ActionTypeDisableMemberMaintenance ActionType = "DisableMemberMaintenance"
// ActionTypeEnableClusterScaling in scopes Normal. (Deprecated) Enable Cluster Scaling integration
ActionTypeEnableClusterScaling ActionType = "EnableClusterScaling"
// ActionTypeEnableMaintenance in scopes Normal. Enable ArangoDB maintenance mode
ActionTypeEnableMaintenance ActionType = "EnableMaintenance"
// ActionTypeEnableMemberMaintenance in scopes Normal. Enable ArangoDB DBServer maintenance mode
ActionTypeEnableMemberMaintenance ActionType = "EnableMemberMaintenance"
// ActionTypeEncryptionKeyAdd in scopes Normal. Add the encryption key to the pool
ActionTypeEncryptionKeyAdd ActionType = "EncryptionKeyAdd"
// ActionTypeEncryptionKeyPropagated in scopes Normal. Update condition of encryption propagation
ActionTypeEncryptionKeyPropagated ActionType = "EncryptionKeyPropagated"
// ActionTypeEncryptionKeyRefresh in scopes Normal. Refresh the encryption keys on member
ActionTypeEncryptionKeyRefresh ActionType = "EncryptionKeyRefresh"
// ActionTypeEncryptionKeyRemove in scopes Normal. Remove the encryption key to the pool
ActionTypeEncryptionKeyRemove ActionType = "EncryptionKeyRemove"
// ActionTypeEncryptionKeyStatusUpdate in scopes Normal. Update status of encryption propagation
ActionTypeEncryptionKeyStatusUpdate ActionType = "EncryptionKeyStatusUpdate"
// ActionTypeIdle in scopes Normal. Define idle operation in case if preconditions are not meet
ActionTypeIdle ActionType = "Idle"
// ActionTypeJWTAdd in scopes Normal. Adds new JWT to the pool
ActionTypeJWTAdd ActionType = "JWTAdd"
// ActionTypeJWTClean in scopes Normal. Remove JWT key from the pool
ActionTypeJWTClean ActionType = "JWTClean"
// ActionTypeJWTPropagated in scopes Normal. Update condition of JWT propagation
ActionTypeJWTPropagated ActionType = "JWTPropagated"
// ActionTypeJWTRefresh in scopes Normal. Refresh current JWT secrets on the member
ActionTypeJWTRefresh ActionType = "JWTRefresh"
// ActionTypeJWTSetActive in scopes Normal. Change active JWT key on the cluster
ActionTypeJWTSetActive ActionType = "JWTSetActive"
// ActionTypeJWTStatusUpdate in scopes Normal. Update status of JWT propagation
ActionTypeJWTStatusUpdate ActionType = "JWTStatusUpdate"
// ActionTypeKillMemberPod in scopes Normal. Execute Delete on Pod 9put pod in Terminating state)
ActionTypeKillMemberPod ActionType = "KillMemberPod"
// ActionTypeLicenseSet in scopes Normal. Update Cluster license (3.9+)
ActionTypeLicenseSet ActionType = "LicenseSet"
// ActionTypeMarkToRemoveMember in scopes Normal. Marks member to be removed. Used when member Pod is annotated with replace annotation
ActionTypeMarkToRemoveMember ActionType = "MarkToRemoveMember"
// ActionTypeMemberPhaseUpdate in scopes High. Change member phase
ActionTypeMemberPhaseUpdate ActionType = "MemberPhaseUpdate"
// ActionTypeMemberRIDUpdate in scopes High. Update Run ID of member
ActionTypeMemberRIDUpdate ActionType = "MemberRIDUpdate"
// ActionTypePVCResize in scopes Normal. Start the resize procedure. Updates PVC Requests field
ActionTypePVCResize ActionType = "PVCResize"
// ActionTypePVCResized in scopes Normal. Waits for PVC resize to be completed
ActionTypePVCResized ActionType = "PVCResized"
// ActionTypeRebalancerCheck in scopes Normal. Check Rebalancer job progress
ActionTypeRebalancerCheck ActionType = "RebalancerCheck"
// ActionTypeRebalancerClean in scopes Normal. Cleans Rebalancer jobs
ActionTypeRebalancerClean ActionType = "RebalancerClean"
// ActionTypeRebalancerGenerate in scopes Normal. Generates the Rebalancer plan
ActionTypeRebalancerGenerate ActionType = "RebalancerGenerate"
// ActionTypeRecreateMember in scopes Normal. Recreate member with same ID and Data
ActionTypeRecreateMember ActionType = "RecreateMember"
// ActionTypeRefreshTLSKeyfileCertificate in scopes Normal. Recreate Server TLS Certificate secret
ActionTypeRefreshTLSKeyfileCertificate ActionType = "RefreshTLSKeyfileCertificate"
// ActionTypeRemoveMember in scopes Normal. Removes member from the Cluster and Status
ActionTypeRemoveMember ActionType = "RemoveMember"
// ActionTypeRenewTLSCACertificate in scopes Normal. Recreate Managed CA secret
ActionTypeRenewTLSCACertificate ActionType = "RenewTLSCACertificate"
// ActionTypeRenewTLSCertificate in scopes Normal. Recreate Server TLS Certificate secret
ActionTypeRenewTLSCertificate ActionType = "RenewTLSCertificate"
// ActionTypeResignLeadership in scopes Normal. Run the ResignLeadership job on DBServer
ActionTypeResignLeadership ActionType = "ResignLeadership"
// ActionTypeResourceSync in scopes Normal. Runs the Resource sync
ActionTypeResourceSync ActionType = "ResourceSync"
// ActionTypeRotateMember in scopes Normal. Waits for Pod restart and recreation
ActionTypeRotateMember ActionType = "RotateMember"
// ActionTypeRotateStartMember in scopes Normal. Start member rotation. After this action member is down
ActionTypeRotateStartMember ActionType = "RotateStartMember"
// ActionTypeRotateStopMember in scopes Normal. Finalize member rotation. After this action member is started back
ActionTypeRotateStopMember ActionType = "RotateStopMember"
// ActionTypeRuntimeContainerArgsLogLevelUpdate in scopes Normal. Change ArangoDB Member log levels in runtime
ActionTypeRuntimeContainerArgsLogLevelUpdate ActionType = "RuntimeContainerArgsLogLevelUpdate"
// ActionTypeRuntimeContainerImageUpdate in scopes Normal. Update Container Image in runtime
ActionTypeRuntimeContainerImageUpdate ActionType = "RuntimeContainerImageUpdate"
// ActionTypeSetCondition in scopes High. (Deprecated) Set deployment condition
ActionTypeSetCondition ActionType = "SetCondition"
// ActionTypeSetConditionV2 in scopes High. Set deployment condition
ActionTypeSetConditionV2 ActionType = "SetConditionV2"
// ActionTypeSetCurrentImage in scopes Normal. Update deployment current image after image discovery
ActionTypeSetCurrentImage ActionType = "SetCurrentImage"
// ActionTypeSetMaintenanceCondition in scopes Normal. Update ArangoDB maintenance condition
ActionTypeSetMaintenanceCondition ActionType = "SetMaintenanceCondition"
// ActionTypeSetMemberCondition in scopes High. (Deprecated) Set member condition
ActionTypeSetMemberCondition ActionType = "SetMemberCondition"
// ActionTypeSetMemberConditionV2 in scopes High. Set member condition
ActionTypeSetMemberConditionV2 ActionType = "SetMemberConditionV2"
// ActionTypeSetMemberCurrentImage in scopes Normal. Update Member current image
ActionTypeSetMemberCurrentImage ActionType = "SetMemberCurrentImage"
// ActionTypeShutdownMember in scopes Normal. Sends Shutdown requests and waits for container to be stopped
ActionTypeShutdownMember ActionType = "ShutdownMember"
// ActionTypeTLSKeyStatusUpdate in scopes Normal. Update Status of TLS propagation process
ActionTypeTLSKeyStatusUpdate ActionType = "TLSKeyStatusUpdate"
// ActionTypeTLSPropagated in scopes Normal. Update TLS propagation condition
ActionTypeTLSPropagated ActionType = "TLSPropagated"
// ActionTypeTimezoneSecretSet in scopes Normal. Set timezone details in cluster
ActionTypeTimezoneSecretSet ActionType = "TimezoneSecretSet"
// ActionTypeTopologyDisable in scopes Normal. Disable TopologyAwareness
ActionTypeTopologyDisable ActionType = "TopologyDisable"
// ActionTypeTopologyEnable in scopes Normal. Enable TopologyAwareness
ActionTypeTopologyEnable ActionType = "TopologyEnable"
// ActionTypeTopologyMemberAssignment in scopes Normal. Update TopologyAwareness Members assignments
ActionTypeTopologyMemberAssignment ActionType = "TopologyMemberAssignment"
// ActionTypeTopologyZonesUpdate in scopes Normal. Update TopologyAwareness Zones info
ActionTypeTopologyZonesUpdate ActionType = "TopologyZonesUpdate"
// ActionTypeUpToDateUpdate in scopes Normal. Update UpToDate condition
ActionTypeUpToDateUpdate ActionType = "UpToDateUpdate"
// ActionTypeUpdateTLSSNI in scopes Normal. Update certificate in SNI
ActionTypeUpdateTLSSNI ActionType = "UpdateTLSSNI"
// ActionTypeUpgradeMember in scopes Normal. Run the Upgrade procedure on member
ActionTypeUpgradeMember ActionType = "UpgradeMember"
// ActionTypeWaitForMemberInSync in scopes Normal. Wait for member to be in sync. In case of DBServer waits for shards. In case of Agents to catch-up on Agency index
ActionTypeWaitForMemberInSync ActionType = "WaitForMemberInSync"
// ActionTypeWaitForMemberUp in scopes Normal. Wait for member to be responsive
ActionTypeWaitForMemberUp ActionType = "WaitForMemberUp"
)
func ActionDefaultTimeout(in ActionType) time.Duration {
switch in {
case ActionTypeAddMember:
return ActionAddMemberDefaultTimeout
case ActionTypeAppendTLSCACertificate:
return ActionAppendTLSCACertificateDefaultTimeout
case ActionTypeArangoMemberUpdatePodSpec:
return ActionArangoMemberUpdatePodSpecDefaultTimeout
case ActionTypeArangoMemberUpdatePodStatus:
return ActionArangoMemberUpdatePodStatusDefaultTimeout
case ActionTypeBackupRestore:
return ActionBackupRestoreDefaultTimeout
case ActionTypeBackupRestoreClean:
return ActionBackupRestoreCleanDefaultTimeout
case ActionTypeBootstrapSetPassword:
return ActionBootstrapSetPasswordDefaultTimeout
case ActionTypeBootstrapUpdate:
return ActionBootstrapUpdateDefaultTimeout
case ActionTypeCleanOutMember:
return ActionCleanOutMemberDefaultTimeout
case ActionTypeCleanTLSCACertificate:
return ActionCleanTLSCACertificateDefaultTimeout
case ActionTypeCleanTLSKeyfileCertificate:
return ActionCleanTLSKeyfileCertificateDefaultTimeout
case ActionTypeClusterMemberCleanup:
return ActionClusterMemberCleanupDefaultTimeout
case ActionTypeDisableClusterScaling:
return ActionDisableClusterScalingDefaultTimeout
case ActionTypeDisableMaintenance:
return ActionDisableMaintenanceDefaultTimeout
case ActionTypeDisableMemberMaintenance:
return ActionDisableMemberMaintenanceDefaultTimeout
case ActionTypeEnableClusterScaling:
return ActionEnableClusterScalingDefaultTimeout
case ActionTypeEnableMaintenance:
return ActionEnableMaintenanceDefaultTimeout
case ActionTypeEnableMemberMaintenance:
return ActionEnableMemberMaintenanceDefaultTimeout
case ActionTypeEncryptionKeyAdd:
return ActionEncryptionKeyAddDefaultTimeout
case ActionTypeEncryptionKeyPropagated:
return ActionEncryptionKeyPropagatedDefaultTimeout
case ActionTypeEncryptionKeyRefresh:
return ActionEncryptionKeyRefreshDefaultTimeout
case ActionTypeEncryptionKeyRemove:
return ActionEncryptionKeyRemoveDefaultTimeout
case ActionTypeEncryptionKeyStatusUpdate:
return ActionEncryptionKeyStatusUpdateDefaultTimeout
case ActionTypeIdle:
return ActionIdleDefaultTimeout
case ActionTypeJWTAdd:
return ActionJWTAddDefaultTimeout
case ActionTypeJWTClean:
return ActionJWTCleanDefaultTimeout
case ActionTypeJWTPropagated:
return ActionJWTPropagatedDefaultTimeout
case ActionTypeJWTRefresh:
return ActionJWTRefreshDefaultTimeout
case ActionTypeJWTSetActive:
return ActionJWTSetActiveDefaultTimeout
case ActionTypeJWTStatusUpdate:
return ActionJWTStatusUpdateDefaultTimeout
case ActionTypeKillMemberPod:
return ActionKillMemberPodDefaultTimeout
case ActionTypeLicenseSet:
return ActionLicenseSetDefaultTimeout
case ActionTypeMarkToRemoveMember:
return ActionMarkToRemoveMemberDefaultTimeout
case ActionTypeMemberPhaseUpdate:
return ActionMemberPhaseUpdateDefaultTimeout
case ActionTypeMemberRIDUpdate:
return ActionMemberRIDUpdateDefaultTimeout
case ActionTypePVCResize:
return ActionPVCResizeDefaultTimeout
case ActionTypePVCResized:
return ActionPVCResizedDefaultTimeout
case ActionTypeRebalancerCheck:
return ActionRebalancerCheckDefaultTimeout
case ActionTypeRebalancerClean:
return ActionRebalancerCleanDefaultTimeout
case ActionTypeRebalancerGenerate:
return ActionRebalancerGenerateDefaultTimeout
case ActionTypeRecreateMember:
return ActionRecreateMemberDefaultTimeout
case ActionTypeRefreshTLSKeyfileCertificate:
return ActionRefreshTLSKeyfileCertificateDefaultTimeout
case ActionTypeRemoveMember:
return ActionRemoveMemberDefaultTimeout
case ActionTypeRenewTLSCACertificate:
return ActionRenewTLSCACertificateDefaultTimeout
case ActionTypeRenewTLSCertificate:
return ActionRenewTLSCertificateDefaultTimeout
case ActionTypeResignLeadership:
return ActionResignLeadershipDefaultTimeout
case ActionTypeResourceSync:
return ActionResourceSyncDefaultTimeout
case ActionTypeRotateMember:
return ActionRotateMemberDefaultTimeout
case ActionTypeRotateStartMember:
return ActionRotateStartMemberDefaultTimeout
case ActionTypeRotateStopMember:
return ActionRotateStopMemberDefaultTimeout
case ActionTypeRuntimeContainerArgsLogLevelUpdate:
return ActionRuntimeContainerArgsLogLevelUpdateDefaultTimeout
case ActionTypeRuntimeContainerImageUpdate:
return ActionRuntimeContainerImageUpdateDefaultTimeout
case ActionTypeSetCondition:
return ActionSetConditionDefaultTimeout
case ActionTypeSetConditionV2:
return ActionSetConditionV2DefaultTimeout
case ActionTypeSetCurrentImage:
return ActionSetCurrentImageDefaultTimeout
case ActionTypeSetMaintenanceCondition:
return ActionSetMaintenanceConditionDefaultTimeout
case ActionTypeSetMemberCondition:
return ActionSetMemberConditionDefaultTimeout
case ActionTypeSetMemberConditionV2:
return ActionSetMemberConditionV2DefaultTimeout
case ActionTypeSetMemberCurrentImage:
return ActionSetMemberCurrentImageDefaultTimeout
case ActionTypeShutdownMember:
return ActionShutdownMemberDefaultTimeout
case ActionTypeTLSKeyStatusUpdate:
return ActionTLSKeyStatusUpdateDefaultTimeout
case ActionTypeTLSPropagated:
return ActionTLSPropagatedDefaultTimeout
case ActionTypeTimezoneSecretSet:
return ActionTimezoneSecretSetDefaultTimeout
case ActionTypeTopologyDisable:
return ActionTopologyDisableDefaultTimeout
case ActionTypeTopologyEnable:
return ActionTopologyEnableDefaultTimeout
case ActionTypeTopologyMemberAssignment:
return ActionTopologyMemberAssignmentDefaultTimeout
case ActionTypeTopologyZonesUpdate:
return ActionTopologyZonesUpdateDefaultTimeout
case ActionTypeUpToDateUpdate:
return ActionUpToDateUpdateDefaultTimeout
case ActionTypeUpdateTLSSNI:
return ActionUpdateTLSSNIDefaultTimeout
case ActionTypeUpgradeMember:
return ActionUpgradeMemberDefaultTimeout
case ActionTypeWaitForMemberInSync:
return ActionWaitForMemberInSyncDefaultTimeout
case ActionTypeWaitForMemberUp:
return ActionWaitForMemberUpDefaultTimeout
default:
return ActionsDefaultTimeout
}
}
func GetActionPriority(in ActionType) ActionPriority {
switch in {
case ActionTypeAddMember:
return ActionPriorityNormal
case ActionTypeAppendTLSCACertificate:
return ActionPriorityNormal
case ActionTypeArangoMemberUpdatePodSpec:
return ActionPriorityHigh
case ActionTypeArangoMemberUpdatePodStatus:
return ActionPriorityHigh
case ActionTypeBackupRestore:
return ActionPriorityNormal
case ActionTypeBackupRestoreClean:
return ActionPriorityNormal
case ActionTypeBootstrapSetPassword:
return ActionPriorityNormal
case ActionTypeBootstrapUpdate:
return ActionPriorityNormal
case ActionTypeCleanOutMember:
return ActionPriorityNormal
case ActionTypeCleanTLSCACertificate:
return ActionPriorityNormal
case ActionTypeCleanTLSKeyfileCertificate:
return ActionPriorityNormal
case ActionTypeClusterMemberCleanup:
return ActionPriorityNormal
case ActionTypeDisableClusterScaling:
return ActionPriorityNormal
case ActionTypeDisableMaintenance:
return ActionPriorityNormal
case ActionTypeDisableMemberMaintenance:
return ActionPriorityNormal
case ActionTypeEnableClusterScaling:
return ActionPriorityNormal
case ActionTypeEnableMaintenance:
return ActionPriorityNormal
case ActionTypeEnableMemberMaintenance:
return ActionPriorityNormal
case ActionTypeEncryptionKeyAdd:
return ActionPriorityNormal
case ActionTypeEncryptionKeyPropagated:
return ActionPriorityNormal
case ActionTypeEncryptionKeyRefresh:
return ActionPriorityNormal
case ActionTypeEncryptionKeyRemove:
return ActionPriorityNormal
case ActionTypeEncryptionKeyStatusUpdate:
return ActionPriorityNormal
case ActionTypeIdle:
return ActionPriorityNormal
case ActionTypeJWTAdd:
return ActionPriorityNormal
case ActionTypeJWTClean:
return ActionPriorityNormal
case ActionTypeJWTPropagated:
return ActionPriorityNormal
case ActionTypeJWTRefresh:
return ActionPriorityNormal
case ActionTypeJWTSetActive:
return ActionPriorityNormal
case ActionTypeJWTStatusUpdate:
return ActionPriorityNormal
case ActionTypeKillMemberPod:
return ActionPriorityNormal
case ActionTypeLicenseSet:
return ActionPriorityNormal
case ActionTypeMarkToRemoveMember:
return ActionPriorityNormal
case ActionTypeMemberPhaseUpdate:
return ActionPriorityHigh
case ActionTypeMemberRIDUpdate:
return ActionPriorityHigh
case ActionTypePVCResize:
return ActionPriorityNormal
case ActionTypePVCResized:
return ActionPriorityNormal
case ActionTypeRebalancerCheck:
return ActionPriorityNormal
case ActionTypeRebalancerClean:
return ActionPriorityNormal
case ActionTypeRebalancerGenerate:
return ActionPriorityNormal
case ActionTypeRecreateMember:
return ActionPriorityNormal
case ActionTypeRefreshTLSKeyfileCertificate:
return ActionPriorityNormal
case ActionTypeRemoveMember:
return ActionPriorityNormal
case ActionTypeRenewTLSCACertificate:
return ActionPriorityNormal
case ActionTypeRenewTLSCertificate:
return ActionPriorityNormal
case ActionTypeResignLeadership:
return ActionPriorityNormal
case ActionTypeResourceSync:
return ActionPriorityNormal
case ActionTypeRotateMember:
return ActionPriorityNormal
case ActionTypeRotateStartMember:
return ActionPriorityNormal
case ActionTypeRotateStopMember:
return ActionPriorityNormal
case ActionTypeRuntimeContainerArgsLogLevelUpdate:
return ActionPriorityNormal
case ActionTypeRuntimeContainerImageUpdate:
return ActionPriorityNormal
case ActionTypeSetCondition:
return ActionPriorityHigh
case ActionTypeSetConditionV2:
return ActionPriorityHigh
case ActionTypeSetCurrentImage:
return ActionPriorityNormal
case ActionTypeSetMaintenanceCondition:
return ActionPriorityNormal
case ActionTypeSetMemberCondition:
return ActionPriorityHigh
case ActionTypeSetMemberConditionV2:
return ActionPriorityHigh
case ActionTypeSetMemberCurrentImage:
return ActionPriorityNormal
case ActionTypeShutdownMember:
return ActionPriorityNormal
case ActionTypeTLSKeyStatusUpdate:
return ActionPriorityNormal
case ActionTypeTLSPropagated:
return ActionPriorityNormal
case ActionTypeTimezoneSecretSet:
return ActionPriorityNormal
case ActionTypeTopologyDisable:
return ActionPriorityNormal
case ActionTypeTopologyEnable:
return ActionPriorityNormal
case ActionTypeTopologyMemberAssignment:
return ActionPriorityNormal
case ActionTypeTopologyZonesUpdate:
return ActionPriorityNormal
case ActionTypeUpToDateUpdate:
return ActionPriorityNormal
case ActionTypeUpdateTLSSNI:
return ActionPriorityNormal
case ActionTypeUpgradeMember:
return ActionPriorityNormal
case ActionTypeWaitForMemberInSync:
return ActionPriorityNormal
case ActionTypeWaitForMemberUp:
return ActionPriorityNormal
default:
return ActionPriorityUnknown
}
}

View file

@ -21,6 +21,8 @@
package v1
import (
"time"
"github.com/dchest/uniuri"
"k8s.io/apimachinery/pkg/api/equality"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -34,10 +36,13 @@ import (
type ActionPriority int
const (
// ActionPriorityNormal define normal priority plan
// ActionPriorityNormal define Normal priority plan
ActionPriorityNormal ActionPriority = iota
// ActionPriorityHigh define high priority plan
// ActionPriorityHigh define High priority plan
ActionPriorityHigh
// ActionPriorityResource define Resource priority plan
ActionPriorityResource
ActionPriorityUnknown
)
// ActionType is a strongly typed name for a plan action item
@ -49,159 +54,12 @@ func (a ActionType) String() string {
// Priority returns plan priority
func (a ActionType) Priority() ActionPriority {
switch a {
case ActionTypeMemberPhaseUpdate, ActionTypeMemberRIDUpdate, ActionTypeSetMemberCondition, ActionTypeSetCondition, ActionTypeSetMemberConditionV2:
return ActionPriorityHigh
default:
return ActionPriorityNormal
}
return GetActionPriority(a)
}
const (
// ActionTypeIdle causes a plan to be recalculated.
ActionTypeIdle ActionType = "Idle"
// ActionTypeAddMember causes a member to be added.
ActionTypeAddMember ActionType = "AddMember"
// ActionTypeMarkToRemoveMember marks member to be removed.
ActionTypeMarkToRemoveMember ActionType = "MarkToRemoveMember"
// ActionTypeRemoveMember causes a member to be removed.
ActionTypeRemoveMember ActionType = "RemoveMember"
// ActionTypeRecreateMember recreates member. Used when member is still owner of some shards.
ActionTypeRecreateMember ActionType = "RecreateMember"
// ActionTypeCleanOutMember causes a member to be cleaned out (dbserver only).
ActionTypeCleanOutMember ActionType = "CleanOutMember"
// ActionTypeShutdownMember causes a member to be shutdown and removed from the cluster.
ActionTypeShutdownMember ActionType = "ShutdownMember"
// ActionTypeResignLeadership causes a member to resign leadership.
ActionTypeResignLeadership ActionType = "ResignLeadership"
// ActionTypeKillMemberPod causes a pod to get delete request. It also waits until Delay finalizer will be removed.
ActionTypeKillMemberPod ActionType = "KillMemberPod"
// ActionTypeRotateMember causes a member to be shutdown and have it's pod removed.
ActionTypeRotateMember ActionType = "RotateMember"
// ActionTypeRotateStartMember causes a member to be shutdown and have it's pod removed. Do not wait to pod recover.
ActionTypeRotateStartMember ActionType = "RotateStartMember"
// ActionTypeRotateStopMember causes a member to be restored.
ActionTypeRotateStopMember ActionType = "RotateStopMember"
// ActionTypeUpgradeMember causes a member to be shutdown and have it's pod removed, restarted with AutoUpgrade option, waited until termination and the restarted again.
ActionTypeUpgradeMember ActionType = "UpgradeMember"
// ActionTypeWaitForMemberUp causes the plan to wait until the member is considered "up".
ActionTypeWaitForMemberUp ActionType = "WaitForMemberUp"
// ActionTypeWaitForMemberInSync causes the plan to wait until members are considered "up" and cluster is healthy.
ActionTypeWaitForMemberInSync ActionType = "WaitForMemberInSync"
// ActionTypeRenewTLSCertificate causes the TLS certificate of a member to be renewed.
ActionTypeRenewTLSCertificate ActionType = "RenewTLSCertificate"
// ActionTypeRenewTLSCACertificate causes the TLS CA certificate of the entire deployment to be renewed.
ActionTypeRenewTLSCACertificate ActionType = "RenewTLSCACertificate"
// ActionTypeAppendTLSCACertificate add TLS CA certificate to local truststore.
ActionTypeAppendTLSCACertificate ActionType = "AppendTLSCACertificate"
// ActionTypeCleanTLSCACertificate clean TLS CA certificate from local truststore.
ActionTypeCleanTLSCACertificate ActionType = "CleanTLSCACertificate"
// ActionTypeCleanTLSKeyfileCertificate clean server keyfile
ActionTypeCleanTLSKeyfileCertificate ActionType = "CleanTLSKeyfileCertificate"
// ActionTypeRefreshTLSKeyfileCertificate refresh server keyfile using API
ActionTypeRefreshTLSKeyfileCertificate ActionType = "RefreshTLSKeyfileCertificate"
// ActionTypeTLSKeyStatusUpdate update status with current data from deployment
ActionTypeTLSKeyStatusUpdate ActionType = "TLSKeyStatusUpdate"
// ActionTypeTLSPropagated change propagated flag
ActionTypeTLSPropagated ActionType = "TLSPropagated"
// ActionTypeUpdateTLSSNI update SNI inplace.
ActionTypeUpdateTLSSNI ActionType = "UpdateTLSSNI"
// ActionTypeSetCurrentImage causes status.CurrentImage to be updated to the image given in the action.
ActionTypeSetCurrentImage ActionType = "SetCurrentImage"
// ActionTypeSetMemberCurrentImage replace image of member to current one.
ActionTypeSetMemberCurrentImage ActionType = "SetMemberCurrentImage"
// ActionTypeDisableClusterScaling turns off scaling DBservers and coordinators
ActionTypeDisableClusterScaling ActionType = "ScalingDisabled"
// ActionTypeEnableClusterScaling turns on scaling DBservers and coordinators
ActionTypeEnableClusterScaling ActionType = "ScalingEnabled"
// ActionTypePVCResize resize event for PVC
ActionTypePVCResize ActionType = "PVCResize"
// ActionTypePVCResized waits for PVC to resize for defined time
ActionTypePVCResized ActionType = "PVCResized"
// UpToDateUpdate define up to date annotation in spec
UpToDateUpdate ActionType = "UpToDateUpdate"
// ActionTypeBackupRestore restore plan
ActionTypeBackupRestore ActionType = "BackupRestore"
// ActionTypeBackupRestoreClean restore plan
ActionTypeBackupRestoreClean ActionType = "BackupRestoreClean"
// ActionTypeEncryptionKeyAdd add new encryption key to list
ActionTypeEncryptionKeyAdd ActionType = "EncryptionKeyAdd"
// ActionTypeEncryptionKeyRemove removes encryption key to list
ActionTypeEncryptionKeyRemove ActionType = "EncryptionKeyRemove"
// ActionTypeEncryptionKeyRefresh refresh encryption keys
ActionTypeEncryptionKeyRefresh ActionType = "EncryptionKeyRefresh"
// ActionTypeEncryptionKeyStatusUpdate update status object with current encryption keys
ActionTypeEncryptionKeyStatusUpdate ActionType = "EncryptionKeyStatusUpdate"
// ActionTypeEncryptionKeyPropagated change propagated flag
ActionTypeEncryptionKeyPropagated ActionType = "EncryptionKeyPropagated"
// ActionTypeJWTStatusUpdate update status of JWT Secret
ActionTypeJWTStatusUpdate ActionType = "JWTStatusUpdate"
// ActionTypeJWTSetActive change active JWT key
ActionTypeJWTSetActive ActionType = "JWTSetActive"
// ActionTypeJWTAdd add new JWT key
ActionTypeJWTAdd ActionType = "JWTAdd"
// ActionTypeJWTClean Clean old JWT key
ActionTypeJWTClean ActionType = "JWTClean"
// ActionTypeJWTRefresh refresh jwt tokens
ActionTypeJWTRefresh ActionType = "JWTRefresh"
// ActionTypeJWTPropagated change propagated flag
ActionTypeJWTPropagated ActionType = "JWTPropagated"
// ActionTypeClusterMemberCleanup removes member from cluster
ActionTypeClusterMemberCleanup ActionType = "ClusterMemberCleanup"
// ActionTypeEnableMaintenance enables maintenance on cluster.
ActionTypeEnableMaintenance ActionType = "EnableMaintenance"
// ActionTypeDisableMaintenance disables maintenance on cluster.
ActionTypeDisableMaintenance ActionType = "DisableMaintenance"
// ActionTypeSetMaintenanceCondition sets maintenance condition.
ActionTypeSetMaintenanceCondition ActionType = "SetMaintenanceCondition"
// ActionTypeEnableMemberMaintenance enables maintenance on cluster member.
ActionTypeEnableMemberMaintenance ActionType = "EnableMemberMaintenance"
// ActionTypeDisableMemberMaintenance disables maintenance on cluster member.
ActionTypeDisableMemberMaintenance ActionType = "DisableMemberMaintenance"
// ActionTypeBootstrapUpdate update bootstrap status to true
ActionTypeBootstrapUpdate ActionType = "BootstrapUpdate"
// ActionTypeBootstrapSetPassword set password to the bootstrapped user
ActionTypeBootstrapSetPassword ActionType = "BootstrapSetPassword"
// ActionTypeMemberPhaseUpdate updated member phase. High priority
ActionTypeMemberPhaseUpdate ActionType = "MemberPhaseUpdate"
// ActionTypeSetMemberCondition sets member condition. It is high priority action.
ActionTypeSetMemberCondition ActionType = "SetMemberCondition"
// ActionTypeSetMemberConditionV2 sets member condition. It is high priority action.
ActionTypeSetMemberConditionV2 ActionType = "SetMemberConditionV2"
// ActionTypeSetCondition sets condition. It is high priority action.
ActionTypeSetCondition ActionType = "SetCondition"
// ActionTypeSetConditionV2 sets condition. It is high priority action.
ActionTypeSetConditionV2 ActionType = "SetConditionV2"
// ActionTypeMemberRIDUpdate updated member Run ID (UID). High priority
ActionTypeMemberRIDUpdate ActionType = "MemberRIDUpdate"
// ActionTypeArangoMemberUpdatePodSpec updates pod spec
ActionTypeArangoMemberUpdatePodSpec ActionType = "ArangoMemberUpdatePodSpec"
// ActionTypeArangoMemberUpdatePodStatus updates pod spec
ActionTypeArangoMemberUpdatePodStatus ActionType = "ArangoMemberUpdatePodStatus"
// ActionTypeLicenseSet sets server license
ActionTypeLicenseSet ActionType = "LicenseSet"
// Runtime Updates
// ActionTypeRuntimeContainerImageUpdate updates container image in runtime
ActionTypeRuntimeContainerImageUpdate ActionType = "RuntimeContainerImageUpdate"
// ActionTypeRuntimeContainerArgsLogLevelUpdate updates the container's executor arguments.
ActionTypeRuntimeContainerArgsLogLevelUpdate ActionType = "RuntimeContainerArgsLogLevelUpdate"
// Topology
ActionTypeTopologyEnable ActionType = "TopologyEnable"
ActionTypeTopologyDisable ActionType = "TopologyDisable"
ActionTypeTopologyZonesUpdate ActionType = "TopologyZonesUpdate"
ActionTypeTopologyMemberAssignment ActionType = "TopologyMemberAssignment"
// Rebalancer
ActionTypeRebalancerGenerate ActionType = "RebalancerGenerate"
ActionTypeRebalancerCheck ActionType = "RebalancerCheck"
ActionTypeRebalancerClean ActionType = "RebalancerClean"
// Resources
ActionTypeResourceSync ActionType = "ResourceSync"
ActionTypeTimezoneSecretSet ActionType = "TimezoneSecretSet"
)
func (a ActionType) DefaultTimeout() time.Duration {
return ActionDefaultTimeout(a)
}
const (
// MemberIDPreviousAction is used for Action.MemberID when the MemberID

View file

@ -63,12 +63,42 @@ func (t *Timeouts) Get() Timeouts {
type ActionTimeouts map[ActionType]Timeout
const InfiniteTimeout time.Duration = 0
func NewInfiniteTimeout() Timeout {
return NewTimeout(InfiniteTimeout)
}
func NewTimeout(timeout time.Duration) Timeout {
return Timeout(meta.Duration{Duration: timeout})
}
type Timeout meta.Duration
func (t *Timeout) UnmarshalJSON(b []byte) error {
var d meta.Duration
if err := d.UnmarshalJSON(b); err != nil {
return err
}
*t = Timeout(d)
return nil
}
func (t Timeout) MarshalJSON() ([]byte, error) {
return meta.Duration(t).MarshalJSON()
}
func (t *Timeout) Infinite() bool {
if t == nil {
return false
}
return t.Duration == 0
}
func (t *Timeout) Get(d time.Duration) time.Duration {
if t == nil {
return d

View file

@ -0,0 +1,51 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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 v1
import (
"testing"
"time"
"github.com/stretchr/testify/require"
"sigs.k8s.io/yaml"
)
func Test_API_Timeouts(t *testing.T) {
d := `
spec:
timeouts:
actions:
CleanOutMember: 50h
`
var q ArangoDeployment
require.NoError(t, yaml.Unmarshal([]byte(d), &q))
require.EqualValues(t, q.Spec.Timeouts.Actions[ActionTypeCleanOutMember].Duration, time.Hour*50)
z, err := yaml.Marshal(q)
require.NoError(t, err)
require.NoError(t, yaml.Unmarshal(z, &q))
require.EqualValues(t, q.Spec.Timeouts.Actions[ActionTypeCleanOutMember].Duration, time.Hour*50)
}

View file

@ -63,12 +63,42 @@ func (t *Timeouts) Get() Timeouts {
type ActionTimeouts map[ActionType]Timeout
const InfiniteTimeout time.Duration = 0
func NewInfiniteTimeout() Timeout {
return NewTimeout(InfiniteTimeout)
}
func NewTimeout(timeout time.Duration) Timeout {
return Timeout(meta.Duration{Duration: timeout})
}
type Timeout meta.Duration
func (t *Timeout) UnmarshalJSON(b []byte) error {
var d meta.Duration
if err := d.UnmarshalJSON(b); err != nil {
return err
}
*t = Timeout(d)
return nil
}
func (t Timeout) MarshalJSON() ([]byte, error) {
return meta.Duration(t).MarshalJSON()
}
func (t *Timeout) Infinite() bool {
if t == nil {
return false
}
return t.Duration == 0
}
func (t *Timeout) Get(d time.Duration) time.Duration {
if t == nil {
return d

View file

@ -0,0 +1,51 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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 v2alpha1
import (
"testing"
"time"
"github.com/stretchr/testify/require"
"sigs.k8s.io/yaml"
)
func Test_API_Timeouts(t *testing.T) {
d := `
spec:
timeouts:
actions:
CleanOutMember: 50h
`
var q ArangoDeployment
require.NoError(t, yaml.Unmarshal([]byte(d), &q))
require.EqualValues(t, q.Spec.Timeouts.Actions[ActionTypeCleanOutMember].Duration, time.Hour*50)
z, err := yaml.Marshal(q)
require.NoError(t, err)
require.NoError(t, yaml.Unmarshal(z, &q))
require.EqualValues(t, q.Spec.Timeouts.Actions[ActionTypeCleanOutMember].Duration, time.Hour*50)
}

View file

@ -158,10 +158,9 @@ type actionFactory func(action api.Action, actionCtx ActionContext) Action
var (
definedActions = map[api.ActionType]actionFactory{}
definedActionsLock sync.Mutex
actionTimeouts = api.ActionTimeouts{}
)
func registerAction(t api.ActionType, f actionFactory, timeout time.Duration) {
func registerAction(t api.ActionType, f actionFactory) {
definedActionsLock.Lock()
defer definedActionsLock.Unlock()
@ -171,7 +170,6 @@ func registerAction(t api.ActionType, f actionFactory, timeout time.Duration) {
}
definedActions[t] = f
actionTimeouts[t] = api.NewTimeout(timeout)
}
func getActionFactory(t api.ActionType) (actionFactory, bool) {

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,349 @@
//
// Copyright 2016-2022 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 reconcile
import (
"testing"
"time"
"github.com/stretchr/testify/require"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func Test_Actions(t *testing.T) {
// Iterate over all actions
t.Run("AddMember", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeAddMember)
})
t.Run("AppendTLSCACertificate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeAppendTLSCACertificate)
})
t.Run("ArangoMemberUpdatePodSpec", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeArangoMemberUpdatePodSpec)
})
t.Run("ArangoMemberUpdatePodStatus", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeArangoMemberUpdatePodStatus)
})
t.Run("BackupRestore", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeBackupRestore)
})
t.Run("BackupRestoreClean", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeBackupRestoreClean)
})
t.Run("BootstrapSetPassword", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeBootstrapSetPassword)
})
t.Run("BootstrapUpdate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeBootstrapUpdate)
})
t.Run("CleanOutMember", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeCleanOutMember)
})
t.Run("CleanTLSCACertificate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeCleanTLSCACertificate)
})
t.Run("CleanTLSKeyfileCertificate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeCleanTLSKeyfileCertificate)
})
t.Run("ClusterMemberCleanup", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeClusterMemberCleanup)
})
t.Run("DisableClusterScaling", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeDisableClusterScaling)
})
t.Run("DisableMaintenance", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeDisableMaintenance)
})
t.Run("DisableMemberMaintenance", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeDisableMemberMaintenance)
})
t.Run("EnableClusterScaling", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeEnableClusterScaling)
})
t.Run("EnableMaintenance", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeEnableMaintenance)
})
t.Run("EnableMemberMaintenance", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeEnableMemberMaintenance)
})
t.Run("EncryptionKeyAdd", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeEncryptionKeyAdd)
})
t.Run("EncryptionKeyPropagated", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeEncryptionKeyPropagated)
})
t.Run("EncryptionKeyRefresh", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeEncryptionKeyRefresh)
})
t.Run("EncryptionKeyRemove", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeEncryptionKeyRemove)
})
t.Run("EncryptionKeyStatusUpdate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeEncryptionKeyStatusUpdate)
})
t.Run("Idle", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeIdle)
})
t.Run("JWTAdd", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeJWTAdd)
})
t.Run("JWTClean", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeJWTClean)
})
t.Run("JWTPropagated", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeJWTPropagated)
})
t.Run("JWTRefresh", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeJWTRefresh)
})
t.Run("JWTSetActive", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeJWTSetActive)
})
t.Run("JWTStatusUpdate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeJWTStatusUpdate)
})
t.Run("KillMemberPod", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeKillMemberPod)
})
t.Run("LicenseSet", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeLicenseSet)
})
t.Run("MarkToRemoveMember", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeMarkToRemoveMember)
})
t.Run("MemberPhaseUpdate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeMemberPhaseUpdate)
})
t.Run("MemberRIDUpdate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeMemberRIDUpdate)
})
t.Run("PVCResize", func(t *testing.T) {
ActionsExistence(t, api.ActionTypePVCResize)
})
t.Run("PVCResized", func(t *testing.T) {
ActionsExistence(t, api.ActionTypePVCResized)
})
t.Run("RebalancerCheck", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeRebalancerCheck)
})
t.Run("RebalancerClean", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeRebalancerClean)
})
t.Run("RebalancerGenerate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeRebalancerGenerate)
})
t.Run("RecreateMember", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeRecreateMember)
})
t.Run("RefreshTLSKeyfileCertificate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeRefreshTLSKeyfileCertificate)
})
t.Run("RemoveMember", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeRemoveMember)
})
t.Run("RenewTLSCACertificate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeRenewTLSCACertificate)
})
t.Run("RenewTLSCertificate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeRenewTLSCertificate)
})
t.Run("ResignLeadership", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeResignLeadership)
})
t.Run("ResourceSync", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeResourceSync)
})
t.Run("RotateMember", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeRotateMember)
ActionsWrapWithActionStartFailureGracePeriod(t, api.ActionTypeRotateMember, 60*time.Second)
})
t.Run("RotateStartMember", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeRotateStartMember)
ActionsWrapWithActionStartFailureGracePeriod(t, api.ActionTypeRotateStartMember, 60*time.Second)
})
t.Run("RotateStopMember", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeRotateStopMember)
})
t.Run("RuntimeContainerArgsLogLevelUpdate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeRuntimeContainerArgsLogLevelUpdate)
})
t.Run("RuntimeContainerImageUpdate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeRuntimeContainerImageUpdate)
})
t.Run("SetCondition", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeSetCondition)
})
t.Run("SetConditionV2", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeSetConditionV2)
})
t.Run("SetCurrentImage", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeSetCurrentImage)
})
t.Run("SetMaintenanceCondition", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeSetMaintenanceCondition)
})
t.Run("SetMemberCondition", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeSetMemberCondition)
})
t.Run("SetMemberConditionV2", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeSetMemberConditionV2)
})
t.Run("SetMemberCurrentImage", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeSetMemberCurrentImage)
})
t.Run("ShutdownMember", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeShutdownMember)
ActionsWrapWithActionStartFailureGracePeriod(t, api.ActionTypeShutdownMember, 60*time.Second)
})
t.Run("TLSKeyStatusUpdate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeTLSKeyStatusUpdate)
})
t.Run("TLSPropagated", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeTLSPropagated)
})
t.Run("TimezoneSecretSet", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeTimezoneSecretSet)
})
t.Run("TopologyDisable", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeTopologyDisable)
})
t.Run("TopologyEnable", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeTopologyEnable)
})
t.Run("TopologyMemberAssignment", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeTopologyMemberAssignment)
})
t.Run("TopologyZonesUpdate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeTopologyZonesUpdate)
})
t.Run("UpToDateUpdate", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeUpToDateUpdate)
})
t.Run("UpdateTLSSNI", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeUpdateTLSSNI)
})
t.Run("UpgradeMember", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeUpgradeMember)
})
t.Run("WaitForMemberInSync", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeWaitForMemberInSync)
})
t.Run("WaitForMemberUp", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeWaitForMemberUp)
})
}
func ActionsExistence(t *testing.T, action api.ActionType) {
t.Run("Existence", func(t *testing.T) {
_, ok := getActionFactory(action)
require.True(t, ok)
})
}
func ActionsWrapWithActionStartFailureGracePeriod(t *testing.T, action api.ActionType, timeout time.Duration) {
t.Run("WrapWithActionStartFailureGracePeriod", func(t *testing.T) {
f, ok := getActionFactory(action)
require.True(t, ok)
a := extractAction(f)
require.NotNil(t, a)
z, ok := a.(*actionStartFailureGracePeriod)
require.True(t, ok)
require.Equal(t, z.failureGracePeriod, timeout)
})
}
func extractAction(f actionFactory) Action {
return f(api.Action{}, nil)
}

View file

@ -29,10 +29,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func init() {
registerAction(api.ActionTypeAddMember, newAddMemberAction, addMemberTimeout)
}
// newAddMemberAction creates a new Action that implements the given
// planned AddMember action.
func newAddMemberAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -29,10 +29,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func init() {
registerAction(api.ActionTypeArangoMemberUpdatePodSpec, newArangoMemberUpdatePodSpecAction, defaultTimeout)
}
// newArangoMemberUpdatePodSpecAction creates a new Action that implements the given
// planned ArangoMemberUpdatePodSpec action.
func newArangoMemberUpdatePodSpecAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -27,10 +27,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func init() {
registerAction(api.ActionTypeArangoMemberUpdatePodStatus, newArangoMemberUpdatePodStatusAction, defaultTimeout)
}
const (
ActionTypeArangoMemberUpdatePodStatusChecksum = "checksum"
)

View file

@ -33,10 +33,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
)
func init() {
registerAction(api.ActionTypeBackupRestore, newBackupRestoreAction, backupRestoreTimeout)
}
const (
actionBackupRestoreLocalJobID api.PlanLocalKey = "jobID"
actionBackupRestoreLocalBackupName api.PlanLocalKey = "backupName"

View file

@ -26,10 +26,6 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeBackupRestoreClean, newBackupRestoreCleanAction, backupRestoreTimeout)
}
func newBackupRestoreCleanAction(action api.Action, actionCtx ActionContext) Action {
a := &actionBackupRestoreClean{}

View file

@ -34,10 +34,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeBootstrapSetPassword, newBootstrapSetPasswordAction, defaultTimeout)
}
func newBootstrapSetPasswordAction(action api.Action, actionCtx ActionContext) Action {
a := &actionBootstrapSetPassword{}

View file

@ -26,10 +26,6 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeBootstrapUpdate, newBootstrapUpdateAction, defaultTimeout)
}
func newBootstrapUpdateAction(action api.Action, actionCtx ActionContext) Action {
a := &actionBootstrapUpdate{}

View file

@ -31,22 +31,18 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
)
func init() {
registerAction(api.ActionTypeCleanOutMember, newCleanOutMemberAction, cleanoutMemberTimeout)
}
// newCleanOutMemberAction creates a new Action that implements the given
// planned CleanOutMember action.
func newCleanOutMemberAction(action api.Action, actionCtx ActionContext) Action {
a := &actionCleanoutMember{}
a := &actionCleanOutMember{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
// actionCleanoutMember implements an CleanOutMemberAction.
type actionCleanoutMember struct {
// actionCleanOutMember implements an CleanOutMemberAction.
type actionCleanOutMember struct {
// actionImpl implement timeout and member id functions
actionImpl
}
@ -54,7 +50,7 @@ type actionCleanoutMember struct {
// Start performs the start of the action.
// Returns true if the action is completely finished, false in case
// the start time needs to be recorded and a ready condition needs to be checked.
func (a *actionCleanoutMember) Start(ctx context.Context) (bool, error) {
func (a *actionCleanOutMember) Start(ctx context.Context) (bool, error) {
if a.action.Group != api.ServerGroupDBServers {
// Proceed only on DBServers
return true, nil
@ -104,7 +100,7 @@ func (a *actionCleanoutMember) Start(ctx context.Context) (bool, error) {
// CheckProgress checks the progress of the action.
// Returns: ready, abort, error.
func (a *actionCleanoutMember) CheckProgress(ctx context.Context) (bool, bool, error) {
func (a *actionCleanOutMember) CheckProgress(ctx context.Context) (bool, bool, error) {
m, ok := a.actionCtx.GetMemberStatusByID(a.action.MemberID)
if !ok {
// We wanted to remove and it is already gone. All ok

View file

@ -29,10 +29,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
)
func init() {
registerAction(api.ActionTypeClusterMemberCleanup, newClusterMemberCleanupAction, addMemberTimeout)
}
// newClusterMemberCleanupAction creates a new Action that implements the given
// planned ClusterMemberCleanup action.
func newClusterMemberCleanupAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -27,21 +27,17 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util"
)
func init() {
registerAction(api.ActionTypeDisableClusterScaling, newDisableScalingCluster, 0)
}
// newDisableScalingCluster creates the new action with disabling scaling DBservers and coordinators.
func newDisableScalingCluster(action api.Action, actionCtx ActionContext) Action {
a := &actionDisableScalingCluster{}
// newDisableClusterScalingAction creates the new action with disabling scaling DBservers and coordinators.
func newDisableClusterScalingAction(action api.Action, actionCtx ActionContext) Action {
a := &actionDisableClusterScaling{}
a.actionImpl = newActionImpl(action, actionCtx, util.NewString(""))
return a
}
// actionDisableScalingCluster implements disabling scaling DBservers and coordinators.
type actionDisableScalingCluster struct {
// actionDisableClusterScaling implements disabling scaling DBservers and coordinators.
type actionDisableClusterScaling struct {
// actionImpl implement timeout and member id functions
actionImpl
@ -50,7 +46,7 @@ type actionDisableScalingCluster struct {
}
// Start disables scaling DBservers and coordinators
func (a *actionDisableScalingCluster) Start(ctx context.Context) (bool, error) {
func (a *actionDisableClusterScaling) Start(ctx context.Context) (bool, error) {
err := a.actionCtx.DisableScalingCluster(ctx)
if err != nil {
return false, err

View file

@ -27,21 +27,17 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util"
)
func init() {
registerAction(api.ActionTypeEnableClusterScaling, newEnableScalingCluster, 0)
}
// newEnableScalingCluster creates the new action with enabling scaling DBservers and coordinators.
func newEnableScalingCluster(action api.Action, actionCtx ActionContext) Action {
a := &actionEnableScalingCluster{}
// newEnableClusterScalingAction creates the new action with enabling scaling DBservers and coordinators.
func newEnableClusterScalingAction(action api.Action, actionCtx ActionContext) Action {
a := &actionEnableClusterScaling{}
a.actionImpl = newActionImpl(action, actionCtx, util.NewString(""))
return a
}
// actionEnableScalingCluster implements enabling scaling DBservers and coordinators.
type actionEnableScalingCluster struct {
// actionEnableClusterScaling implements enabling scaling DBservers and coordinators.
type actionEnableClusterScaling struct {
// actionImpl implement timeout and member id functions
actionImpl
@ -50,7 +46,7 @@ type actionEnableScalingCluster struct {
}
// Start enables scaling DBservers and coordinators
func (a *actionEnableScalingCluster) Start(ctx context.Context) (bool, error) {
func (a *actionEnableClusterScaling) Start(ctx context.Context) (bool, error) {
err := a.actionCtx.EnableScalingCluster(ctx)
if err != nil {
return false, err

View file

@ -50,25 +50,21 @@ func ensureEncryptionSupport(actionCtx ActionContext) error {
return nil
}
func init() {
registerAction(api.ActionTypeEncryptionKeyAdd, newEncryptionKeyAdd, defaultTimeout)
}
func newEncryptionKeyAdd(action api.Action, actionCtx ActionContext) Action {
a := &encryptionKeyAddAction{}
func newEncryptionKeyAddAction(action api.Action, actionCtx ActionContext) Action {
a := &actionEncryptionKeyAdd{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type encryptionKeyAddAction struct {
type actionEncryptionKeyAdd struct {
actionImpl
actionEmptyCheckProgress
}
func (a *encryptionKeyAddAction) Start(ctx context.Context) (bool, error) {
func (a *actionEncryptionKeyAdd) Start(ctx context.Context) (bool, error) {
if err := ensureEncryptionSupport(a.actionCtx); err != nil {
a.log.Err(err).Error("Action not supported")
return true, nil

View file

@ -26,25 +26,21 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeEncryptionKeyPropagated, newEncryptionKeyPropagated, defaultTimeout)
}
func newEncryptionKeyPropagated(action api.Action, actionCtx ActionContext) Action {
a := &encryptionKeyPropagatedAction{}
func newEncryptionKeyPropagatedAction(action api.Action, actionCtx ActionContext) Action {
a := &actionEncryptionKeyPropagated{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type encryptionKeyPropagatedAction struct {
type actionEncryptionKeyPropagated struct {
actionImpl
actionEmptyCheckProgress
}
func (a *encryptionKeyPropagatedAction) Start(ctx context.Context) (bool, error) {
func (a *actionEncryptionKeyPropagated) Start(ctx context.Context) (bool, error) {
propagatedFlag, exists := a.action.Params[propagated]
if !exists {
a.log.Error("Propagated flag is missing")

View file

@ -31,28 +31,24 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
)
func init() {
registerAction(api.ActionTypeEncryptionKeyRefresh, newEncryptionKeyRefresh, defaultTimeout)
}
func newEncryptionKeyRefresh(action api.Action, actionCtx ActionContext) Action {
a := &encryptionKeyRefreshAction{}
func newEncryptionKeyRefreshAction(action api.Action, actionCtx ActionContext) Action {
a := &actionEncryptionKeyRefresh{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type encryptionKeyRefreshAction struct {
type actionEncryptionKeyRefresh struct {
actionImpl
}
func (a *encryptionKeyRefreshAction) Start(ctx context.Context) (bool, error) {
func (a *actionEncryptionKeyRefresh) Start(ctx context.Context) (bool, error) {
ready, _, err := a.CheckProgress(ctx)
return ready, err
}
func (a *encryptionKeyRefreshAction) CheckProgress(ctx context.Context) (bool, bool, error) {
func (a *actionEncryptionKeyRefresh) CheckProgress(ctx context.Context) (bool, bool, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
keyFolder, err := a.actionCtx.ACS().CurrentClusterCache().Secret().V1().Read().Get(ctxChild,

View file

@ -34,25 +34,21 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeEncryptionKeyRemove, newEncryptionKeyRemove, defaultTimeout)
}
func newEncryptionKeyRemove(action api.Action, actionCtx ActionContext) Action {
a := &encryptionKeyRemoveAction{}
func newEncryptionKeyRemoveAction(action api.Action, actionCtx ActionContext) Action {
a := &actionEncryptionKeyRemove{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type encryptionKeyRemoveAction struct {
type actionEncryptionKeyRemove struct {
actionImpl
actionEmptyCheckProgress
}
func (a *encryptionKeyRemoveAction) Start(ctx context.Context) (bool, error) {
func (a *actionEncryptionKeyRemove) Start(ctx context.Context) (bool, error) {
if err := ensureEncryptionSupport(a.actionCtx); err != nil {
a.log.Err(err).Error("Action not supported")
return true, nil

View file

@ -31,25 +31,21 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
)
func init() {
registerAction(api.ActionTypeEncryptionKeyStatusUpdate, newEncryptionKeyStatusUpdate, defaultTimeout)
}
func newEncryptionKeyStatusUpdate(action api.Action, actionCtx ActionContext) Action {
a := &encryptionKeyStatusUpdateAction{}
func newEncryptionKeyStatusUpdateAction(action api.Action, actionCtx ActionContext) Action {
a := &actionEncryptionKeyStatusUpdate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type encryptionKeyStatusUpdateAction struct {
type actionEncryptionKeyStatusUpdate struct {
actionImpl
actionEmptyCheckProgress
}
func (a *encryptionKeyStatusUpdateAction) Start(ctx context.Context) (bool, error) {
func (a *actionEncryptionKeyStatusUpdate) Start(ctx context.Context) (bool, error) {
if err := ensureEncryptionSupport(a.actionCtx); err != nil {
a.log.Err(err).Error("Action not supported")
return true, nil

View file

@ -26,10 +26,6 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeIdle, newIdleAction, addMemberTimeout)
}
// newIdleAction creates a new Action that implements the given
// planned Idle action.
func newIdleAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -37,25 +37,21 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeJWTAdd, newJWTAdd, defaultTimeout)
}
func newJWTAdd(action api.Action, actionCtx ActionContext) Action {
a := &jwtAddAction{}
func newJWTAddAction(action api.Action, actionCtx ActionContext) Action {
a := &actionJWTAdd{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type jwtAddAction struct {
type actionJWTAdd struct {
actionImpl
actionEmptyCheckProgress
}
func (a *jwtAddAction) Start(ctx context.Context) (bool, error) {
func (a *actionJWTAdd) Start(ctx context.Context) (bool, error) {
folder, err := ensureJWTFolderSupportFromAction(a.actionCtx)
if err != nil {
a.log.Err(err).Error("Action not supported")

View file

@ -35,25 +35,21 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeJWTClean, newJWTClean, defaultTimeout)
}
func newJWTClean(action api.Action, actionCtx ActionContext) Action {
a := &jwtCleanAction{}
func newJWTCleanAction(action api.Action, actionCtx ActionContext) Action {
a := &actionJWTClean{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type jwtCleanAction struct {
type actionJWTClean struct {
actionImpl
actionEmptyCheckProgress
}
func (a *jwtCleanAction) Start(ctx context.Context) (bool, error) {
func (a *actionJWTClean) Start(ctx context.Context) (bool, error) {
folder, err := ensureJWTFolderSupportFromAction(a.actionCtx)
if err != nil {
a.log.Err(err).Error("Action not supported")

View file

@ -26,25 +26,21 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeJWTPropagated, newJWTPropagated, defaultTimeout)
}
func newJWTPropagated(action api.Action, actionCtx ActionContext) Action {
a := &jwtPropagatedAction{}
func newJWTPropagatedAction(action api.Action, actionCtx ActionContext) Action {
a := &actionJWTPropagated{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type jwtPropagatedAction struct {
type actionJWTPropagated struct {
actionImpl
actionEmptyCheckProgress
}
func (a *jwtPropagatedAction) Start(ctx context.Context) (bool, error) {
func (a *actionJWTPropagated) Start(ctx context.Context) (bool, error) {
_, err := ensureJWTFolderSupportFromAction(a.actionCtx)
if err != nil {
a.log.Err(err).Error("Action not supported")

View file

@ -29,23 +29,19 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
)
func init() {
registerAction(api.ActionTypeJWTRefresh, newJWTRefresh, defaultTimeout)
}
func newJWTRefresh(action api.Action, actionCtx ActionContext) Action {
a := &jwtRefreshAction{}
func newJWTRefreshAction(action api.Action, actionCtx ActionContext) Action {
a := &actionJWTRefresh{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type jwtRefreshAction struct {
type actionJWTRefresh struct {
actionImpl
}
func (a *jwtRefreshAction) CheckProgress(ctx context.Context) (bool, bool, error) {
func (a *actionJWTRefresh) CheckProgress(ctx context.Context) (bool, bool, error) {
if folder, err := ensureJWTFolderSupport(a.actionCtx.GetSpec(), a.actionCtx.GetStatus()); err != nil || !folder {
return true, false, nil
}
@ -73,7 +69,7 @@ func (a *jwtRefreshAction) CheckProgress(ctx context.Context) (bool, bool, error
return true, false, nil
}
func (a *jwtRefreshAction) Start(ctx context.Context) (bool, error) {
func (a *actionJWTRefresh) Start(ctx context.Context) (bool, error) {
ready, _, err := a.CheckProgress(ctx)
return ready, err
}

View file

@ -37,25 +37,21 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeJWTSetActive, newJWTSetActive, defaultTimeout)
}
func newJWTSetActive(action api.Action, actionCtx ActionContext) Action {
a := &jwtSetActiveAction{}
func newJWTSetActiveAction(action api.Action, actionCtx ActionContext) Action {
a := &actionJWTSetActive{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type jwtSetActiveAction struct {
type actionJWTSetActive struct {
actionImpl
actionEmptyCheckProgress
}
func (a *jwtSetActiveAction) Start(ctx context.Context) (bool, error) {
func (a *actionJWTSetActive) Start(ctx context.Context) (bool, error) {
folder, err := ensureJWTFolderSupportFromAction(a.actionCtx)
if err != nil {
a.log.Err(err).Error("Action not supported")

View file

@ -60,25 +60,21 @@ func ensureJWTFolderSupport(spec api.DeploymentSpec, status api.DeploymentStatus
return true, nil
}
func init() {
registerAction(api.ActionTypeJWTStatusUpdate, newJWTStatusUpdate, defaultTimeout)
}
func newJWTStatusUpdate(action api.Action, actionCtx ActionContext) Action {
a := &jwtStatusUpdateAction{}
func newJWTStatusUpdateAction(action api.Action, actionCtx ActionContext) Action {
a := &actionJWTStatusUpdate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type jwtStatusUpdateAction struct {
type actionJWTStatusUpdate struct {
actionImpl
actionEmptyCheckProgress
}
func (a *jwtStatusUpdateAction) Start(ctx context.Context) (bool, error) {
func (a *actionJWTStatusUpdate) Start(ctx context.Context) (bool, error) {
folder, err := ensureJWTFolderSupportFromAction(a.actionCtx)
if err != nil {
a.log.Err(err).Error("Action not supported")

View file

@ -32,10 +32,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func init() {
registerAction(api.ActionTypeKillMemberPod, newKillMemberPodAction, defaultTimeout)
}
// newKillMemberPodAction creates a new Action that implements the given
// planned KillMemberPod action.
func newKillMemberPodAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -24,10 +24,6 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeSetMaintenanceCondition, newSetMaintenanceConditionAction, addMemberTimeout)
}
func newSetMaintenanceConditionAction(action api.Action, actionCtx ActionContext) Action {
a := &actionSetMaintenanceCondition{}

View file

@ -26,10 +26,6 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeDisableMaintenance, newDisableMaintenanceAction, addMemberTimeout)
}
func newDisableMaintenanceAction(action api.Action, actionCtx ActionContext) Action {
a := &actionDisableMaintenance{}

View file

@ -26,10 +26,6 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeEnableMaintenance, newEnableMaintenanceAction, addMemberTimeout)
}
func newEnableMaintenanceAction(action api.Action, actionCtx ActionContext) Action {
a := &actionEnableMaintenance{}

View file

@ -26,19 +26,15 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeMarkToRemoveMember, newMarkToRemoveMemberAction, addMemberTimeout)
}
func newMarkToRemoveMemberAction(action api.Action, actionCtx ActionContext) Action {
a := &actionMarkToRemove{}
a := &actionMarkToRemoveMember{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type actionMarkToRemove struct {
type actionMarkToRemoveMember struct {
// actionImpl implement timeout and member id functions
actionImpl
@ -46,7 +42,7 @@ type actionMarkToRemove struct {
actionEmptyCheckProgress
}
func (a *actionMarkToRemove) Start(ctx context.Context) (bool, error) {
func (a *actionMarkToRemoveMember) Start(ctx context.Context) (bool, error) {
if a.action.Group != api.ServerGroupDBServers && a.action.Group != api.ServerGroupAgents && a.action.Group != api.ServerGroupCoordinators {
return true, nil
}

View file

@ -24,10 +24,6 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeDisableMemberMaintenance, newDisableMemberMaintenanceAction, defaultTimeout)
}
func newDisableMemberMaintenanceAction(action api.Action, actionCtx ActionContext) Action {
a := &actionDisableMemberMaintenance{}

View file

@ -24,10 +24,6 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeEnableMemberMaintenance, newEnableMemberMaintenanceAction, defaultTimeout)
}
func newEnableMemberMaintenanceAction(action api.Action, actionCtx ActionContext) Action {
a := &actionEnableMemberMaintenance{}

View file

@ -28,29 +28,25 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func init() {
registerAction(api.ActionTypeMemberPhaseUpdate, newMemberPhaseUpdate, defaultTimeout)
}
const (
actionTypeMemberPhaseUpdatePhaseKey string = "phase"
)
func newMemberPhaseUpdate(action api.Action, actionCtx ActionContext) Action {
a := &memberPhaseUpdateAction{}
func newMemberPhaseUpdateAction(action api.Action, actionCtx ActionContext) Action {
a := &actionMemberPhaseUpdate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type memberPhaseUpdateAction struct {
type actionMemberPhaseUpdate struct {
actionImpl
actionEmptyCheckProgress
}
func (a *memberPhaseUpdateAction) Start(ctx context.Context) (bool, error) {
func (a *actionMemberPhaseUpdate) Start(ctx context.Context) (bool, error) {
m, ok := a.actionCtx.GetMemberStatusByID(a.action.MemberID)
if !ok {
a.log.Error("No such member")

View file

@ -24,18 +24,14 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeMemberRIDUpdate, newMemberRIDUpdate, defaultTimeout)
}
func newMemberRIDUpdate(action api.Action, actionCtx ActionContext) Action {
a := &memberRIDUpdateAction{}
func newMemberRIDUpdateAction(action api.Action, actionCtx ActionContext) Action {
a := &actionMemberRIDUpdate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type memberRIDUpdateAction struct {
type actionMemberRIDUpdate struct {
actionEmpty
}

View file

@ -32,10 +32,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypePVCResize, newPVCResizeAction, pvcResizeTimeout)
}
// newRotateMemberAction creates a new Action that implements the given
// planned RotateMember action.
func newPVCResizeAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -29,10 +29,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypePVCResized, newPVCResizedAction, pvcResizedTimeout)
}
// newRotateMemberAction creates a new Action that implements the given
// planned RotateMember action.
func newPVCResizedAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -0,0 +1,26 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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
//go:build !enterprise
// +build !enterprise
package reconcile
type actionRebalancerCheck struct {
actionEmpty
}

View file

@ -0,0 +1,31 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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 reconcile
import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
func newRebalancerCheckAction(action api.Action, actionCtx ActionContext) Action {
a := &actionRebalancerCheck{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}

View file

@ -0,0 +1,26 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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
//go:build !enterprise
// +build !enterprise
package reconcile
type actionRebalancerClean struct {
actionEmpty
}

View file

@ -0,0 +1,31 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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 reconcile
import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
func newRebalancerCleanAction(action api.Action, actionCtx ActionContext) Action {
a := &actionRebalancerClean{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}

View file

@ -0,0 +1,26 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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
//go:build !enterprise
// +build !enterprise
package reconcile
type actionRebalancerGenerate struct {
actionEmpty
}

View file

@ -0,0 +1,31 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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 reconcile
import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
func newRebalancerGenerateAction(action api.Action, actionCtx ActionContext) Action {
a := &actionRebalancerGenerate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}

View file

@ -27,10 +27,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func init() {
registerAction(api.ActionTypeRecreateMember, newRecreateMemberAction, recreateMemberTimeout)
}
// newRecreateMemberAction creates a new Action that implements the given
// planned RecreateMember action.
func newRecreateMemberAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -34,10 +34,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
)
func init() {
registerAction(api.ActionTypeRemoveMember, newRemoveMemberAction, removeMemberTimeout)
}
// newRemoveMemberAction creates a new Action that implements the given
// planned RemoveMember action.
func newRemoveMemberAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -0,0 +1,35 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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 reconcile
import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
func newRenewTLSCertificateAction(action api.Action, actionCtx ActionContext) Action {
a := &actionRenewTLSCertificate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type actionRenewTLSCertificate struct {
actionEmpty
}

View file

@ -31,10 +31,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
)
func init() {
registerAction(api.ActionTypeResignLeadership, newResignLeadershipAction, shutdownMemberTimeout)
}
// newResignLeadershipAction creates a new Action that implements the given
// planned ResignLeadership action.
func newResignLeadershipAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -0,0 +1,35 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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 reconcile
import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
func newResourceSyncAction(action api.Action, actionCtx ActionContext) Action {
a := &actionResourceSync{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type actionResourceSync struct {
actionEmpty
}

View file

@ -22,7 +22,6 @@ package reconcile
import (
"context"
"time"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -32,10 +31,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeRotateMember, withActionStartFailureGracePeriod(newRotateMemberAction, time.Minute), rotateMemberTimeout)
}
// newRotateMemberAction creates a new Action that implements the given
// planned RotateMember action.
func newRotateMemberAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -22,7 +22,6 @@ package reconcile
import (
"context"
"time"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -31,10 +30,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeRotateStartMember, withActionStartFailureGracePeriod(newRotateStartMemberAction, time.Minute), rotateMemberTimeout)
}
// newRotateStartMemberAction creates a new Action that implements the given
// planned RotateStartMember action.
func newRotateStartMemberAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -27,10 +27,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func init() {
registerAction(api.ActionTypeRotateStopMember, newRotateStopMemberAction, rotateMemberTimeout)
}
// newRotateStopMemberAction creates a new Action that implements the given
// planned RotateStopMember action.
func newRotateStopMemberAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -35,27 +35,23 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
)
func init() {
registerAction(api.ActionTypeRuntimeContainerArgsLogLevelUpdate, runtimeContainerArgsUpdate, defaultTimeout)
}
func runtimeContainerArgsUpdate(action api.Action, actionCtx ActionContext) Action {
a := &actionRuntimeContainerArgsUpdate{}
func newRuntimeContainerArgsLogLevelUpdateAction(action api.Action, actionCtx ActionContext) Action {
a := &actionRuntimeContainerArgsLogLevelUpdate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
var _ ActionPost = &actionRuntimeContainerArgsUpdate{}
var _ ActionPost = &actionRuntimeContainerArgsLogLevelUpdate{}
type actionRuntimeContainerArgsUpdate struct {
type actionRuntimeContainerArgsLogLevelUpdate struct {
// actionImpl implement timeout and member id functions
actionImpl
}
// Post updates arguments for the specific Arango member.
func (a actionRuntimeContainerArgsUpdate) Post(ctx context.Context) error {
func (a actionRuntimeContainerArgsLogLevelUpdate) Post(ctx context.Context) error {
m, ok := a.actionCtx.GetMemberStatusByID(a.action.MemberID)
if !ok {
a.log.Info("member is gone already")
@ -118,14 +114,14 @@ func (a actionRuntimeContainerArgsUpdate) Post(ctx context.Context) error {
return nil
}
func (a *actionRuntimeContainerArgsUpdate) ReloadComponents() []throttle.Component {
func (a *actionRuntimeContainerArgsLogLevelUpdate) ReloadComponents() []throttle.Component {
return []throttle.Component{
throttle.Pod,
}
}
// Start starts the action for changing conditions on the provided member.
func (a actionRuntimeContainerArgsUpdate) Start(ctx context.Context) (bool, error) {
func (a actionRuntimeContainerArgsLogLevelUpdate) Start(ctx context.Context) (bool, error) {
m, ok := a.actionCtx.GetMemberStatusByID(a.action.MemberID)
if !ok {
a.log.Info("member is gone already")
@ -238,12 +234,12 @@ func validateMemberAndPod(member *api.ArangoMember, pod *core.Pod) (*core.PodTem
}
// CheckProgress returns always true because it does not have to wait for any result.
func (a actionRuntimeContainerArgsUpdate) CheckProgress(_ context.Context) (bool, bool, error) {
func (a actionRuntimeContainerArgsLogLevelUpdate) CheckProgress(_ context.Context) (bool, bool, error) {
return true, false, nil
}
// setLogLevel sets the log's levels for the specific server.
func (a actionRuntimeContainerArgsUpdate) setLogLevel(ctx context.Context, logLevels map[string]string) error {
func (a actionRuntimeContainerArgsLogLevelUpdate) setLogLevel(ctx context.Context, logLevels map[string]string) error {
if len(logLevels) == 0 {
return nil
}

View file

@ -33,11 +33,7 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeRuntimeContainerImageUpdate, runtimeContainerImageUpdate, defaultTimeout)
}
func runtimeContainerImageUpdate(action api.Action, actionCtx ActionContext) Action {
func newRuntimeContainerImageUpdateAction(action api.Action, actionCtx ActionContext) Action {
a := &actionRuntimeContainerImageUpdate{}
a.actionImpl = newBaseActionImplDefRef(action, actionCtx)

View file

@ -27,11 +27,7 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeSetCondition, setCondition, defaultTimeout)
}
func setCondition(action api.Action, actionCtx ActionContext) Action {
func newSetConditionAction(action api.Action, actionCtx ActionContext) Action {
a := &actionSetCondition{}
a.actionImpl = newActionImplDefRef(action, actionCtx)

View file

@ -28,10 +28,6 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeSetConditionV2, setConditionV2, defaultTimeout)
}
const (
setConditionActionV2KeyTypeAdd string = "add"
setConditionActionV2KeyTypeRemove string = "remove"
@ -44,7 +40,7 @@ const (
setConditionActionV2KeyHash string = "hash"
)
func setConditionV2(action api.Action, actionCtx ActionContext) Action {
func newSetConditionV2Action(action api.Action, actionCtx ActionContext) Action {
a := &actionSetConditionV2{}
a.actionImpl = newActionImplDefRef(action, actionCtx)

View file

@ -27,22 +27,18 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func init() {
registerAction(api.ActionTypeSetMemberCurrentImage, newSetCurrentMemberImageAction, upgradeMemberTimeout)
}
// newSetCurrentImageAction creates a new Action that implements the given
// planned SetCurrentImage action.
func newSetCurrentMemberImageAction(action api.Action, actionCtx ActionContext) Action {
a := &setCurrentMemberImageAction{}
func newSetMemberCurrentImageAction(action api.Action, actionCtx ActionContext) Action {
a := &actionSetMemberCurrentImage{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
// setCurrentImageAction implements an SetCurrentImage.
type setCurrentMemberImageAction struct {
// actionSetMemberCurrentImage implements an SetCurrentImage.
type actionSetMemberCurrentImage struct {
// actionImpl implement timeout and member id functions
actionImpl
}
@ -50,7 +46,7 @@ type setCurrentMemberImageAction struct {
// Start performs the start of the action.
// Returns true if the action is completely finished, false in case
// the start time needs to be recorded and a ready condition needs to be checked.
func (a *setCurrentMemberImageAction) Start(ctx context.Context) (bool, error) {
func (a *actionSetMemberCurrentImage) Start(ctx context.Context) (bool, error) {
ready, _, err := a.CheckProgress(ctx)
if err != nil {
return false, errors.WithStack(err)
@ -60,7 +56,7 @@ func (a *setCurrentMemberImageAction) Start(ctx context.Context) (bool, error) {
// CheckProgress checks the progress of the action.
// Returns true if the action is completely finished, false otherwise.
func (a *setCurrentMemberImageAction) CheckProgress(ctx context.Context) (bool, bool, error) {
func (a *actionSetMemberCurrentImage) CheckProgress(ctx context.Context) (bool, bool, error) {
imageInfo, found := a.actionCtx.GetImageInfo(a.action.Image)
if !found {
a.log.Info("Image not found")

View file

@ -29,25 +29,21 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeLicenseSet, newLicenseSet, defaultTimeout)
}
func newLicenseSet(action api.Action, actionCtx ActionContext) Action {
a := &licenseSetAction{}
func newLicenseSetAction(action api.Action, actionCtx ActionContext) Action {
a := &actionLicenseSet{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type licenseSetAction struct {
type actionLicenseSet struct {
actionImpl
actionEmptyCheckProgress
}
func (a *licenseSetAction) Start(ctx context.Context) (bool, error) {
func (a *actionLicenseSet) Start(ctx context.Context) (bool, error) {
ctxChild, cancel := globals.GetGlobals().Timeouts().ArangoD().WithTimeout(ctx)
defer cancel()
spec := a.actionCtx.GetSpec()

View file

@ -28,11 +28,7 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func init() {
registerAction(api.ActionTypeSetMemberCondition, setMemberCondition, defaultTimeout)
}
func setMemberCondition(action api.Action, actionCtx ActionContext) Action {
func newSetMemberConditionAction(action api.Action, actionCtx ActionContext) Action {
a := &actionSetMemberCondition{}
a.actionImpl = newActionImplDefRef(action, actionCtx)

View file

@ -28,11 +28,7 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeSetMemberConditionV2, setMemberConditionV2, defaultTimeout)
}
func setMemberConditionV2(action api.Action, actionCtx ActionContext) Action {
func newSetMemberConditionV2Action(action api.Action, actionCtx ActionContext) Action {
a := &actionSetMemberConditionV2{}
a.actionImpl = newActionImplDefRef(action, actionCtx)

View file

@ -22,16 +22,11 @@ package reconcile
import (
"context"
"time"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func init() {
registerAction(api.ActionTypeShutdownMember, withActionStartFailureGracePeriod(newShutdownMemberAction, time.Minute), shutdownMemberTimeout)
}
// newShutdownMemberAction creates a new Action that implements the given
// planned ShutdownMember action.
func newShutdownMemberAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -21,33 +21,15 @@
package reconcile
import (
"time"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func GetActionTimeout(spec api.DeploymentSpec, t api.ActionType) time.Duration {
if d, ok := getActionTimeout(spec, t); ok {
return d
}
if d, ok := getActionTimeout(spec, "default"); ok {
return d
}
return defaultTimeout
}
func getActionTimeout(spec api.DeploymentSpec, t api.ActionType) (time.Duration, bool) {
func GetActionTimeout(spec api.DeploymentSpec, t api.ActionType) api.Timeout {
if timeouts := spec.Timeouts; timeouts != nil {
if d, ok := timeouts.Actions[t]; ok {
return d.Duration, true
return d
}
}
if d, ok := actionTimeouts[t]; ok {
return d.Duration, true
}
return 0, false
return api.Timeout{Duration: api.ActionDefaultTimeout(t)}
}

View file

@ -37,25 +37,21 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeTimezoneSecretSet, newTimezoneCMSetAction, operationTLSCACertificateTimeout)
}
func newTimezoneCMSetAction(action api.Action, actionCtx ActionContext) Action {
a := &timezoneCMSetAction{}
func newTimezoneSecretSetAction(action api.Action, actionCtx ActionContext) Action {
a := &actionTimezoneSecretSet{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type timezoneCMSetAction struct {
type actionTimezoneSecretSet struct {
actionImpl
actionEmptyCheckProgress
}
func (a *timezoneCMSetAction) Start(ctx context.Context) (bool, error) {
func (a *actionTimezoneSecretSet) Start(ctx context.Context) (bool, error) {
if !features.Timezone().Enabled() {
return true, nil
}

View file

@ -36,25 +36,21 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeAppendTLSCACertificate, newAppendTLSCACertificateAction, operationTLSCACertificateTimeout)
}
func newAppendTLSCACertificateAction(action api.Action, actionCtx ActionContext) Action {
a := &appendTLSCACertificateAction{}
a := &actionAppendTLSCACertificate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type appendTLSCACertificateAction struct {
type actionAppendTLSCACertificate struct {
actionImpl
actionEmptyCheckProgress
}
func (a *appendTLSCACertificateAction) Start(ctx context.Context) (bool, error) {
func (a *actionAppendTLSCACertificate) Start(ctx context.Context) (bool, error) {
if !a.actionCtx.GetSpec().TLS.IsSecure() {
return true, nil
}

View file

@ -35,25 +35,21 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeCleanTLSCACertificate, newCleanTLSCACertificateAction, operationTLSCACertificateTimeout)
}
func newCleanTLSCACertificateAction(action api.Action, actionCtx ActionContext) Action {
a := &cleanTLSCACertificateAction{}
a := &actionCleanTLSCACertificate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type cleanTLSCACertificateAction struct {
type actionCleanTLSCACertificate struct {
actionImpl
actionEmptyCheckProgress
}
func (a *cleanTLSCACertificateAction) Start(ctx context.Context) (bool, error) {
func (a *actionCleanTLSCACertificate) Start(ctx context.Context) (bool, error) {
a.log.Info("Clean TLS Ca")
if !a.actionCtx.GetSpec().TLS.IsSecure() {
a.log.Info("Insecure deployment")

View file

@ -30,25 +30,21 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeRenewTLSCACertificate, newRenewTLSCACertificateAction, operationTLSCACertificateTimeout)
}
func newRenewTLSCACertificateAction(action api.Action, actionCtx ActionContext) Action {
a := &renewTLSCACertificateAction{}
a := &actionRenewTLSCACertificate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type renewTLSCACertificateAction struct {
type actionRenewTLSCACertificate struct {
actionImpl
actionEmptyCheckProgress
}
func (a *renewTLSCACertificateAction) Start(ctx context.Context) (bool, error) {
func (a *actionRenewTLSCACertificate) Start(ctx context.Context) (bool, error) {
if !a.actionCtx.GetSpec().TLS.IsSecure() {
return true, nil
}

View file

@ -30,25 +30,21 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeCleanTLSKeyfileCertificate, newCleanTLSKeyfileCertificateAction, operationTLSCACertificateTimeout)
}
func newCleanTLSKeyfileCertificateAction(action api.Action, actionCtx ActionContext) Action {
a := &cleanTLSKeyfileCertificateAction{}
a := &actionCleanTLSKeyfileCertificate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type cleanTLSKeyfileCertificateAction struct {
type actionCleanTLSKeyfileCertificate struct {
actionImpl
actionEmptyCheckProgress
}
func (a *cleanTLSKeyfileCertificateAction) Start(ctx context.Context) (bool, error) {
func (a *actionCleanTLSKeyfileCertificate) Start(ctx context.Context) (bool, error) {
if !a.actionCtx.GetSpec().TLS.IsSecure() {
return true, nil
}

View file

@ -31,23 +31,19 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
func init() {
registerAction(api.ActionTypeRefreshTLSKeyfileCertificate, newRefreshTLSKeyfileCertificateAction, operationTLSCACertificateTimeout)
}
func newRefreshTLSKeyfileCertificateAction(action api.Action, actionCtx ActionContext) Action {
a := &refreshTLSKeyfileCertificateAction{}
a := &actionRefreshTLSKeyfileCertificate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type refreshTLSKeyfileCertificateAction struct {
type actionRefreshTLSKeyfileCertificate struct {
actionImpl
}
func (a *refreshTLSKeyfileCertificateAction) CheckProgress(ctx context.Context) (bool, bool, error) {
func (a *actionRefreshTLSKeyfileCertificate) CheckProgress(ctx context.Context) (bool, bool, error) {
c, err := a.actionCtx.GetMembersState().GetMemberClient(a.action.MemberID)
if err != nil {
a.log.Err(err).Warn("Unable to get client")
@ -85,7 +81,7 @@ func (a *refreshTLSKeyfileCertificateAction) CheckProgress(ctx context.Context)
return false, false, nil
}
func (a *refreshTLSKeyfileCertificateAction) Start(ctx context.Context) (bool, error) {
func (a *actionRefreshTLSKeyfileCertificate) Start(ctx context.Context) (bool, error) {
ready, _, err := a.CheckProgress(ctx)
return ready, err
}

View file

@ -26,25 +26,21 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeTLSPropagated, newTLSPropagated, defaultTimeout)
}
func newTLSPropagated(action api.Action, actionCtx ActionContext) Action {
a := &tlsPropagatedAction{}
func newTLSPropagatedAction(action api.Action, actionCtx ActionContext) Action {
a := &actionTLSPropagated{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type tlsPropagatedAction struct {
type actionTLSPropagated struct {
actionImpl
actionEmptyCheckProgress
}
func (a *tlsPropagatedAction) Start(ctx context.Context) (bool, error) {
func (a *actionTLSPropagated) Start(ctx context.Context) (bool, error) {
propagatedFlag, exists := a.action.Params[propagated]
if !exists {
a.log.Error("Propagated flag is missing")

View file

@ -27,25 +27,21 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
)
func init() {
registerAction(api.ActionTypeUpdateTLSSNI, newTLSSNIUpdate, tlsSNIUpdateTimeout)
}
func newTLSSNIUpdate(action api.Action, actionCtx ActionContext) Action {
a := &tlsSNIUpdate{}
func newUpdateTLSSNIAction(action api.Action, actionCtx ActionContext) Action {
a := &actionUpdateTLSSNI{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type tlsSNIUpdate struct {
type actionUpdateTLSSNI struct {
actionImpl
actionEmptyStart
}
func (t *tlsSNIUpdate) CheckProgress(ctx context.Context) (bool, bool, error) {
func (t *actionUpdateTLSSNI) CheckProgress(ctx context.Context) (bool, bool, error) {
spec := t.actionCtx.GetSpec()
if !spec.TLS.IsSecure() {
return true, false, nil

View file

@ -31,25 +31,21 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
)
func init() {
registerAction(api.ActionTypeTLSKeyStatusUpdate, newTLSKeyStatusUpdate, defaultTimeout)
}
func newTLSKeyStatusUpdate(action api.Action, actionCtx ActionContext) Action {
a := &tlsKeyStatusUpdateAction{}
func newTLSKeyStatusUpdateAction(action api.Action, actionCtx ActionContext) Action {
a := &actionTLSKeyStatusUpdate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type tlsKeyStatusUpdateAction struct {
type actionTLSKeyStatusUpdate struct {
actionImpl
actionEmptyCheckProgress
}
func (a *tlsKeyStatusUpdateAction) Start(ctx context.Context) (bool, error) {
func (a *actionTLSKeyStatusUpdate) Start(ctx context.Context) (bool, error) {
if !a.actionCtx.GetSpec().TLS.IsSecure() {
return true, nil
}

View file

@ -21,6 +21,6 @@
package reconcile
type topologyDisable struct {
type actionTopologyDisable struct {
actionEmpty
}

View file

@ -24,12 +24,8 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeTopologyDisable, newTopologyDisable, defaultTimeout)
}
func newTopologyDisable(action api.Action, actionCtx ActionContext) Action {
a := &topologyDisable{}
func newTopologyDisableAction(action api.Action, actionCtx ActionContext) Action {
a := &actionTopologyDisable{}
a.actionImpl = newActionImplDefRef(action, actionCtx)

View file

@ -21,6 +21,6 @@
package reconcile
type topologyEnable struct {
type actionTopologyEnable struct {
actionEmpty
}

View file

@ -24,12 +24,8 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeTopologyEnable, newTopologyEnable, defaultTimeout)
}
func newTopologyEnable(action api.Action, actionCtx ActionContext) Action {
a := &topologyEnable{}
func newTopologyEnableAction(action api.Action, actionCtx ActionContext) Action {
a := &actionTopologyEnable{}
a.actionImpl = newActionImplDefRef(action, actionCtx)

View file

@ -21,6 +21,6 @@
package reconcile
type topologyMemberAssignment struct {
type actionTopologyMemberAssignment struct {
actionEmpty
}

View file

@ -24,12 +24,8 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeTopologyMemberAssignment, newTopologyMemberAssignment, defaultTimeout)
}
func newTopologyMemberAssignment(action api.Action, actionCtx ActionContext) Action {
a := &topologyMemberAssignment{}
func newTopologyMemberAssignmentAction(action api.Action, actionCtx ActionContext) Action {
a := &actionTopologyMemberAssignment{}
a.actionImpl = newActionImplDefRef(action, actionCtx)

View file

@ -21,6 +21,6 @@
package reconcile
type topologyZonesUpdate struct {
type actionTopologyZonesUpdate struct {
actionEmpty
}

View file

@ -24,12 +24,8 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func init() {
registerAction(api.ActionTypeTopologyZonesUpdate, newTopologyZonesUpdate, defaultTimeout)
}
func newTopologyZonesUpdate(action api.Action, actionCtx ActionContext) Action {
a := &topologyZonesUpdate{}
func newTopologyZonesUpdateAction(action api.Action, actionCtx ActionContext) Action {
a := &actionTopologyZonesUpdate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)

View file

@ -27,22 +27,18 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func init() {
registerAction(api.ActionTypeSetCurrentImage, newSetCurrentImageAction, upgradeMemberTimeout)
}
// newSetCurrentImageAction creates a new Action that implements the given
// planned SetCurrentImage action.
func newSetCurrentImageAction(action api.Action, actionCtx ActionContext) Action {
a := &setCurrentImageAction{}
a := &actionSetCurrentImage{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
// setCurrentImageAction implements an SetCurrentImage.
type setCurrentImageAction struct {
// actionSetCurrentImage implements an SetCurrentImage.
type actionSetCurrentImage struct {
// actionImpl implement timeout and member id functions
actionImpl
}
@ -50,7 +46,7 @@ type setCurrentImageAction struct {
// Start performs the start of the action.
// Returns true if the action is completely finished, false in case
// the start time needs to be recorded and a ready condition needs to be checked.
func (a *setCurrentImageAction) Start(ctx context.Context) (bool, error) {
func (a *actionSetCurrentImage) Start(ctx context.Context) (bool, error) {
ready, _, err := a.CheckProgress(ctx)
if err != nil {
return false, errors.WithStack(err)
@ -60,7 +56,7 @@ func (a *setCurrentImageAction) Start(ctx context.Context) (bool, error) {
// CheckProgress checks the progress of the action.
// Returns true if the action is completely finished, false otherwise.
func (a *setCurrentImageAction) CheckProgress(ctx context.Context) (bool, bool, error) {
func (a *actionSetCurrentImage) CheckProgress(ctx context.Context) (bool, bool, error) {
imageInfo, found := a.actionCtx.GetImageInfo(a.action.Image)
if !found {
return false, false, nil

View file

@ -27,10 +27,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func init() {
registerAction(api.ActionTypeUpgradeMember, newUpgradeMemberAction, upgradeMemberTimeout)
}
// newUpgradeMemberAction creates a new Action that implements the given
// planned UpgradeMember action.
func newUpgradeMemberAction(action api.Action, actionCtx ActionContext) Action {

View file

@ -0,0 +1,35 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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 reconcile
import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
func newUpToDateUpdateAction(action api.Action, actionCtx ActionContext) Action {
a := &actionUpToDateUpdate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type actionUpToDateUpdate struct {
actionEmpty
}

View file

@ -28,13 +28,9 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util"
)
func init() {
registerAction(api.ActionTypeWaitForMemberInSync, newWaitForMemberInSync, waitForMemberUpTimeout)
}
// newWaitForMemberUpAction creates a new Action that implements the given
// planned WaitForShardInSync action.
func newWaitForMemberInSync(action api.Action, actionCtx ActionContext) Action {
func newWaitForMemberInSyncAction(action api.Action, actionCtx ActionContext) Action {
a := &actionWaitForMemberInSync{}
a.actionImpl = newActionImplDefRef(action, actionCtx)

View file

@ -30,10 +30,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
)
func init() {
registerAction(api.ActionTypeWaitForMemberUp, newWaitForMemberUpAction, waitForMemberUpTimeout)
}
// newWaitForMemberUpAction creates a new Action that implements the given
// planned WaitForMemberUp action.
func newWaitForMemberUpAction(action api.Action, actionCtx ActionContext) Action {

Some files were not shown because too many files have changed in this diff Show more