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

[Feature] Deprecate Actions (#1383)

This commit is contained in:
Adam Janikowski 2023-08-18 10:51:51 +03:00 committed by GitHub
parent 90aca02ce1
commit 282a50e255
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 600 additions and 473 deletions

View file

@ -4,6 +4,7 @@
- (Maintenance) Bump golang.org/x/net to v0.13.0
- (Feature) PVCResize action concurrency limit
- (Feature) Optional Assertions
- (Feature) Deprecate Actions
## [1.2.32](https://github.com/arangodb/kube-arangodb/tree/1.2.32) (2023-08-07)
- (Feature) Backup lifetime - remove Backup once its lifetime has been reached

View file

@ -18,10 +18,10 @@
| CleanTLSCACertificate | no | 30m0s | no | Enterprise Only | Remove Certificate from CA TrustStore |
| CleanTLSKeyfileCertificate | no | 30m0s | no | Enterprise Only | Remove old TLS certificate from server |
| ClusterMemberCleanup | no | 10m0s | no | Community & Enterprise | Remove member from Cluster if it is gone already (Coordinators) |
| DisableClusterScaling | no | 10m0s | no | Community & Enterprise | (Deprecated) Disable Cluster Scaling integration |
| ~~DisableClusterScaling~~ | no | 10m0s | no | Community & Enterprise | Disable Cluster Scaling integration |
| DisableMaintenance | no | 10m0s | no | Community & Enterprise | Disable ArangoDB maintenance mode |
| DisableMemberMaintenance | no | 10m0s | no | Enterprise Only | Disable ArangoDB DBServer maintenance mode |
| EnableClusterScaling | no | 10m0s | no | Community & Enterprise | (Deprecated) Enable Cluster Scaling integration |
| ~~EnableClusterScaling~~ | no | 10m0s | no | Community & Enterprise | Enable Cluster Scaling integration |
| EnableMaintenance | no | 10m0s | no | Community & Enterprise | Enable ArangoDB maintenance mode |
| EnableMemberMaintenance | no | 10m0s | no | Enterprise Only | Enable ArangoDB DBServer maintenance mode |
| EncryptionKeyAdd | no | 10m0s | no | Enterprise Only | Add the encryption key to the pool |
@ -40,7 +40,7 @@
| LicenseSet | no | 10m0s | no | Community & Enterprise | Update Cluster license (3.9+) |
| MarkToRemoveMember | no | 10m0s | no | Community & Enterprise | Marks member to be removed. Used when member Pod is annotated with replace annotation |
| MemberPhaseUpdate | no | 10m0s | no | Community & Enterprise | Change member phase |
| MemberRIDUpdate | no | 10m0s | no | Community & Enterprise | Update Run ID of member |
| ~~MemberRIDUpdate~~ | no | 10m0s | no | Community & Enterprise | Update Run ID of member |
| PVCResize | no | 30m0s | no | Community & Enterprise | Start the resize procedure. Updates PVC Requests field |
| PVCResized | no | 15m0s | no | Community & Enterprise | Waits for PVC resize to be completed |
| PlaceHolder | no | 10m0s | no | Community & Enterprise | Empty placeholder action |
@ -65,12 +65,12 @@
| RuntimeContainerArgsLogLevelUpdate | no | 10m0s | no | Community & Enterprise | Change ArangoDB Member log levels in runtime |
| RuntimeContainerImageUpdate | no | 10m0s | no | Community & Enterprise | Update Container Image in runtime |
| RuntimeContainerSyncTolerations | no | 10m0s | no | Community & Enterprise | Update Pod Tolerations in runtime |
| SetCondition | no | 10m0s | no | Community & Enterprise | (Deprecated) Set deployment condition |
| ~~SetCondition~~ | no | 10m0s | no | Community & Enterprise | Set deployment condition |
| SetConditionV2 | no | 10m0s | no | Community & Enterprise | Set deployment condition |
| SetCurrentImage | no | 6h0m0s | no | Community & Enterprise | Update deployment current image after image discovery |
| SetCurrentMemberArch | no | 10m0s | no | Community & Enterprise | Set current member architecture |
| SetMaintenanceCondition | no | 10m0s | no | Community & Enterprise | Update ArangoDB maintenance condition |
| SetMemberCondition | no | 10m0s | no | Community & Enterprise | (Deprecated) Set member condition |
| ~~SetMemberCondition~~ | no | 10m0s | no | Community & Enterprise | Set member condition |
| SetMemberConditionV2 | no | 10m0s | no | Community & Enterprise | Set member condition |
| SetMemberCurrentImage | no | 10m0s | no | Community & Enterprise | Update Member current image |
| ShutdownMember | no | 30m0s | no | Community & Enterprise | Sends Shutdown requests and waits for container to be stopped |

View file

@ -34,6 +34,7 @@ import (
"github.com/arangodb/kube-arangodb/internal/md"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/strings"
)
@ -188,6 +189,14 @@ func (i ActionsInput) Configurable() []string {
return r
}
func (i ActionsInput) Deprecated() map[string]string {
r := map[string]string{}
for k, a := range i.Actions {
r[k] = util.TypeOrDefault(a.Deprecated, "")
}
return r
}
type Action struct {
Timeout *meta.Duration `json:"timeout,omitempty"`
StartupFailureGracePeriod *meta.Duration `json:"startupFailureGracePeriod,omitempty"`
@ -203,6 +212,8 @@ type Action struct {
Optional bool `json:"optional"`
Configurable bool `json:"configurable"`
Deprecated *string `json:"deprecated"`
}
func (a Action) InScope(scope string) bool {
@ -247,6 +258,7 @@ func RenderActions(root string) error {
"timeouts": in.Timeouts(),
"descriptions": in.Descriptions(),
"optionals": in.Optionals(),
"deprecated": in.Deprecated(),
"defaultTimeout": fmt.Sprintf("%d * time.Second // %s", in.DefaultTimeout.Duration/time.Second, in.DefaultTimeout.Duration.String()),
}); err != nil {
return err
@ -273,6 +285,7 @@ func RenderActions(root string) error {
if err := i.Execute(out, map[string]interface{}{
"actions": in.Keys(),
"startupFailureGracePeriods": in.StartFailureGracePeriods(),
"deprecated": in.Deprecated(),
}); err != nil {
return err
}
@ -324,6 +337,7 @@ func RenderActions(root string) error {
"startupFailureGracePeriods": in.StartFailureGracePeriods(),
"internal": in.Internal(),
"optional": in.Optionals(),
"deprecated": in.Deprecated(),
}); err != nil {
return err
}
@ -352,6 +366,11 @@ func RenderActions(root string) error {
)
for _, k := range in.Keys() {
name := k
if in.Actions[k].Deprecated != nil {
name = fmt.Sprintf("~~%s~~", name)
}
a := in.Actions[k]
v := in.DefaultTimeout.Duration.String()
if t := a.Timeout; t != nil {
@ -372,7 +391,7 @@ func RenderActions(root string) error {
}
if err := t.AddRow(map[md.Column]string{
action: k,
action: name,
timeout: v,
description: a.Description,
edition: vr,

View file

@ -26,16 +26,23 @@ const (
// ActionsDefaultTimeout define default timeout
ActionsDefaultTimeout time.Duration = {{ $root.defaultTimeout }}
{{- range .actions }}
{{ range .actions -}}
// Action{{ . }}DefaultTimeout define default timeout for action Action{{ . }}
Action{{ . }}DefaultTimeout time.Duration = {{ index $root.timeouts . }}
{{- end }}
{{ end }}
// Actions
{{ range .actions }}
{{ range .actions -}}
// ActionType{{ . }} in scopes {{ index $root.scopes . }}. {{ index $root.descriptions . }}
{{ if (index $root.deprecated .) -}}
//
// Deprecated: {{ index $root.deprecated . }}
{{ end -}}
ActionType{{ . }} ActionType = "{{ . }}"
{{- end }}
{{ end -}}
)
func (a ActionType) DefaultTimeout() time.Duration {

View file

@ -27,30 +27,47 @@ import (
var (
// Ensure implementation
{{- range .actions }}
{{- if not (index $root.deprecated .) }}
_ Action = &action{{ . }}{}
_ actionFactory = new{{ . }}Action
{{- end }}
{{- end }}
)
func init() {
// Register all actions
{{- range .actions }}
{{ range .actions -}}
// {{ . }}
{
// Get Action defition
function := new{{ . }}Action
// Get Action type
{{ if (index $root.deprecated .) -}}
// nolint:staticcheck
{{ end -}}
action := api.ActionType{{ . }}
{{ if (index $root.deprecated .) -}}
// Get Empty (Deprecated) Action Definition
function := newDeprecatedAction
{{ else -}}
// Get Action defition
function := new{{ . }}Action
// Wrap action main function
{{- $startupFailureGracePeriod := index $root.startupFailureGracePeriods . -}}
{{- if $startupFailureGracePeriod }}
{{ $startupFailureGracePeriod := index $root.startupFailureGracePeriods . -}}
{{ if $startupFailureGracePeriod -}}
// With StartupFailureGracePeriod
function = withActionStartFailureGracePeriod(function, {{ $startupFailureGracePeriod }})
{{- end }}
{{ end -}}
{{ end -}}
// Register action
registerAction(action, function)
}
{{- end }}
{{ end -}}
}

View file

@ -33,6 +33,9 @@ func Test_Actions(t *testing.T) {
{{- range .actions }}
t.Run("{{ . }}", func(t *testing.T) {
{{ if (index $root.deprecated .) -}}
// nolint:staticcheck
{{ end -}}
ActionsExistence(t, api.ActionType{{ . }})
{{- $startupFailureGracePeriod := index $root.startupFailureGracePeriods . -}}
{{- if $startupFailureGracePeriod }}
@ -40,6 +43,9 @@ func Test_Actions(t *testing.T) {
{{- end }}
{{- $isInternal := index $root.internal . }}
t.Run("Internal", func(t *testing.T) {
{{- if (index $root.deprecated .) }}
// nolint:staticcheck
{{- end }}
{{- if $isInternal }}
require.True(t, api.ActionType{{ . }}.Internal())
{{- else }}
@ -48,6 +54,9 @@ func Test_Actions(t *testing.T) {
})
{{- $isOptional := index $root.optional . }}
t.Run("Optional", func(t *testing.T) {
{{- if (index $root.deprecated .) }}
// nolint:staticcheck
{{- end }}
{{- if $isOptional }}
require.True(t, api.ActionType{{ . }}.Optional())
{{- else }}

View file

@ -100,9 +100,11 @@ actions:
SetMemberCurrentImage:
description: Update Member current image
DisableClusterScaling:
description: (Deprecated) Disable Cluster Scaling integration
description: Disable Cluster Scaling integration
deprecated: "action is not used anymore"
EnableClusterScaling:
description: (Deprecated) Enable Cluster Scaling integration
description: Enable Cluster Scaling integration
deprecated: "action is not used anymore"
PVCResize:
description: Start the resize procedure. Updates PVC Requests field
timeout: 30m
@ -176,17 +178,19 @@ actions:
scopes:
- High
SetMemberCondition:
description: (Deprecated) Set member condition
description: Set member condition
scopes:
- High
deprecated: "action is not used anymore"
SetMemberConditionV2:
description: Set member condition
scopes:
- High
SetCondition:
description: (Deprecated) Set deployment condition
description: Set deployment condition
scopes:
- High
deprecated: "action is not used anymore"
SetConditionV2:
description: Set deployment condition
scopes:
@ -195,6 +199,7 @@ actions:
description: Update Run ID of member
scopes:
- High
deprecated: "action is not used anymore"
ArangoMemberUpdatePodSpec:
description: Propagate Member Pod spec (requested)
scopes:

View file

@ -25,168 +25,250 @@ const (
// 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
// ActionCleanMemberServiceDefaultTimeout define default timeout for action ActionCleanMemberService
ActionCleanMemberServiceDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
// 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
// ActionPlaceHolderDefaultTimeout define default timeout for action ActionPlaceHolder
ActionPlaceHolderDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionRebalancerCheckDefaultTimeout define default timeout for action ActionRebalancerCheck
ActionRebalancerCheckDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionRebalancerCheckV2DefaultTimeout define default timeout for action ActionRebalancerCheckV2
ActionRebalancerCheckV2DefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionRebalancerCleanDefaultTimeout define default timeout for action ActionRebalancerClean
ActionRebalancerCleanDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionRebalancerCleanV2DefaultTimeout define default timeout for action ActionRebalancerCleanV2
ActionRebalancerCleanV2DefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionRebalancerGenerateDefaultTimeout define default timeout for action ActionRebalancerGenerate
ActionRebalancerGenerateDefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionRebalancerGenerateV2DefaultTimeout define default timeout for action ActionRebalancerGenerateV2
ActionRebalancerGenerateV2DefaultTimeout time.Duration = ActionsDefaultTimeout
// ActionRebuildOutSyncedShardsDefaultTimeout define default timeout for action ActionRebuildOutSyncedShards
ActionRebuildOutSyncedShardsDefaultTimeout time.Duration = 86400 * time.Second // 24h0m0s
// 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
// ActionRemoveMemberPVCDefaultTimeout define default timeout for action ActionRemoveMemberPVC
ActionRemoveMemberPVCDefaultTimeout 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
// ActionRuntimeContainerSyncTolerationsDefaultTimeout define default timeout for action ActionRuntimeContainerSyncTolerations
ActionRuntimeContainerSyncTolerationsDefaultTimeout 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
// ActionSetCurrentMemberArchDefaultTimeout define default timeout for action ActionSetCurrentMemberArch
ActionSetCurrentMemberArchDefaultTimeout time.Duration = 600 * time.Second // 10m0s
// 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
// ActionWaitForMemberReadyDefaultTimeout define default timeout for action ActionWaitForMemberReady
ActionWaitForMemberReadyDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
// ActionWaitForMemberUpDefaultTimeout define default timeout for action ActionWaitForMemberUp
ActionWaitForMemberUpDefaultTimeout time.Duration = 1800 * time.Second // 30m0s
@ -194,166 +276,257 @@ const (
// 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"
// ActionTypeCleanMemberService in scopes Normal. Removes Server Service
ActionTypeCleanMemberService ActionType = "CleanMemberService"
// 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 in scopes Normal. Disable Cluster Scaling integration
//
// Deprecated: action is not used anymore
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 in scopes Normal. Enable Cluster Scaling integration
//
// Deprecated: action is not used anymore
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
//
// Deprecated: action is not used anymore
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"
// ActionTypePlaceHolder in scopes Normal. Empty placeholder action
ActionTypePlaceHolder ActionType = "PlaceHolder"
// ActionTypeRebalancerCheck in scopes Normal. Check Rebalancer job progress
ActionTypeRebalancerCheck ActionType = "RebalancerCheck"
// ActionTypeRebalancerCheckV2 in scopes Normal. Check Rebalancer job progress
ActionTypeRebalancerCheckV2 ActionType = "RebalancerCheckV2"
// ActionTypeRebalancerClean in scopes Normal. Cleans Rebalancer jobs
ActionTypeRebalancerClean ActionType = "RebalancerClean"
// ActionTypeRebalancerCleanV2 in scopes Normal. Cleans Rebalancer jobs
ActionTypeRebalancerCleanV2 ActionType = "RebalancerCleanV2"
// ActionTypeRebalancerGenerate in scopes Normal. Generates the Rebalancer plan
ActionTypeRebalancerGenerate ActionType = "RebalancerGenerate"
// ActionTypeRebalancerGenerateV2 in scopes Normal. Generates the Rebalancer plan
ActionTypeRebalancerGenerateV2 ActionType = "RebalancerGenerateV2"
// ActionTypeRebuildOutSyncedShards in scopes High. Run Rebuild Out Synced Shards procedure for DBServers
ActionTypeRebuildOutSyncedShards ActionType = "RebuildOutSyncedShards"
// 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"
// ActionTypeRemoveMemberPVC in scopes Normal. Removes member PVC and enforce recreate procedure
ActionTypeRemoveMemberPVC ActionType = "RemoveMemberPVC"
// 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"
// ActionTypeRuntimeContainerSyncTolerations in scopes Normal. Update Pod Tolerations in runtime
ActionTypeRuntimeContainerSyncTolerations ActionType = "RuntimeContainerSyncTolerations"
// ActionTypeSetCondition in scopes High. (Deprecated) Set deployment condition
// ActionTypeSetCondition in scopes High. Set deployment condition
//
// Deprecated: action is not used anymore
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"
// ActionTypeSetCurrentMemberArch in scopes Normal. Set current member architecture
ActionTypeSetCurrentMemberArch ActionType = "SetCurrentMemberArch"
// ActionTypeSetMaintenanceCondition in scopes Normal. Update ArangoDB maintenance condition
ActionTypeSetMaintenanceCondition ActionType = "SetMaintenanceCondition"
// ActionTypeSetMemberCondition in scopes High. (Deprecated) Set member condition
// ActionTypeSetMemberCondition in scopes High. Set member condition
//
// Deprecated: action is not used anymore
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"
// ActionTypeWaitForMemberReady in scopes Normal. Wait for member Ready condition
ActionTypeWaitForMemberReady ActionType = "WaitForMemberReady"
// ActionTypeWaitForMemberUp in scopes Normal. Wait for member to be responsive
ActionTypeWaitForMemberUp ActionType = "WaitForMemberUp"
)

View file

@ -286,6 +286,19 @@ func (p Plan) Before(action ...Action) Plan {
return n
}
// WrapWithPlan wraps plan with plan
func (p Plan) WrapWithPlan(before, after Plan) Plan {
n := Plan{}
n = append(n, before...)
n = append(n, p...)
n = append(n, after...)
return n
}
// Wrap wraps plan with actions
func (p Plan) Wrap(before, after Action) Plan {
n := Plan{}

File diff suppressed because it is too large Load diff

View file

@ -161,11 +161,14 @@ func Test_Actions(t *testing.T) {
})
t.Run("DisableClusterScaling", func(t *testing.T) {
// nolint:staticcheck
ActionsExistence(t, api.ActionTypeDisableClusterScaling)
t.Run("Internal", func(t *testing.T) {
// nolint:staticcheck
require.False(t, api.ActionTypeDisableClusterScaling.Internal())
})
t.Run("Optional", func(t *testing.T) {
// nolint:staticcheck
require.False(t, api.ActionTypeDisableClusterScaling.Optional())
})
})
@ -191,11 +194,14 @@ func Test_Actions(t *testing.T) {
})
t.Run("EnableClusterScaling", func(t *testing.T) {
// nolint:staticcheck
ActionsExistence(t, api.ActionTypeEnableClusterScaling)
t.Run("Internal", func(t *testing.T) {
// nolint:staticcheck
require.False(t, api.ActionTypeEnableClusterScaling.Internal())
})
t.Run("Optional", func(t *testing.T) {
// nolint:staticcheck
require.False(t, api.ActionTypeEnableClusterScaling.Optional())
})
})
@ -381,11 +387,14 @@ func Test_Actions(t *testing.T) {
})
t.Run("MemberRIDUpdate", func(t *testing.T) {
// nolint:staticcheck
ActionsExistence(t, api.ActionTypeMemberRIDUpdate)
t.Run("Internal", func(t *testing.T) {
// nolint:staticcheck
require.False(t, api.ActionTypeMemberRIDUpdate.Internal())
})
t.Run("Optional", func(t *testing.T) {
// nolint:staticcheck
require.False(t, api.ActionTypeMemberRIDUpdate.Optional())
})
})
@ -633,11 +642,14 @@ func Test_Actions(t *testing.T) {
})
t.Run("SetCondition", func(t *testing.T) {
// nolint:staticcheck
ActionsExistence(t, api.ActionTypeSetCondition)
t.Run("Internal", func(t *testing.T) {
// nolint:staticcheck
require.False(t, api.ActionTypeSetCondition.Internal())
})
t.Run("Optional", func(t *testing.T) {
// nolint:staticcheck
require.False(t, api.ActionTypeSetCondition.Optional())
})
})
@ -683,11 +695,14 @@ func Test_Actions(t *testing.T) {
})
t.Run("SetMemberCondition", func(t *testing.T) {
// nolint:staticcheck
ActionsExistence(t, api.ActionTypeSetMemberCondition)
t.Run("Internal", func(t *testing.T) {
// nolint:staticcheck
require.False(t, api.ActionTypeSetMemberCondition.Internal())
})
t.Run("Optional", func(t *testing.T) {
// nolint:staticcheck
require.False(t, api.ActionTypeSetMemberCondition.Optional())
})
})

View file

@ -1,55 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 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 (
"context"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util"
)
// 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.NewType[string](""))
return a
}
// actionDisableClusterScaling implements disabling scaling DBservers and coordinators.
type actionDisableClusterScaling struct {
// actionImpl implement timeout and member id functions
actionImpl
// actionEmptyCheckProgress implement check progress with empty implementation
actionEmptyCheckProgress
}
// Start disables scaling DBservers and coordinators
func (a *actionDisableClusterScaling) Start(ctx context.Context) (bool, error) {
err := a.actionCtx.DisableScalingCluster(ctx)
if err != nil {
return false, err
}
return true, nil
}

View file

@ -1,55 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 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 (
"context"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util"
)
// 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.NewType[string](""))
return a
}
// actionEnableClusterScaling implements enabling scaling DBservers and coordinators.
type actionEnableClusterScaling struct {
// actionImpl implement timeout and member id functions
actionImpl
// actionEmptyCheckProgress implement check progress with empty implementation
actionEmptyCheckProgress
}
// Start enables scaling DBservers and coordinators
func (a *actionEnableClusterScaling) Start(ctx context.Context) (bool, error) {
err := a.actionCtx.EnableScalingCluster(ctx)
if err != nil {
return false, err
}
return true, nil
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2023 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.
@ -27,6 +27,7 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/logging"
"github.com/arangodb/kube-arangodb/pkg/util/assertion"
)
var (
@ -123,3 +124,25 @@ func (a actionImpl) wrap(in *zerolog.Event) *zerolog.Event {
func (a actionImpl) MemberID() string {
return *a.memberIDRef
}
func newDeprecatedAction(action api.Action, actionCtx ActionContext) Action {
a := actionDeprecated{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type actionDeprecated struct {
actionImpl
actionEmptyCheckProgress
}
func (a actionDeprecated) Start(ctx context.Context) (bool, error) {
a.log.Warn("Deprecated Action call")
assertion.Assert(true, assertion.DeprecatedActionKey, "Action %s is deprecated", a.action.Type.String())
return true, nil
}

View file

@ -1,37 +0,0 @@
//
// 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 newMemberRIDUpdateAction(action api.Action, actionCtx ActionContext) Action {
a := &actionMemberRIDUpdate{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type actionMemberRIDUpdate struct {
actionEmpty
}

View file

@ -1,82 +0,0 @@
//
// 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 (
"context"
"strconv"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)
func newSetConditionAction(action api.Action, actionCtx ActionContext) Action {
a := &actionSetCondition{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type actionSetCondition struct {
// actionImpl implement timeout and member id functions
actionImpl
actionEmptyCheckProgress
}
// Start starts the action for changing conditions on the provided member.
func (a actionSetCondition) Start(ctx context.Context) (bool, error) {
if len(a.action.Params) == 0 {
a.log.Info("can not start the action with the empty list of conditions")
return true, nil
}
if err := a.actionCtx.WithStatusUpdate(ctx, func(s *api.DeploymentStatus) bool {
changed := false
for condition, value := range a.action.Params {
if value == "" {
a.log.Debug("remove the condition")
if s.Conditions.Remove(api.ConditionType(condition)) {
changed = true
}
} else {
set, err := strconv.ParseBool(value)
if err != nil {
a.log.Err(err).Str("value", value).Error("can not parse string to boolean")
continue
}
a.log.Debug("set the condition")
if s.Conditions.Update(api.ConditionType(condition), set, a.action.Reason, "action set the member condition") {
changed = true
}
}
}
return changed
}); err != nil {
a.log.Err(err).Warn("Unable to set condition")
return true, nil
}
return true, nil
}

View file

@ -1,82 +0,0 @@
//
// 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 (
"context"
"strconv"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func newSetMemberConditionAction(action api.Action, actionCtx ActionContext) Action {
a := &actionSetMemberCondition{}
a.actionImpl = newActionImplDefRef(action, actionCtx)
return a
}
type actionSetMemberCondition struct {
// actionImpl implement timeout and member id functions
actionImpl
actionEmptyCheckProgress
}
// Start starts the action for changing conditions on the provided member.
func (a actionSetMemberCondition) Start(ctx context.Context) (bool, error) {
m, ok := a.actionCtx.GetMemberStatusByID(a.action.MemberID)
if !ok {
a.log.Info("can not set the condition because the member is gone already")
return true, nil
}
if len(a.action.Params) == 0 {
a.log.Info("can not start the action with the empty list of conditions")
return true, nil
}
for condition, value := range a.action.Params {
if value == "" {
a.log.Debug("remove the condition")
m.Conditions.Remove(api.ConditionType(condition))
} else {
set, err := strconv.ParseBool(value)
if err != nil {
a.log.Err(err).Str("value", value).Error("can not parse string to boolean")
continue
}
a.log.Debug("set the condition")
m.Conditions.Update(api.ConditionType(condition), set, a.action.Reason, "action set the member condition")
}
}
if err := a.actionCtx.UpdateMember(ctx, m); err != nil {
return false, errors.Wrap(errors.WithStack(err), "can not update the member")
}
return true, nil
}

View file

@ -123,15 +123,18 @@ func (r *Reconciler) updateMemberPhasePlan(ctx context.Context, apiObject k8suti
}
func pendingRestartMemberConditionAction(group api.ServerGroup, memberID string, reason string) api.Action {
return actions.NewAction(api.ActionTypeSetMemberCondition, group, shared.WithPredefinedMember(memberID), reason).AddParam(api.ConditionTypePendingRestart.String(), "T")
return shared.UpdateMemberConditionActionV2(reason, api.ConditionTypePendingRestart, group, memberID, true, reason, "", "")
}
func restartMemberConditionAction(group api.ServerGroup, memberID string, reason string) api.Action {
return pendingRestartMemberConditionAction(group, memberID, reason).AddParam(api.ConditionTypeRestart.String(), "T")
func restartMemberConditionAction(group api.ServerGroup, memberID string, reason string) api.Plan {
return api.Plan{
pendingRestartMemberConditionAction(group, memberID, reason),
shared.UpdateMemberConditionActionV2(reason, api.ConditionTypeRestart, group, memberID, true, reason, "", ""),
}
}
func tlsRotateConditionAction(group api.ServerGroup, memberID string, reason string) api.Action {
return actions.NewAction(api.ActionTypeSetMemberCondition, group, shared.WithPredefinedMember(memberID), reason).AddParam(api.ConditionTypePendingTLSRotation.String(), "T")
return shared.UpdateMemberConditionActionV2(reason, api.ConditionTypePendingTLSRotation, group, memberID, true, reason, "", "")
}
func (r *Reconciler) updateMemberUpdateConditionsPlan(ctx context.Context, apiObject k8sutil.APIObject,
@ -144,13 +147,11 @@ func (r *Reconciler) updateMemberUpdateConditionsPlan(ctx context.Context, apiOb
// We are in updating phase
if status.Plan.IsEmpty() {
// If plan is empty then something went wrong
plan = append(plan,
actions.NewAction(api.ActionTypeSetMemberCondition, e.Group, e.Member, "Clean update actions after failure").
AddParam(api.ConditionTypePendingUpdate.String(), "").
AddParam(api.ConditionTypeUpdating.String(), "").
AddParam(api.ConditionTypeUpdateFailed.String(), "T").
AddParam(api.ConditionTypePendingRestart.String(), "T"),
)
plan = append(plan, shared.RemoveMemberConditionActionV2("Clean update actions after failure", api.ConditionTypePendingUpdate, e.Group, e.Member.ID),
shared.RemoveMemberConditionActionV2("Clean update actions after failure", api.ConditionTypeUpdating, e.Group, e.Member.ID),
shared.UpdateMemberConditionActionV2("Clean update actions after failure", api.ConditionTypeUpdateFailed, e.Group, e.Member.ID, true, "Clean update actions after failure", "", ""),
shared.UpdateMemberConditionActionV2("Clean update actions after failure", api.ConditionTypePendingRestart, e.Group, e.Member.ID, true, "Clean update actions after failure", "", ""))
}
}
}
@ -207,7 +208,7 @@ func (r *Reconciler) updateMemberRotationConditions(apiObject k8sutil.APIObject,
r.log.Bool("enforced", true).Info("Unknown reason")
}
// We need to do enforced rotation
return api.Plan{restartMemberConditionAction(group, member.ID, reason)}, nil
return restartMemberConditionAction(group, member.ID, reason), nil
case rotation.InPlaceRotation:
if member.Conditions.IsTrue(api.ConditionTypeUpdateFailed) {
if !(member.Conditions.IsTrue(api.ConditionTypePendingRestart) || member.Conditions.IsTrue(api.ConditionTypeRestart)) {
@ -217,7 +218,7 @@ func (r *Reconciler) updateMemberRotationConditions(apiObject k8sutil.APIObject,
} else if member.Conditions.IsTrue(api.ConditionTypeUpdating) || member.Conditions.IsTrue(api.ConditionTypePendingUpdate) {
return nil, nil
}
return api.Plan{actions.NewAction(api.ActionTypeSetMemberCondition, group, member, reason).AddParam(api.ConditionTypePendingUpdate.String(), "T")}, nil
return api.Plan{shared.UpdateMemberConditionActionV2(reason, api.ConditionTypePendingUpdate, group, member.ID, true, reason, "", "")}, nil
case rotation.SilentRotation:
// Propagate changes without restart, but apply plan if required
plan = append(plan, actions.NewAction(api.ActionTypeArangoMemberUpdatePodStatus, group, member, "Propagating status of pod").AddParam(ActionTypeArangoMemberUpdatePodStatusChecksum, checksum))
@ -234,7 +235,7 @@ func (r *Reconciler) updateMemberRotationConditions(apiObject k8sutil.APIObject,
}
if spec.MemberPropagationMode.Get() == api.DeploymentMemberPropagationModeAlways {
return api.Plan{restartMemberConditionAction(group, member.ID, reason)}, nil
return restartMemberConditionAction(group, member.ID, reason), nil
} else {
return api.Plan{pendingRestartMemberConditionAction(group, member.ID, reason)}, nil
}

View file

@ -203,9 +203,10 @@ func (r *Reconciler) createUpdatePlanInternal(apiObject k8sutil.APIObject, spec
if svc, ok := cache.Service().V1().GetSimple(arangoMember.GetName()); ok {
if k8sutil.IsServiceRotationRequired(spec, svc) {
return api.Plan{actions.NewAction(api.ActionTypeSetMemberCondition, m.Group, m.Member, "Cleaning update").
AddParam(api.ConditionTypePendingUpdate.String(), "").
AddParam(api.ConditionTypeUpdating.String(), "T")}, false
return api.Plan{
shared.RemoveMemberConditionActionV2("Cleaning update", api.ConditionTypePendingUpdate, m.Group, m.Member.ID),
shared.UpdateMemberConditionActionV2("Cleaning update", api.ConditionTypeUpdating, m.Group, m.Member.ID, true, "Cleaning update", "", ""),
}, false
}
}
@ -213,18 +214,20 @@ func (r *Reconciler) createUpdatePlanInternal(apiObject k8sutil.APIObject, spec
r.planLogger.Err(err).Str("member", m.Member.ID).Error("Error while generating update plan")
continue
} else if mode != rotation.InPlaceRotation {
return api.Plan{actions.NewAction(api.ActionTypeSetMemberCondition, m.Group, m.Member, "Cleaning update").
AddParam(api.ConditionTypePendingUpdate.String(), "").
AddParam(api.ConditionTypeUpdating.String(), "T")}, false
return api.Plan{
shared.RemoveMemberConditionActionV2(reason, api.ConditionTypePendingUpdate, m.Group, m.Member.ID),
shared.UpdateMemberConditionActionV2(reason, api.ConditionTypeUpdating, m.Group, m.Member.ID, true, reason, "", ""),
}, false
} else {
p = withWaitForMember(p, m.Group, m.Member)
p = append(p, actions.NewAction(api.ActionTypeArangoMemberUpdatePodStatus, m.Group, m.Member, "Propagating status of pod").AddParam(ActionTypeArangoMemberUpdatePodStatusChecksum, checksum))
p = p.Wrap(actions.NewAction(api.ActionTypeSetMemberCondition, m.Group, m.Member, reason).
AddParam(api.ConditionTypePendingUpdate.String(), "").AddParam(api.ConditionTypeUpdating.String(), "T"),
actions.NewAction(api.ActionTypeSetMemberCondition, m.Group, m.Member, reason).
AddParam(api.ConditionTypeUpdating.String(), ""))
p.WrapWithPlan(api.Plan{
shared.RemoveMemberConditionActionV2(reason, api.ConditionTypePendingUpdate, m.Group, m.Member.ID),
shared.UpdateMemberConditionActionV2(reason, api.ConditionTypeUpdating, m.Group, m.Member.ID, true, reason, "", ""),
}, api.Plan{
shared.RemoveMemberConditionActionV2(reason, api.ConditionTypeUpdating, m.Group, m.Member.ID),
})
return p, false
}

View file

@ -28,6 +28,7 @@ type Key string
const (
KeyUnknown Key = ""
DeprecatedActionKey Key = "DeprecatedAction"
)
func (k Key) Assert(condition bool, msg string, args ...interface{}) {