@@ -25,6 +25,7 @@ import (
2525 "github.com/scaleway/scaleway-sdk-go/api/instance/v1"
2626 "github.com/scaleway/scaleway-sdk-go/api/lb/v1"
2727 "github.com/scaleway/scaleway-sdk-go/scw"
28+ "golang.org/x/exp/maps"
2829 v1 "k8s.io/api/core/v1"
2930 "k8s.io/apimachinery/pkg/fields"
3031 "k8s.io/apimachinery/pkg/util/runtime"
@@ -201,18 +202,19 @@ func (s *syncController) syncNodeTags(node *v1.Node) error {
201202 patcher := NewNodePatcher (s .clientSet , nodeCopied )
202203
203204 nodeLabels := map [string ]string {}
204- nodeTaints := []v1.Taint {}
205+ // Note: taints must be unique by key and effect pair
206+ nodeTaints := map [string ]v1.Taint {}
205207 for _ , tag := range server .Server .Tags {
206208 if strings .HasPrefix (tag , labelTaintPrefix ) {
207209 key , value , effect := tagTaintParser (tag )
208210 if key == "" {
209211 continue
210212 }
211- nodeTaints = append ( nodeTaints , v1.Taint {
213+ nodeTaints [ fmt . Sprintf ( "%s:%s" , key , effect )] = v1.Taint {
212214 Key : key ,
213215 Value : value ,
214216 Effect : effect ,
215- })
217+ }
216218 } else {
217219 var key string
218220 var value string
@@ -251,12 +253,13 @@ func (s *syncController) syncNodeTags(node *v1.Node) error {
251253 }
252254
253255 for _ , taint := range node .Spec .Taints {
254- if ! strings .HasPrefix (taint .Key , taintsPrefix ) {
255- nodeTaints = append (nodeTaints , taint )
256+ taintUniqueKey := fmt .Sprintf ("%s:%s" , taint .Key , taint .Effect )
257+ if _ , ok := nodeTaints [taintUniqueKey ]; ! ok && ! strings .HasPrefix (taint .Key , taintsPrefix ) {
258+ nodeTaints [taintUniqueKey ] = taint
256259 }
257260 }
258261
259- nodeCopied .Spec .Taints = nodeTaints
262+ nodeCopied .Spec .Taints = maps . Values ( nodeTaints )
260263 err = patcher .Patch ()
261264 if err != nil {
262265 klog .Errorf ("error patching service: %v" , err )
0 commit comments