1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

[Improvement] ArangoDB image validation (=>3.10) for ARM64 architecture (#1161)

This commit is contained in:
jwierzbo 2022-11-07 16:14:32 +01:00 committed by GitHub
parent 60c7a35331
commit 2f94237256
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 48 additions and 11 deletions

View file

@ -14,6 +14,7 @@
- (Dependencies) Bump K8S Dependencies to 1.22.15 - (Dependencies) Bump K8S Dependencies to 1.22.15
- (Bugfix) Unlock broken inspectors - (Bugfix) Unlock broken inspectors
- (Debug) Allow to send package to stdout - (Debug) Allow to send package to stdout
- (Improvement) ArangoDB image validation (=>3.10) for ARM64 architecture
## [1.2.20](https://github.com/arangodb/kube-arangodb/tree/1.2.20) (2022-10-25) ## [1.2.20](https://github.com/arangodb/kube-arangodb/tree/1.2.20) (2022-10-25)
- (Feature) Add action progress - (Feature) Add action progress

View file

@ -39,7 +39,8 @@ ifndef KEEP_GOPATH
endif endif
GOBUILDARGS ?= GOBUILDARGS ?=
GOVERSION := 1.17-alpine3.15 GOBASEVERSION := 1.17
GOVERSION := $(GOBASEVERSION)-alpine3.15
DISTRIBUTION := alpine:3.15 DISTRIBUTION := alpine:3.15
PULSAR := $(GOBUILDDIR)/bin/pulsar$(shell go env GOEXE) PULSAR := $(GOBUILDDIR)/bin/pulsar$(shell go env GOEXE)
@ -482,7 +483,7 @@ patch-chart:
.PHONY: tidy .PHONY: tidy
tidy: tidy:
@go mod tidy @go mod tidy -compat=$(GOBASEVERSION)
.PHONY: deps-reload .PHONY: deps-reload
deps-reload: tidy init deps-reload: tidy init

View file

@ -78,6 +78,8 @@ const (
ConditionTypeUpgradeFailed ConditionType = "UpgradeFailed" ConditionTypeUpgradeFailed ConditionType = "UpgradeFailed"
// ConditionTypeArchitectureMismatch indicates that the member has a different architecture than the deployment. // ConditionTypeArchitectureMismatch indicates that the member has a different architecture than the deployment.
ConditionTypeArchitectureMismatch ConditionType = "ArchitectureMismatch" ConditionTypeArchitectureMismatch ConditionType = "ArchitectureMismatch"
// ConditionTypeArchitectureChangeCannotBeApplied indicates that the member has a different architecture than the requested one.
ConditionTypeArchitectureChangeCannotBeApplied ConditionType = "ArchitectureChangeCannotBeApplied"
// ConditionTypeMemberMaintenanceMode indicates that Maintenance is enabled on particular member // ConditionTypeMemberMaintenanceMode indicates that Maintenance is enabled on particular member
ConditionTypeMemberMaintenanceMode ConditionType = "MemberMaintenanceMode" ConditionTypeMemberMaintenanceMode ConditionType = "MemberMaintenanceMode"

View file

@ -103,6 +103,7 @@ func removeMemberConditionsMapFunc(m *api.MemberStatus) {
m.Conditions.Remove(api.MemberReplacementRequired) m.Conditions.Remove(api.MemberReplacementRequired)
m.Conditions.Remove(api.ConditionTypePVCResizePending) m.Conditions.Remove(api.ConditionTypePVCResizePending)
m.Conditions.Remove(api.ConditionTypeArchitectureMismatch) m.Conditions.Remove(api.ConditionTypeArchitectureMismatch)
m.Conditions.Remove(api.ConditionTypeArchitectureChangeCannotBeApplied)
m.RemoveTerminationsBefore(time.Now().Add(-1 * recentTerminationsKeepPeriod)) m.RemoveTerminationsBefore(time.Now().Add(-1 * recentTerminationsKeepPeriod))

View file

@ -30,6 +30,7 @@ import (
"github.com/arangodb/kube-arangodb/pkg/apis/shared" "github.com/arangodb/kube-arangodb/pkg/apis/shared"
"github.com/arangodb/kube-arangodb/pkg/deployment/reconcile" "github.com/arangodb/kube-arangodb/pkg/deployment/reconcile"
"github.com/arangodb/kube-arangodb/pkg/util/errors" "github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
) )
func (d *Deployment) createAgencyMapping(ctx context.Context) error { func (d *Deployment) createAgencyMapping(ctx context.Context) error {
@ -127,7 +128,13 @@ func (d *Deployment) renderMember(spec api.DeploymentSpec, status *api.Deploymen
} }
deploymentName := apiObject.GetName() deploymentName := apiObject.GetName()
role := group.AsRole() role := group.AsRole()
arch := apiObject.GetAcceptedSpec().Architecture.GetDefault() arch := apiObject.GetAcceptedSpec().Architecture.GetDefault()
if arch != api.ArangoDeploymentArchitectureAMD64 && apiObject.Status.CurrentImage.ArangoDBVersion.CompareTo("3.10.0") < 0 {
arch = api.ArangoDeploymentArchitectureAMD64
d.log.Str("arch", string(arch)).Warn("Cannot render pod with requested arch. It's not supported in ArangoDB < 3.10.0. Defaulting architecture to AMD64")
d.CreateEvent(k8sutil.NewCannotSetArchitectureEvent(d.GetAPIObject(), string(arch), id))
}
switch group { switch group {
case api.ServerGroupSingle: case api.ServerGroupSingle:

View file

@ -32,6 +32,8 @@ import (
// PlanBuilderContext contains context methods provided to plan builders. // PlanBuilderContext contains context methods provided to plan builders.
type PlanBuilderContext interface { type PlanBuilderContext interface {
reconciler.DeploymentStatusUpdate
reconciler.DeploymentInfoGetter reconciler.DeploymentInfoGetter
reconciler.DeploymentAgencyMaintenance reconciler.DeploymentAgencyMaintenance
reconciler.ArangoMemberContext reconciler.ArangoMemberContext

View file

@ -22,6 +22,7 @@ package reconcile
import ( import (
"context" "context"
"fmt"
"github.com/arangodb/kube-arangodb/pkg/apis/deployment" "github.com/arangodb/kube-arangodb/pkg/apis/deployment"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
@ -45,15 +46,28 @@ func (r *Reconciler) createChangeMemberArchPlan(ctx context.Context,
if pod, ok := cache.Pod().V1().GetSimple(member.Pod.GetName()); ok { if pod, ok := cache.Pod().V1().GetSimple(member.Pod.GetName()); ok {
if v, ok := pod.GetAnnotations()[deployment.ArangoDeploymentPodChangeArchAnnotation]; ok { if v, ok := pod.GetAnnotations()[deployment.ArangoDeploymentPodChangeArchAnnotation]; ok {
arch := api.ArangoDeploymentArchitectureType(v) archToApply := api.ArangoDeploymentArchitectureType(v)
if arch.IsArchMismatch(spec.Architecture, member.Architecture) { if archToApply.IsArchMismatch(spec.Architecture, member.Architecture) {
r.log. if archToApply != api.ArangoDeploymentArchitectureAMD64 && status.CurrentImage.ArangoDBVersion.CompareTo("3.10.0") < 0 {
Str("pod-name", member.Pod.GetName()). if member.Conditions.Update(api.ConditionTypeArchitectureChangeCannotBeApplied, true,
Str("server-group", m.Group.AsRole()). fmt.Sprintf("Member has ArangoDB in version which not supports Architecture change (%s)", archToApply), "") {
Warn("try changing an Architecture type, but %s", getRequiredRotateMessage(member.Pod.GetName())) r.log.Warn("Cannot apply 'arch' annotation changes. It's not supported in ArangoDB < 3.10.0")
p = append(p, context.CreateEvent(k8sutil.NewCannotSetArchitectureEvent(apiObject, string(archToApply), member.ID))
actions.NewAction(api.ActionTypeSetCurrentMemberArch, m.Group, member, "Architecture Mismatch").SetArch(arch), context.CreateEvent(k8sutil.NewCannotSetArchitectureEvent(pod, string(archToApply), member.ID))
)
if err := context.UpdateMember(ctx, member); err != nil {
r.log.Error("Can not save member condition", member.ID, api.ConditionTypeArchitectureChangeCannotBeApplied, err)
}
}
} else {
r.log.
Str("pod-name", member.Pod.GetName()).
Str("server-group", m.Group.AsRole()).
Warn("try changing an Architecture type, but %s", getRequiredRotateMessage(member.Pod.GetName()))
p = append(p,
actions.NewAction(api.ActionTypeSetCurrentMemberArch, m.Group, member, "Architecture Mismatch").SetArch(archToApply),
)
}
} }
} }
} }

View file

@ -283,3 +283,12 @@ func NewOperatorEngineOpsAlertEvent(reason string, apiObject APIObject) *Event {
event.Message = fmt.Sprintf("Event OperatorEngineOpsAlert raised, investigation needed: %s", reason) event.Message = fmt.Sprintf("Event OperatorEngineOpsAlert raised, investigation needed: %s", reason)
return event return event
} }
// NewCannotSetArchitectureEvent creates an even of type CannotSetArchitectureEvent.
func NewCannotSetArchitectureEvent(apiObject runtime.Object, arch, memberId string) *Event {
event := newDeploymentEvent(apiObject)
event.Type = core.EventTypeWarning
event.Reason = "Can not set architecture"
event.Message = fmt.Sprintf("Can not apply %s arch for member %s. It is not supported in current ArangoDB version", arch, memberId)
return event
}