Skip to content

Commit a1eeaac

Browse files
authored
[Feature] Add ArangoMember Message and extend ArangoMember CRD (#1464)
1 parent 00889b3 commit a1eeaac

11 files changed

+85
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- (Documentation) Update ArangoDeploymentReplication and ArangoLocalStorage CR auto-generated docs
1313
- (Feature) Member Memory Reservation
1414
- (Documentation) Update ArangoDeploymentReplication and ArangoLocalStorage CR auto-generated docs
15+
- (Feature) Add ArangoMember Message and extend ArangoMember CRD
1516

1617
## [1.2.34](https://github.com/arangodb/kube-arangodb/tree/1.2.34) (2023-10-16)
1718
- (Bugfix) Fix make manifests-crd-file command

pkg/apis/deployment/v1/arango_member_status.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,18 @@
2020

2121
package v1
2222

23+
import meta "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
2325
type ArangoMemberStatus struct {
2426
Conditions ConditionList `json:"conditions,omitempty"`
2527

2628
Template *ArangoMemberPodTemplate `json:"template,omitempty"`
29+
30+
// Message keeps the information about time when ArangoMember Status was modified last time
31+
LastUpdateTime meta.Time `json:"lastUpdateTime,omitempty"`
32+
33+
// Message keeps the information about ArangoMember Message in the String format
34+
Message string `json:"message,omitempty"`
2735
}
2836

2937
func (a ArangoMemberStatus) InSync(status MemberStatus) bool {

pkg/apis/deployment/v1/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/deployment/v2alpha1/arango_member_status.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,18 @@
2020

2121
package v2alpha1
2222

23+
import meta "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
2325
type ArangoMemberStatus struct {
2426
Conditions ConditionList `json:"conditions,omitempty"`
2527

2628
Template *ArangoMemberPodTemplate `json:"template,omitempty"`
29+
30+
// Message keeps the information about time when ArangoMember Status was modified last time
31+
LastUpdateTime meta.Time `json:"lastUpdateTime,omitempty"`
32+
33+
// Message keeps the information about ArangoMember Message in the String format
34+
Message string `json:"message,omitempty"`
2735
}
2836

2937
func (a ArangoMemberStatus) InSync(status MemberStatus) bool {

pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/deployment/reconcile/action_arango_member_update_pod_spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (a *actionArangoMemberUpdatePodSpec) Start(ctx context.Context) (bool, erro
130130
return false, err
131131
}
132132

133-
if err := inspector.WithArangoMemberStatusUpdate(ctx, cache, name, func(member *api.ArangoMember) (bool, error) {
133+
if err := WithArangoMemberStatusUpdate(ctx, cache, name, func(member *api.ArangoMember) (bool, error) {
134134
if (member.Status.Template == nil || member.Status.Template.PodSpec == nil) && (m.Pod == nil || m.Pod.SpecVersion == "" || m.Pod.SpecVersion == template.PodSpecChecksum) {
135135
member.Status.Template = template.DeepCopy()
136136
}

pkg/deployment/reconcile/action_arango_member_update_pod_status.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@ import (
2525

2626
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
2727
"github.com/arangodb/kube-arangodb/pkg/util/errors"
28-
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
2928
)
3029

3130
const (
@@ -83,7 +82,7 @@ func (a *actionArangoMemberUpdatePodStatus) Start(ctx context.Context) (bool, er
8382
}
8483

8584
if member.Status.Template == nil || !member.Status.Template.Equals(member.Spec.Template) {
86-
if err := inspector.WithArangoMemberStatusUpdate(ctx, cache, name, func(in *api.ArangoMember) (bool, error) {
85+
if err := WithArangoMemberStatusUpdate(ctx, cache, name, func(in *api.ArangoMember) (bool, error) {
8786
if in.Status.Template == nil || !in.Status.Template.Equals(member.Spec.Template) {
8887
in.Status.Template = member.Spec.Template.DeepCopy()
8988
return true, nil

pkg/deployment/reconcile/action_member_status_sync.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ package reconcile
2323
import (
2424
"context"
2525

26-
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
27-
2826
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
2927
"github.com/arangodb/kube-arangodb/pkg/util/errors"
30-
"github.com/arangodb/kube-arangodb/pkg/util/globals"
3128
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
3229
)
3330

@@ -77,19 +74,10 @@ func (a *actionMemberStatusSync) Start(ctx context.Context) (bool, error) {
7774
return true, nil
7875
}
7976

80-
amemberc := amember.DeepCopy()
81-
if amemberc.Status.Propagate(m) {
82-
// Change applied
83-
nctx, c := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
84-
defer c()
85-
86-
if _, err := cache.ArangoMemberModInterface().V1().UpdateStatus(nctx, amemberc, meta.UpdateOptions{}); err != nil {
87-
return false, errors.WithStack(err)
88-
}
89-
90-
if err := cache.Refresh(nctx); err != nil {
91-
return false, errors.WithStack(err)
92-
}
77+
if err := WithArangoMemberStatusUpdate(ctx, cache, amember.GetName(), func(in *api.ArangoMember) (bool, error) {
78+
return in.Status.Propagate(m), nil
79+
}); err != nil {
80+
return false, errors.WithStack(err)
9381
}
9482

9583
return true, nil

pkg/deployment/reconcile/action_runtime_container_args_udpate.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -32,7 +32,6 @@ import (
3232
"github.com/arangodb/kube-arangodb/pkg/deployment/rotation"
3333
"github.com/arangodb/kube-arangodb/pkg/util/globals"
3434
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
35-
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
3635
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
3736
)
3837

@@ -107,7 +106,7 @@ func (a actionRuntimeContainerArgsLogLevelUpdate) Post(ctx context.Context) erro
107106
return false, nil
108107
}
109108

110-
err := inspector.WithArangoMemberStatusUpdate(ctx, cache, memberName, updateMemberStatusArgs)
109+
err := WithArangoMemberStatusUpdate(ctx, cache, memberName, updateMemberStatusArgs)
111110
if err != nil {
112111
return errors.WithMessage(err, "Error while updating member status")
113112
}

pkg/deployment/reconcile/action_runtime_container_image_update.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"github.com/arangodb/kube-arangodb/pkg/deployment/rotation"
3232
"github.com/arangodb/kube-arangodb/pkg/util/errors"
3333
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
34-
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
3534
)
3635

3736
func newRuntimeContainerImageUpdateAction(action api.Action, actionCtx ActionContext) Action {
@@ -121,7 +120,7 @@ func (a actionRuntimeContainerImageUpdate) Post(ctx context.Context) error {
121120
return err
122121
}
123122

124-
return inspector.WithArangoMemberStatusUpdate(ctx, cache, name, func(in *api.ArangoMember) (bool, error) {
123+
return WithArangoMemberStatusUpdate(ctx, cache, name, func(in *api.ArangoMember) (bool, error) {
125124
if in.Spec.Template == nil || in.Status.Template == nil ||
126125
in.Spec.Template.PodSpec == nil || in.Status.Template.PodSpec == nil {
127126
a.log.Info("Nil Member definition")

0 commit comments

Comments
 (0)