mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-07-22 23:10:36 -04:00
operator: update control plane nodes first
This commit is contained in:
parent
3e22aa8d43
commit
d5860bf861
2 changed files with 58 additions and 0 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -388,6 +389,10 @@ func (r *NodeVersionReconciler) tryStartClusterVersionUpgrade(ctx context.Contex
|
|||
func (r *NodeVersionReconciler) pairDonorsAndHeirs(ctx context.Context, controller metav1.Object, outdatedNodes []corev1.Node, mintNodes []mintNode) []replacementPair {
|
||||
logr := log.FromContext(ctx)
|
||||
var pairs []replacementPair
|
||||
|
||||
// Prioritize control-plane nodes, which need to be upgraded first starting with k8s v1.31.0.
|
||||
sortByControlPlanes(outdatedNodes)
|
||||
|
||||
for _, mintNode := range mintNodes {
|
||||
var foundReplacement bool
|
||||
// find outdated node in the same group
|
||||
|
@ -943,3 +948,16 @@ type newNodeConfig struct {
|
|||
scalingGroupByID map[string]updatev1alpha1.ScalingGroup
|
||||
newNodesBudget int
|
||||
}
|
||||
|
||||
func sortByControlPlanes(nodes []corev1.Node) {
|
||||
slices.SortStableFunc(nodes, func(a, b corev1.Node) int {
|
||||
_, aControlPlane := a.Labels["node-role.kubernetes.io/control-plane"]
|
||||
_, bControlPlane := b.Labels["node-role.kubernetes.io/control-plane"]
|
||||
if aControlPlane == bControlPlane {
|
||||
return 0
|
||||
} else if aControlPlane {
|
||||
return -1
|
||||
}
|
||||
return 1
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue