Skip to content

Commit

Permalink
Merge pull request #11 from annismckenzie/fix-issue-10
Browse files Browse the repository at this point in the history
Check taints to be removed against the existing taints
  • Loading branch information
annismckenzie authored Jan 9, 2021
2 parents 1a6c684 + d3747b5 commit 956090e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ That Kubernetes operator doesn't exist. At least, it didn't until now. 🤠
## Installation

```sh
kubectl apply -f https://raw.githubusercontent.com/annismckenzie/k3os-config-operator/v0.1.0/deploy/operator.yaml
kubectl apply -f https://raw.githubusercontent.com/annismckenzie/k3os-config-operator/v0.1.1/deploy/operator.yaml
```


Expand Down
2 changes: 1 addition & 1 deletion config/production/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ resources:

images:
- name: ghcr.io/annismckenzie/k3os-config-operator
newTag: v0.1.0
newTag: v0.1.1
2 changes: 1 addition & 1 deletion deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: ghcr.io/annismckenzie/k3os-config-operator:v0.1.0
image: ghcr.io/annismckenzie/k3os-config-operator:v0.1.1
name: manager
resources:
limits:
Expand Down
12 changes: 12 additions & 0 deletions pkg/nodes/tainter.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ func (t *tainter) Reconcile(node *corev1.Node, configNodeTaints []string) error
return errors.ErrSkipUpdate
}

// here we check whether any of the taints that should be removed
// can even be removed from the node's taints or whether they were
// potentially already removed in a previous reconciliation
tmp := make([]corev1.Taint, 0, len(taintsToRemove))
for _, taintToRemove := range taintsToRemove {
// check whether the taint to remove even still exists on the node
if taints.TaintExists(node.Spec.Taints, &taintToRemove) {
tmp = append(tmp, taintToRemove)
}
}
taintsToRemove = tmp

_, newNodeTaints, err := taints.ReorganizeTaints(node, false, taintsToAdd, taintsToRemove)
if err != nil {
return err
Expand Down
14 changes: 14 additions & 0 deletions pkg/nodes/tainter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ func Test_tainter_Reconcile(t *testing.T) {
},
expectedAddedTaintsAnnotation: "",
},
{
name: "Removed taint stays in the list of taints (issue #10)",
args: args{
node: taintedNode([]string{"key2=value2:NoExecute"}),
configNodeTaints: []string{
"key2=value2:NoExecute-",
"key4=value4:NoExecute-", // simulate removal of a taint that was removed in a previous reconciliation
},
},
expectedTaints: []string{
"existingTaint=existingTaintValue:NoSchedule",
},
expectedAddedTaintsAnnotation: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 956090e

Please sign in to comment.