mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] Add ArangoMember Message and extend ArangoMember CRD (#1464)
This commit is contained in:
parent
00889b3100
commit
a1eeaace59
11 changed files with 85 additions and 25 deletions
|
@ -12,6 +12,7 @@
|
|||
- (Documentation) Update ArangoDeploymentReplication and ArangoLocalStorage CR auto-generated docs
|
||||
- (Feature) Member Memory Reservation
|
||||
- (Documentation) Update ArangoDeploymentReplication and ArangoLocalStorage CR auto-generated docs
|
||||
- (Feature) Add ArangoMember Message and extend ArangoMember CRD
|
||||
|
||||
## [1.2.34](https://github.com/arangodb/kube-arangodb/tree/1.2.34) (2023-10-16)
|
||||
- (Bugfix) Fix make manifests-crd-file command
|
||||
|
|
|
@ -20,10 +20,18 @@
|
|||
|
||||
package v1
|
||||
|
||||
import meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
type ArangoMemberStatus struct {
|
||||
Conditions ConditionList `json:"conditions,omitempty"`
|
||||
|
||||
Template *ArangoMemberPodTemplate `json:"template,omitempty"`
|
||||
|
||||
// Message keeps the information about time when ArangoMember Status was modified last time
|
||||
LastUpdateTime meta.Time `json:"lastUpdateTime,omitempty"`
|
||||
|
||||
// Message keeps the information about ArangoMember Message in the String format
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func (a ArangoMemberStatus) InSync(status MemberStatus) bool {
|
||||
|
|
1
pkg/apis/deployment/v1/zz_generated.deepcopy.go
generated
1
pkg/apis/deployment/v1/zz_generated.deepcopy.go
generated
|
@ -599,6 +599,7 @@ func (in *ArangoMemberStatus) DeepCopyInto(out *ArangoMemberStatus) {
|
|||
*out = new(ArangoMemberPodTemplate)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,18 @@
|
|||
|
||||
package v2alpha1
|
||||
|
||||
import meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
type ArangoMemberStatus struct {
|
||||
Conditions ConditionList `json:"conditions,omitempty"`
|
||||
|
||||
Template *ArangoMemberPodTemplate `json:"template,omitempty"`
|
||||
|
||||
// Message keeps the information about time when ArangoMember Status was modified last time
|
||||
LastUpdateTime meta.Time `json:"lastUpdateTime,omitempty"`
|
||||
|
||||
// Message keeps the information about ArangoMember Message in the String format
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func (a ArangoMemberStatus) InSync(status MemberStatus) bool {
|
||||
|
|
|
@ -599,6 +599,7 @@ func (in *ArangoMemberStatus) DeepCopyInto(out *ArangoMemberStatus) {
|
|||
*out = new(ArangoMemberPodTemplate)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ func (a *actionArangoMemberUpdatePodSpec) Start(ctx context.Context) (bool, erro
|
|||
return false, err
|
||||
}
|
||||
|
||||
if err := inspector.WithArangoMemberStatusUpdate(ctx, cache, name, func(member *api.ArangoMember) (bool, error) {
|
||||
if err := WithArangoMemberStatusUpdate(ctx, cache, name, func(member *api.ArangoMember) (bool, error) {
|
||||
if (member.Status.Template == nil || member.Status.Template.PodSpec == nil) && (m.Pod == nil || m.Pod.SpecVersion == "" || m.Pod.SpecVersion == template.PodSpecChecksum) {
|
||||
member.Status.Template = template.DeepCopy()
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
@ -25,7 +25,6 @@ import (
|
|||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -83,7 +82,7 @@ func (a *actionArangoMemberUpdatePodStatus) Start(ctx context.Context) (bool, er
|
|||
}
|
||||
|
||||
if member.Status.Template == nil || !member.Status.Template.Equals(member.Spec.Template) {
|
||||
if err := inspector.WithArangoMemberStatusUpdate(ctx, cache, name, func(in *api.ArangoMember) (bool, error) {
|
||||
if err := WithArangoMemberStatusUpdate(ctx, cache, name, func(in *api.ArangoMember) (bool, error) {
|
||||
if in.Status.Template == nil || !in.Status.Template.Equals(member.Spec.Template) {
|
||||
in.Status.Template = member.Spec.Template.DeepCopy()
|
||||
return true, nil
|
||||
|
|
|
@ -23,11 +23,8 @@ package reconcile
|
|||
import (
|
||||
"context"
|
||||
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/globals"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
|
||||
)
|
||||
|
||||
|
@ -77,19 +74,10 @@ func (a *actionMemberStatusSync) Start(ctx context.Context) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
amemberc := amember.DeepCopy()
|
||||
if amemberc.Status.Propagate(m) {
|
||||
// Change applied
|
||||
nctx, c := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
|
||||
defer c()
|
||||
|
||||
if _, err := cache.ArangoMemberModInterface().V1().UpdateStatus(nctx, amemberc, meta.UpdateOptions{}); err != nil {
|
||||
return false, errors.WithStack(err)
|
||||
}
|
||||
|
||||
if err := cache.Refresh(nctx); err != nil {
|
||||
return false, errors.WithStack(err)
|
||||
}
|
||||
if err := WithArangoMemberStatusUpdate(ctx, cache, amember.GetName(), func(in *api.ArangoMember) (bool, error) {
|
||||
return in.Status.Propagate(m), nil
|
||||
}); err != nil {
|
||||
return false, errors.WithStack(err)
|
||||
}
|
||||
|
||||
return true, nil
|
||||
|
|
|
@ -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.
|
||||
|
@ -32,7 +32,6 @@ import (
|
|||
"github.com/arangodb/kube-arangodb/pkg/deployment/rotation"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/globals"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
|
||||
)
|
||||
|
||||
|
@ -107,7 +106,7 @@ func (a actionRuntimeContainerArgsLogLevelUpdate) Post(ctx context.Context) erro
|
|||
return false, nil
|
||||
}
|
||||
|
||||
err := inspector.WithArangoMemberStatusUpdate(ctx, cache, memberName, updateMemberStatusArgs)
|
||||
err := WithArangoMemberStatusUpdate(ctx, cache, memberName, updateMemberStatusArgs)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "Error while updating member status")
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import (
|
|||
"github.com/arangodb/kube-arangodb/pkg/deployment/rotation"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
|
||||
)
|
||||
|
||||
func newRuntimeContainerImageUpdateAction(action api.Action, actionCtx ActionContext) Action {
|
||||
|
@ -121,7 +120,7 @@ func (a actionRuntimeContainerImageUpdate) Post(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
return inspector.WithArangoMemberStatusUpdate(ctx, cache, name, func(in *api.ArangoMember) (bool, error) {
|
||||
return WithArangoMemberStatusUpdate(ctx, cache, name, func(in *api.ArangoMember) (bool, error) {
|
||||
if in.Spec.Template == nil || in.Status.Template == nil ||
|
||||
in.Spec.Template.PodSpec == nil || in.Status.Template.PodSpec == nil {
|
||||
a.log.Info("Nil Member definition")
|
||||
|
|
56
pkg/deployment/reconcile/helper_member.go
Normal file
56
pkg/deployment/reconcile/helper_member.go
Normal file
|
@ -0,0 +1,56 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// 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 (
|
||||
"context"
|
||||
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
|
||||
)
|
||||
|
||||
func WithArangoMemberStatusUpdate(ctx context.Context, client inspector.ArangoMemberUpdateInterface, name string, f inspector.ArangoMemberUpdateFunc) error {
|
||||
return inspector.WithArangoMemberStatusUpdate(ctx, client, name, func(in *api.ArangoMember) (bool, error) {
|
||||
if changed, err := f(in); err != nil {
|
||||
return false, err
|
||||
} else if !changed {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// Update Status
|
||||
|
||||
postArangoMemberStatusUpdate(in)
|
||||
|
||||
return true, nil
|
||||
})
|
||||
}
|
||||
|
||||
func postArangoMemberStatusUpdate(in *api.ArangoMember) {
|
||||
in.Status.LastUpdateTime = meta.Now()
|
||||
|
||||
if in.Status.Conditions.IsTrue(api.ConditionTypeReady) {
|
||||
in.Status.Message = "Member is Ready"
|
||||
} else {
|
||||
in.Status.Message = "Member is Not Ready"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue