Skip to content

Commit 282a50e

Browse files
authored
[Feature] Deprecate Actions (#1383)
1 parent 90aca02 commit 282a50e

20 files changed

+596
-469
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- (Maintenance) Bump golang.org/x/net to v0.13.0
55
- (Feature) PVCResize action concurrency limit
66
- (Feature) Optional Assertions
7+
- (Feature) Deprecate Actions
78

89
## [1.2.32](https://github.com/arangodb/kube-arangodb/tree/1.2.32) (2023-08-07)
910
- (Feature) Backup lifetime - remove Backup once its lifetime has been reached

docs/generated/actions.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
| CleanTLSCACertificate | no | 30m0s | no | Enterprise Only | Remove Certificate from CA TrustStore |
1919
| CleanTLSKeyfileCertificate | no | 30m0s | no | Enterprise Only | Remove old TLS certificate from server |
2020
| ClusterMemberCleanup | no | 10m0s | no | Community & Enterprise | Remove member from Cluster if it is gone already (Coordinators) |
21-
| DisableClusterScaling | no | 10m0s | no | Community & Enterprise | (Deprecated) Disable Cluster Scaling integration |
21+
| ~~DisableClusterScaling~~ | no | 10m0s | no | Community & Enterprise | Disable Cluster Scaling integration |
2222
| DisableMaintenance | no | 10m0s | no | Community & Enterprise | Disable ArangoDB maintenance mode |
2323
| DisableMemberMaintenance | no | 10m0s | no | Enterprise Only | Disable ArangoDB DBServer maintenance mode |
24-
| EnableClusterScaling | no | 10m0s | no | Community & Enterprise | (Deprecated) Enable Cluster Scaling integration |
24+
| ~~EnableClusterScaling~~ | no | 10m0s | no | Community & Enterprise | Enable Cluster Scaling integration |
2525
| EnableMaintenance | no | 10m0s | no | Community & Enterprise | Enable ArangoDB maintenance mode |
2626
| EnableMemberMaintenance | no | 10m0s | no | Enterprise Only | Enable ArangoDB DBServer maintenance mode |
2727
| EncryptionKeyAdd | no | 10m0s | no | Enterprise Only | Add the encryption key to the pool |
@@ -40,7 +40,7 @@
4040
| LicenseSet | no | 10m0s | no | Community & Enterprise | Update Cluster license (3.9+) |
4141
| MarkToRemoveMember | no | 10m0s | no | Community & Enterprise | Marks member to be removed. Used when member Pod is annotated with replace annotation |
4242
| MemberPhaseUpdate | no | 10m0s | no | Community & Enterprise | Change member phase |
43-
| MemberRIDUpdate | no | 10m0s | no | Community & Enterprise | Update Run ID of member |
43+
| ~~MemberRIDUpdate~~ | no | 10m0s | no | Community & Enterprise | Update Run ID of member |
4444
| PVCResize | no | 30m0s | no | Community & Enterprise | Start the resize procedure. Updates PVC Requests field |
4545
| PVCResized | no | 15m0s | no | Community & Enterprise | Waits for PVC resize to be completed |
4646
| PlaceHolder | no | 10m0s | no | Community & Enterprise | Empty placeholder action |
@@ -65,12 +65,12 @@
6565
| RuntimeContainerArgsLogLevelUpdate | no | 10m0s | no | Community & Enterprise | Change ArangoDB Member log levels in runtime |
6666
| RuntimeContainerImageUpdate | no | 10m0s | no | Community & Enterprise | Update Container Image in runtime |
6767
| RuntimeContainerSyncTolerations | no | 10m0s | no | Community & Enterprise | Update Pod Tolerations in runtime |
68-
| SetCondition | no | 10m0s | no | Community & Enterprise | (Deprecated) Set deployment condition |
68+
| ~~SetCondition~~ | no | 10m0s | no | Community & Enterprise | Set deployment condition |
6969
| SetConditionV2 | no | 10m0s | no | Community & Enterprise | Set deployment condition |
7070
| SetCurrentImage | no | 6h0m0s | no | Community & Enterprise | Update deployment current image after image discovery |
7171
| SetCurrentMemberArch | no | 10m0s | no | Community & Enterprise | Set current member architecture |
7272
| SetMaintenanceCondition | no | 10m0s | no | Community & Enterprise | Update ArangoDB maintenance condition |
73-
| SetMemberCondition | no | 10m0s | no | Community & Enterprise | (Deprecated) Set member condition |
73+
| ~~SetMemberCondition~~ | no | 10m0s | no | Community & Enterprise | Set member condition |
7474
| SetMemberConditionV2 | no | 10m0s | no | Community & Enterprise | Set member condition |
7575
| SetMemberCurrentImage | no | 10m0s | no | Community & Enterprise | Update Member current image |
7676
| ShutdownMember | no | 30m0s | no | Community & Enterprise | Sends Shutdown requests and waits for container to be stopped |

internal/actions.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434

3535
"github.com/arangodb/kube-arangodb/internal/md"
3636
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
37+
"github.com/arangodb/kube-arangodb/pkg/util"
3738
"github.com/arangodb/kube-arangodb/pkg/util/strings"
3839
)
3940

@@ -188,6 +189,14 @@ func (i ActionsInput) Configurable() []string {
188189
return r
189190
}
190191

192+
func (i ActionsInput) Deprecated() map[string]string {
193+
r := map[string]string{}
194+
for k, a := range i.Actions {
195+
r[k] = util.TypeOrDefault(a.Deprecated, "")
196+
}
197+
return r
198+
}
199+
191200
type Action struct {
192201
Timeout *meta.Duration `json:"timeout,omitempty"`
193202
StartupFailureGracePeriod *meta.Duration `json:"startupFailureGracePeriod,omitempty"`
@@ -203,6 +212,8 @@ type Action struct {
203212
Optional bool `json:"optional"`
204213

205214
Configurable bool `json:"configurable"`
215+
216+
Deprecated *string `json:"deprecated"`
206217
}
207218

208219
func (a Action) InScope(scope string) bool {
@@ -247,6 +258,7 @@ func RenderActions(root string) error {
247258
"timeouts": in.Timeouts(),
248259
"descriptions": in.Descriptions(),
249260
"optionals": in.Optionals(),
261+
"deprecated": in.Deprecated(),
250262
"defaultTimeout": fmt.Sprintf("%d * time.Second // %s", in.DefaultTimeout.Duration/time.Second, in.DefaultTimeout.Duration.String()),
251263
}); err != nil {
252264
return err
@@ -273,6 +285,7 @@ func RenderActions(root string) error {
273285
if err := i.Execute(out, map[string]interface{}{
274286
"actions": in.Keys(),
275287
"startupFailureGracePeriods": in.StartFailureGracePeriods(),
288+
"deprecated": in.Deprecated(),
276289
}); err != nil {
277290
return err
278291
}
@@ -324,6 +337,7 @@ func RenderActions(root string) error {
324337
"startupFailureGracePeriods": in.StartFailureGracePeriods(),
325338
"internal": in.Internal(),
326339
"optional": in.Optionals(),
340+
"deprecated": in.Deprecated(),
327341
}); err != nil {
328342
return err
329343
}
@@ -352,6 +366,11 @@ func RenderActions(root string) error {
352366
)
353367

354368
for _, k := range in.Keys() {
369+
name := k
370+
if in.Actions[k].Deprecated != nil {
371+
name = fmt.Sprintf("~~%s~~", name)
372+
}
373+
355374
a := in.Actions[k]
356375
v := in.DefaultTimeout.Duration.String()
357376
if t := a.Timeout; t != nil {
@@ -372,7 +391,7 @@ func RenderActions(root string) error {
372391
}
373392

374393
if err := t.AddRow(map[md.Column]string{
375-
action: k,
394+
action: name,
376395
timeout: v,
377396
description: a.Description,
378397
edition: vr,

internal/actions.go.tmpl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,23 @@ const (
2626

2727
// ActionsDefaultTimeout define default timeout
2828
ActionsDefaultTimeout time.Duration = {{ $root.defaultTimeout }}
29-
{{- range .actions }}
29+
30+
{{ range .actions -}}
3031
// Action{{ . }}DefaultTimeout define default timeout for action Action{{ . }}
3132
Action{{ . }}DefaultTimeout time.Duration = {{ index $root.timeouts . }}
32-
{{- end }}
3333

34+
{{ end }}
3435
// Actions
35-
{{ range .actions }}
36+
37+
{{ range .actions -}}
3638
// ActionType{{ . }} in scopes {{ index $root.scopes . }}. {{ index $root.descriptions . }}
39+
{{ if (index $root.deprecated .) -}}
40+
//
41+
// Deprecated: {{ index $root.deprecated . }}
42+
{{ end -}}
3743
ActionType{{ . }} ActionType = "{{ . }}"
38-
{{- end }}
44+
45+
{{ end -}}
3946
)
4047

4148
func (a ActionType) DefaultTimeout() time.Duration {

internal/actions.register.go.tmpl

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,47 @@ import (
2727
var (
2828
// Ensure implementation
2929
{{- range .actions }}
30+
{{- if not (index $root.deprecated .) }}
3031

3132
_ Action = &action{{ . }}{}
3233
_ actionFactory = new{{ . }}Action
3334
{{- end }}
35+
{{- end }}
3436
)
3537

3638
func init() {
3739
// Register all actions
38-
{{- range .actions }}
3940

41+
{{ range .actions -}}
4042
// {{ . }}
4143
{
44+
// Get Action type
45+
{{ if (index $root.deprecated .) -}}
46+
// nolint:staticcheck
47+
{{ end -}}
48+
action := api.ActionType{{ . }}
49+
50+
{{ if (index $root.deprecated .) -}}
51+
// Get Empty (Deprecated) Action Definition
52+
function := newDeprecatedAction
53+
54+
{{ else -}}
4255
// Get Action defition
4356
function := new{{ . }}Action
44-
action := api.ActionType{{ . }}
4557

4658
// Wrap action main function
47-
{{- $startupFailureGracePeriod := index $root.startupFailureGracePeriods . -}}
48-
{{- if $startupFailureGracePeriod }}
59+
60+
{{ $startupFailureGracePeriod := index $root.startupFailureGracePeriods . -}}
61+
{{ if $startupFailureGracePeriod -}}
62+
// With StartupFailureGracePeriod
4963
function = withActionStartFailureGracePeriod(function, {{ $startupFailureGracePeriod }})
50-
{{- end }}
64+
65+
{{ end -}}
66+
{{ end -}}
5167

5268
// Register action
5369
registerAction(action, function)
5470
}
55-
{{- end }}
71+
72+
{{ end -}}
5673
}

internal/actions.register.test.go.tmpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,19 @@ func Test_Actions(t *testing.T) {
3333
{{- range .actions }}
3434

3535
t.Run("{{ . }}", func(t *testing.T) {
36+
{{ if (index $root.deprecated .) -}}
37+
// nolint:staticcheck
38+
{{ end -}}
3639
ActionsExistence(t, api.ActionType{{ . }})
3740
{{- $startupFailureGracePeriod := index $root.startupFailureGracePeriods . -}}
3841
{{- if $startupFailureGracePeriod }}
3942
ActionsWrapWithActionStartFailureGracePeriod(t, api.ActionType{{ . }}, {{ $startupFailureGracePeriod }})
4043
{{- end }}
4144
{{- $isInternal := index $root.internal . }}
4245
t.Run("Internal", func(t *testing.T) {
46+
{{- if (index $root.deprecated .) }}
47+
// nolint:staticcheck
48+
{{- end }}
4349
{{- if $isInternal }}
4450
require.True(t, api.ActionType{{ . }}.Internal())
4551
{{- else }}
@@ -48,6 +54,9 @@ func Test_Actions(t *testing.T) {
4854
})
4955
{{- $isOptional := index $root.optional . }}
5056
t.Run("Optional", func(t *testing.T) {
57+
{{- if (index $root.deprecated .) }}
58+
// nolint:staticcheck
59+
{{- end }}
5160
{{- if $isOptional }}
5261
require.True(t, api.ActionType{{ . }}.Optional())
5362
{{- else }}

internal/actions.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ actions:
100100
SetMemberCurrentImage:
101101
description: Update Member current image
102102
DisableClusterScaling:
103-
description: (Deprecated) Disable Cluster Scaling integration
103+
description: Disable Cluster Scaling integration
104+
deprecated: "action is not used anymore"
104105
EnableClusterScaling:
105-
description: (Deprecated) Enable Cluster Scaling integration
106+
description: Enable Cluster Scaling integration
107+
deprecated: "action is not used anymore"
106108
PVCResize:
107109
description: Start the resize procedure. Updates PVC Requests field
108110
timeout: 30m
@@ -176,17 +178,19 @@ actions:
176178
scopes:
177179
- High
178180
SetMemberCondition:
179-
description: (Deprecated) Set member condition
181+
description: Set member condition
180182
scopes:
181183
- High
184+
deprecated: "action is not used anymore"
182185
SetMemberConditionV2:
183186
description: Set member condition
184187
scopes:
185188
- High
186189
SetCondition:
187-
description: (Deprecated) Set deployment condition
190+
description: Set deployment condition
188191
scopes:
189192
- High
193+
deprecated: "action is not used anymore"
190194
SetConditionV2:
191195
description: Set deployment condition
192196
scopes:
@@ -195,6 +199,7 @@ actions:
195199
description: Update Run ID of member
196200
scopes:
197201
- High
202+
deprecated: "action is not used anymore"
198203
ArangoMemberUpdatePodSpec:
199204
description: Propagate Member Pod spec (requested)
200205
scopes:

0 commit comments

Comments
 (0)