mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] Alternative Upgrade Order (#1731)
This commit is contained in:
parent
459462b0dc
commit
9f0e5c5713
6 changed files with 70 additions and 3 deletions
|
@ -35,6 +35,7 @@
|
||||||
- (Improvement) Improve Metrics Handling
|
- (Improvement) Improve Metrics Handling
|
||||||
- (Feature) (Scheduler) Create Integration Profile
|
- (Feature) (Scheduler) Create Integration Profile
|
||||||
- (Feature) (Scheduler) Additional types
|
- (Feature) (Scheduler) Additional types
|
||||||
|
- (Feature) Alternative Upgrade Order Feature
|
||||||
|
|
||||||
## [1.2.42](https://github.com/arangodb/kube-arangodb/tree/1.2.42) (2024-07-23)
|
## [1.2.42](https://github.com/arangodb/kube-arangodb/tree/1.2.42) (2024-07-23)
|
||||||
- (Maintenance) Go 1.22.4 & Kubernetes 1.29.6 libraries
|
- (Maintenance) Go 1.22.4 & Kubernetes 1.29.6 libraries
|
||||||
|
|
|
@ -23,6 +23,7 @@ package features
|
||||||
func init() {
|
func init() {
|
||||||
registerFeature(upgradeVersionCheck)
|
registerFeature(upgradeVersionCheck)
|
||||||
registerFeature(upgradeVersionCheckV2)
|
registerFeature(upgradeVersionCheckV2)
|
||||||
|
registerFeature(upgradeAlternativeOrder)
|
||||||
}
|
}
|
||||||
|
|
||||||
var upgradeVersionCheck Feature = &feature{
|
var upgradeVersionCheck Feature = &feature{
|
||||||
|
@ -39,6 +40,14 @@ var upgradeVersionCheckV2 Feature = &feature{
|
||||||
enabledByDefault: false,
|
enabledByDefault: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var upgradeAlternativeOrder Feature = &feature{
|
||||||
|
name: "upgrade-alternative-order",
|
||||||
|
description: "Changes order of the upgrade process - Coordinators are upgraded before DBServers",
|
||||||
|
enterpriseRequired: false,
|
||||||
|
enabledByDefault: false,
|
||||||
|
hidden: true,
|
||||||
|
}
|
||||||
|
|
||||||
func UpgradeVersionCheck() Feature {
|
func UpgradeVersionCheck() Feature {
|
||||||
return upgradeVersionCheck
|
return upgradeVersionCheck
|
||||||
}
|
}
|
||||||
|
@ -46,3 +55,5 @@ func UpgradeVersionCheck() Feature {
|
||||||
func UpgradeVersionCheckV2() Feature {
|
func UpgradeVersionCheckV2() Feature {
|
||||||
return upgradeVersionCheckV2
|
return upgradeVersionCheckV2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UpgradeAlternativeOrder() Feature { return upgradeAlternativeOrder }
|
||||||
|
|
|
@ -51,6 +51,17 @@ var (
|
||||||
api.ServerGroupSyncWorkers,
|
api.ServerGroupSyncWorkers,
|
||||||
api.ServerGroupGateways,
|
api.ServerGroupGateways,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// alternativeUpgradeOrder contains execution order which enforce upgrade of Coordinators before DBServers
|
||||||
|
alternativeUpgradeOrder = []api.ServerGroup{
|
||||||
|
api.ServerGroupAgents,
|
||||||
|
api.ServerGroupSingle,
|
||||||
|
api.ServerGroupCoordinators,
|
||||||
|
api.ServerGroupDBServers,
|
||||||
|
api.ServerGroupSyncMasters,
|
||||||
|
api.ServerGroupSyncWorkers,
|
||||||
|
api.ServerGroupGateways,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// upgradeDecision is the result of an upgrade check.
|
// upgradeDecision is the result of an upgrade check.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// DISCLAIMER
|
// DISCLAIMER
|
||||||
//
|
//
|
||||||
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
|
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -22,6 +22,7 @@ package reconcile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/deployment/features"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/deployment/rotation"
|
"github.com/arangodb/kube-arangodb/pkg/deployment/rotation"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||||
)
|
)
|
||||||
|
@ -62,7 +63,10 @@ func (r *Reconciler) createRotateOrUpgradeDecision(spec api.DeploymentSpec, stat
|
||||||
d := updateUpgradeDecisionMap{}
|
d := updateUpgradeDecisionMap{}
|
||||||
|
|
||||||
// Init phase
|
// Init phase
|
||||||
for _, m := range status.Members.AsList() {
|
|
||||||
|
upgradeOrder := util.BoolSwitch(features.UpgradeAlternativeOrder().Enabled(), alternativeUpgradeOrder, api.AllServerGroups)
|
||||||
|
|
||||||
|
for _, m := range status.Members.AsListInGroups(upgradeOrder...) {
|
||||||
d[m.Member.ID] = r.createRotateOrUpgradeDecisionMember(spec, status, context, m)
|
d[m.Member.ID] = r.createRotateOrUpgradeDecisionMember(spec, status, context, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// DISCLAIMER
|
// DISCLAIMER
|
||||||
//
|
//
|
||||||
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
|
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -31,6 +31,24 @@ import (
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func Test_EnsureGroupsContainsAll(t *testing.T) {
|
||||||
|
ensure := func(t *testing.T, groups ...api.ServerGroup) {
|
||||||
|
require.Equal(t, groups, util.UniqueList(groups))
|
||||||
|
|
||||||
|
for _, expected := range api.AllServerGroups {
|
||||||
|
t.Run(expected.AsRole(), func(t *testing.T) {
|
||||||
|
require.Contains(t, groups, expected)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t.Run("rotationByAnnotationOrder", func(t *testing.T) {
|
||||||
|
ensure(t, rotationByAnnotationOrder...)
|
||||||
|
})
|
||||||
|
t.Run("alternativeUpgradeOrder", func(t *testing.T) {
|
||||||
|
ensure(t, alternativeUpgradeOrder...)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func Test_RotateUpgrade_Condition(t *testing.T) {
|
func Test_RotateUpgrade_Condition(t *testing.T) {
|
||||||
type testCase struct {
|
type testCase struct {
|
||||||
status api.MemberStatus
|
status api.MemberStatus
|
||||||
|
|
|
@ -112,6 +112,28 @@ func FormatList[A, B any](in []A, format func(A) B) []B {
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ContainsList[A comparable](in []A, item A) bool {
|
||||||
|
for _, el := range in {
|
||||||
|
if el == item {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func UniqueList[A comparable](in []A) []A {
|
||||||
|
var r = make([]A, 0, len(in))
|
||||||
|
|
||||||
|
for _, el := range in {
|
||||||
|
if !ContainsList(r, el) {
|
||||||
|
r = append(r, el)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
func FormatListErr[A, B any](in []A, format func(A) (B, error)) ([]B, error) {
|
func FormatListErr[A, B any](in []A, format func(A) (B, error)) ([]B, error) {
|
||||||
var r = make([]B, len(in))
|
var r = make([]B, len(in))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue