mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Bugfix] Switch tolerations compare (#1222)
This commit is contained in:
parent
46b519a1d1
commit
ed74418b8f
4 changed files with 20 additions and 6 deletions
|
@ -8,6 +8,7 @@
|
|||
- (Feature) Promote Version Check Feature
|
||||
- (Bugfix) Ensure PDBs Consistency
|
||||
- (Bugfix) Fix LocalStorage WaitForFirstConsumer mode
|
||||
- (Bugfix) Fix Tolerations propagation in case of toleration removal
|
||||
|
||||
## [1.2.22](https://github.com/arangodb/kube-arangodb/tree/1.2.22) (2022-12-13)
|
||||
- (Bugfix) Do not manage ports in managed ExternalAccess mode
|
||||
|
|
|
@ -78,7 +78,9 @@ func (a actionRuntimeContainerSyncTolerations) Start(ctx context.Context) (bool,
|
|||
|
||||
expectedTolerations := member.Spec.Template.PodSpec.Spec.Tolerations
|
||||
|
||||
calculatedTolerations := tolerations.MergeTolerationsIfNotFound(currentTolerations, expectedTolerations)
|
||||
origTolerations := tolerations.CreatePodTolerations(a.actionCtx.GetMode(), a.action.Group)
|
||||
|
||||
calculatedTolerations := tolerations.MergeTolerationsIfNotFound(currentTolerations, origTolerations, expectedTolerations)
|
||||
|
||||
if reflect.DeepEqual(currentTolerations, calculatedTolerations) {
|
||||
return true, nil
|
||||
|
|
|
@ -33,7 +33,7 @@ func comparePodTolerations(_ api.DeploymentSpec, _ api.ServerGroup, spec, status
|
|||
if !reflect.DeepEqual(spec.Tolerations, status.Tolerations) {
|
||||
plan = append(plan, builder.NewAction(api.ActionTypeRuntimeContainerSyncTolerations))
|
||||
|
||||
spec.Tolerations = status.Tolerations
|
||||
status.Tolerations = spec.Tolerations
|
||||
mode = mode.And(InPlaceRotation)
|
||||
|
||||
return
|
||||
|
|
|
@ -26,7 +26,6 @@ import (
|
|||
core "k8s.io/api/core/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -56,6 +55,16 @@ func NewNoExecuteToleration(key string, duration TolerationDuration) core.Tolera
|
|||
return t
|
||||
}
|
||||
|
||||
func CopyTolerations(source []core.Toleration) []core.Toleration {
|
||||
out := make([]core.Toleration, len(source))
|
||||
|
||||
for id := range out {
|
||||
source[id].DeepCopyInto(&out[id])
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
// MergeTolerationsIfNotFound merge the given tolerations lists, if no such toleration has been set in the given source.
|
||||
func MergeTolerationsIfNotFound(source []core.Toleration, toAdd ...[]core.Toleration) []core.Toleration {
|
||||
for _, toleration := range toAdd {
|
||||
|
@ -82,16 +91,18 @@ func AddTolerationIfNotFound(source []core.Toleration, toAdd core.Toleration) []
|
|||
}
|
||||
}
|
||||
|
||||
// Ensure we are working on the copy
|
||||
source = CopyTolerations(source)
|
||||
|
||||
for id, t := range source {
|
||||
if t.Key == toAdd.Key && t.Effect == toAdd.Effect && t.Operator == toAdd.Operator && t.Value == toAdd.Value {
|
||||
// We are on same toleration, only value needs to be modified
|
||||
if !util.CompareInt64p(t.TolerationSeconds, toAdd.TolerationSeconds) {
|
||||
source[id].TolerationSeconds = util.NewInt64OrNil(toAdd.TolerationSeconds)
|
||||
}
|
||||
toAdd.DeepCopyInto(&source[id])
|
||||
|
||||
return source
|
||||
}
|
||||
}
|
||||
|
||||
return append(source, toAdd)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue