Skip to content

Commit

Permalink
[Feature] PVCResize action concurrency limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ajanikow committed Aug 15, 2023
1 parent 147d6bf commit b6239c6
Show file tree
Hide file tree
Showing 42 changed files with 210 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Change Log

## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
- (Feature) PVCResize action concurrency limit

## [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
Expand Down
4 changes: 4 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import (
"github.com/arangodb/kube-arangodb/pkg/crd"
"github.com/arangodb/kube-arangodb/pkg/deployment/agency/cache"
"github.com/arangodb/kube-arangodb/pkg/deployment/features"
"github.com/arangodb/kube-arangodb/pkg/deployment/reconcile"
"github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme"
"github.com/arangodb/kube-arangodb/pkg/logging"
"github.com/arangodb/kube-arangodb/pkg/metrics/collector"
Expand Down Expand Up @@ -236,6 +237,9 @@ func init() {
if err := cache.Init(&cmdMain); err != nil {
panic(err.Error())
}
if err := reconcile.ActionsConfigGlobal.Init(&cmdMain); err != nil {
panic(err.Error())
}
}

func Execute() int {
Expand Down
43 changes: 43 additions & 0 deletions internal/actions.config.go.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- $root := . -}}
//
// Copyright 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 "github.com/spf13/cobra"

var ActionsConfigGlobal ActionsConfig

type ActionsConfig struct {
{{- range .configurable }}
// {{ . }} keeps configuration for action api.ActionType{{ . }}
{{ . }} Action{{ . }}Config
{{- end }}
}

// Init initializes all registered features.
// If a feature is not provided via process's argument, then it is taken from environment variable
// or from enabled by default setting.
func (a *ActionsConfig) Init(cmd *cobra.Command) error {
{{- range .configurable }}
if err := a.{{ . }}.Init(cmd); err != nil {
return err
}
{{- end }}
return nil
}
39 changes: 39 additions & 0 deletions internal/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ var actionsGoTemplate []byte
//go:embed actions.register.go.tmpl
var actionsRegisterGoTemplate []byte

//go:embed actions.config.go.tmpl
var actionsConfigGoTemplate []byte

//go:embed actions.register.test.go.tmpl
var actionsRegisterTestGoTemplate []byte

Expand Down Expand Up @@ -175,6 +178,16 @@ func (i ActionsInput) Timeouts() map[string]string {
return r
}

func (i ActionsInput) Configurable() []string {
var r []string
for k, a := range i.Actions {
if a.Configurable {
r = append(r, k)
}
}
return r
}

type Action struct {
Timeout *meta.Duration `json:"timeout,omitempty"`
StartupFailureGracePeriod *meta.Duration `json:"startupFailureGracePeriod,omitempty"`
Expand All @@ -188,6 +201,8 @@ type Action struct {
IsInternal bool `json:"isInternal"`

Optional bool `json:"optional"`

Configurable bool `json:"configurable"`
}

func (a Action) InScope(scope string) bool {
Expand Down Expand Up @@ -267,6 +282,30 @@ func RenderActions(root string) error {
}
}

{
actions := path.Join(root, "pkg", "deployment", "reconcile", "action.config.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(actionsConfigGoTemplate))
if err != nil {
return err
}

if err := i.Execute(out, map[string]interface{}{
"configurable": in.Configurable(),
}); err != nil {
return err
}

if err := out.Close(); err != nil {
return err
}
}

{
actions := path.Join(root, "pkg", "deployment", "reconcile", "action.register.generated_test.go")

Expand Down
1 change: 1 addition & 0 deletions internal/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ actions:
PVCResize:
description: Start the resize procedure. Updates PVC Requests field
timeout: 30m
configurable: true
PVCResized:
description: Waits for PVC resize to be completed
timeout: 15m
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/jwt.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/apis/deployment/v1/member_status_list.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/deployment/v2alpha1/member_status_list.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/acs/acs.community.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/chaos/monkey.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/member/state.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/members.community.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/pod/topology.community.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
38 changes: 38 additions & 0 deletions pkg/deployment/reconcile/action.config.generated.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Copyright 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 "github.com/spf13/cobra"

var ActionsConfigGlobal ActionsConfig

type ActionsConfig struct {
// PVCResize keeps configuration for action api.ActionTypePVCResize
PVCResize ActionPVCResizeConfig
}

// Init initializes all registered features.
// If a feature is not provided via process's argument, then it is taken from environment variable
// or from enabled by default setting.
func (a *ActionsConfig) Init(cmd *cobra.Command) error {
if err := a.PVCResize.Init(cmd); err != nil {
return err
}
return nil
}
2 changes: 1 addition & 1 deletion pkg/deployment/reconcile/action_bootstrap_set_password.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/reconcile/action_placeholder.community.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
13 changes: 13 additions & 0 deletions pkg/deployment/reconcile/action_pvc_resize.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package reconcile
import (
"context"

"github.com/spf13/cobra"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand All @@ -32,6 +33,18 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)

type ActionPVCResizeConfig struct {
Concurrency int
}

func (a *ActionPVCResizeConfig) Init(cmd *cobra.Command) error {
f := cmd.Flags()

f.IntVar(&a.Concurrency, "action.PVCResize.concurrency", 32, "Define limit of concurrent PVC Resizes on the cluster")

return nil
}

// newRotateMemberAction creates a new Action that implements the given
// planned RotateMember action.
func newPVCResizeAction(action api.Action, actionCtx ActionContext) Action {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Loading

0 comments on commit b6239c6

Please sign in to comment.