8000 [Feature] Delay Action by ajanikow · Pull Request #1827 · arangodb/kube-arangodb · GitHub
[go: up one dir, main page]

Skip to content

[Feature] Delay Action #1827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- (Feature) Allow to continue if ResignServer job is gone
- (Feature) UpgradeByReplace Flow
- (Feature) (Platform) ArangoRoute Timeout option
- (Feature) Delay Action

## [1.2.44](https://github.com/arangodb/kube-arangodb/tree/1.2.44) (2025-02-03)
- (Maintenance) Kubernetes 1.31.1 libraries
Expand Down
2 changes: 2 additions & 0 deletions docs/generated/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ nav_order: 11
| 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) |
| Delay | no | 10m0s | yes | Community & Enterprise | Define delay operation |
| ~~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 |
Expand Down Expand Up @@ -121,6 +122,7 @@ spec:
CleanTLSCACertificate: 30m0s
CleanTLSKeyfileCertificate: 30m0s
ClusterMemberCleanup: 10m0s
Delay: 10m0s
DisableClusterScaling: 10m0s
DisableMaintenance: 10m0s
DisableMemberMaintenance: 10m0s
Expand Down
2 changes: 1 addition & 1 deletion internal/actions.config.go.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $root := . -}}
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2025 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.
Expand Down
2 changes: 1 addition & 1 deletion internal/actions.go.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $root := . -}}
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2025 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.
Expand Down
2 changes: 1 addition & 1 deletion internal/actions.register.go.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $root := . -}}
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2025 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.
Expand Down
2 changes: 1 addition & 1 deletion internal/actions.register.test.go.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $root := . -}}
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2025 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.
Expand Down
6 changes: 6 additions & 0 deletions internal/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ actions:
description: Empty placeholder action
Idle:
description: Define idle operation in case if preconditions are not meet
Delay:
description: Define delay operation
optional: true
scopes:
- Normal
- High
AddMember:
description: Adds new member to the Member list
timeout: 10m
Expand Down
14 changes: 13 additions & 1 deletion pkg/apis/deployment/v1/actions.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion pkg/apis/deployment/v2alpha1/actions.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/deployment/reconcile/action.config.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion pkg/deployment/reconcile/action.register.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion pkg/deployment/reconcile/action.register.generated_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2025 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.
Expand Down Expand Up @@ -160,6 +160,16 @@ func Test_Actions(t *testing.T) {
})
})

t.Run("Delay", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeDelay)
t.Run("Internal", func(t *testing.T) {
require.False(t, api.ActionTypeDelay.Internal())
})
t.Run("Optional", func(t *testing.T) {
require.True(t, api.ActionTypeDelay.Optional())
})
})

t.Run("DisableClusterScaling", func(t *testing.T) {
// nolint:staticcheck
ActionsExistence(t, api.ActionTypeDisableClusterScaling)
Expand Down
77 changes: 77 additions & 0 deletions pkg/deployment/reconcile/action_delay.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// DISCLAIMER
//
// Copyright 2025 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"
"time"

api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
)

const (
DelayActionDuration = "delayActionDuration"
)

// newDelayAction creates a new Action that implements the given
// planned Delay action.
func newDelayAction(action api.Action, actionCtx ActionContext) Action {
a := &actionDelay{}

a.actionImpl = newActionImplDefRef(action, actionCtx)

return a
}

// actionDelay implements an Delay.
type actionDelay struct {
// actionImpl implement timeout and member id functions
actionImpl
}

// 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 *actionDelay) Start(ctx context.Context) (bool, error) {
return false, nil
}

func (a *actionDelay) CheckProgress(ctx context.Context) (bool, bool, error) {
v, ok := a.action.Params[DelayActionDuration]
if !ok {
a.log.Str("key", DelayActionDuration).Warn("Param for the delay not defined")
return true, false, nil
}

d, err := time.ParseDuration(v)
if err != nil {
a.log.Err(err).Str("value", v).Warn("Unable to parse duration")
return true, false, nil
}

if v := a.action.StartTime; v != nil {
if v.Time.Add(d).Before(time.Now()) {
return true, false, nil
}
}

return false, false, nil
}
0