Skip to content

Commit ed74418

Browse files
authored
[Bugfix] Switch tolerations compare (#1222)
1 parent 46b519a commit ed74418

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- (Feature) Promote Version Check Feature
99
- (Bugfix) Ensure PDBs Consistency
1010
- (Bugfix) Fix LocalStorage WaitForFirstConsumer mode
11+
- (Bugfix) Fix Tolerations propagation in case of toleration removal
1112

1213
## [1.2.22](https://github.com/arangodb/kube-arangodb/tree/1.2.22) (2022-12-13)
1314
- (Bugfix) Do not manage ports in managed ExternalAccess mode

pkg/deployment/reconcile/action_runtime_sync_tolerations.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ func (a actionRuntimeContainerSyncTolerations) Start(ctx context.Context) (bool,
7878

7979
expectedTolerations := member.Spec.Template.PodSpec.Spec.Tolerations
8080

81-
calculatedTolerations := tolerations.MergeTolerationsIfNotFound(currentTolerations, expectedTolerations)
81+
origTolerations := tolerations.CreatePodTolerations(a.actionCtx.GetMode(), a.action.Group)
82+
83+
calculatedTolerations := tolerations.MergeTolerationsIfNotFound(currentTolerations, origTolerations, expectedTolerations)
8284

8385
if reflect.DeepEqual(currentTolerations, calculatedTolerations) {
8486
return true, nil

pkg/deployment/rotation/arangod_tolerations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func comparePodTolerations(_ api.DeploymentSpec, _ api.ServerGroup, spec, status
3333
if !reflect.DeepEqual(spec.Tolerations, status.Tolerations) {
3434
plan = append(plan, builder.NewAction(api.ActionTypeRuntimeContainerSyncTolerations))
3535

36-
spec.Tolerations = status.Tolerations
36+
status.Tolerations = spec.Tolerations
3737
mode = mode.And(InPlaceRotation)
3838

3939
return

pkg/util/k8sutil/tolerations/tolerations.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
core "k8s.io/api/core/v1"
2727

2828
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
29-
"github.com/arangodb/kube-arangodb/pkg/util"
3029
)
3130

3231
const (
@@ -56,6 +55,16 @@ func NewNoExecuteToleration(key string, duration TolerationDuration) core.Tolera
5655
return t
5756
}
5857

58+
func CopyTolerations(source []core.Toleration) []core.Toleration {
59+
out := make([]core.Toleration, len(source))
60+
61+
for id := range out {
62+
source[id].DeepCopyInto(&out[id])
63+
}
64+
65+
return out
66+
}
67+
5968
// MergeTolerationsIfNotFound merge the given tolerations lists, if no such toleration has been set in the given source.
6069
func MergeTolerationsIfNotFound(source []core.Toleration, toAdd ...[]core.Toleration) []core.Toleration {
6170
for _, toleration := range toAdd {
@@ -82,16 +91,18 @@ func AddTolerationIfNotFound(source []core.Toleration, toAdd core.Toleration) []
8291
}
8392
}
8493

94+
// Ensure we are working on the copy
95+
source = CopyTolerations(source)
96+
8597
for id, t := range source {
8698
if t.Key == toAdd.Key && t.Effect == toAdd.Effect && t.Operator == toAdd.Operator && t.Value == toAdd.Value {
8799
// We are on same toleration, only value needs to be modified
88-
if !util.CompareInt64p(t.TolerationSeconds, toAdd.TolerationSeconds) {
89-
source[id].TolerationSeconds = util.NewInt64OrNil(toAdd.TolerationSeconds)
90-
}
100+
toAdd.DeepCopyInto(&source[id])
91101

92102
return source
93103
}
94104
}
105+
95106
return append(source, toAdd)
96107
}
97108

0 commit comments

Comments
 (0)