-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NodeSelector change does not trigger reconcile (#186)
* NodeSelector change does not trigger reconcile When `nodeSelector` is changed and it matches a new node, this node ignores it. This issue was caused by reconcile predicate `UpdateFunc` callback depending on matching the node with both the new and the old policy `nodeSelector`. This caused `UpdateFunc` to not work properly. Now we check our node only against the new (updated) policy `nodeSelector`. Signed-off-by: HlinaCZ <[email protected]> Signed-off-by: Petr Horacek <[email protected]>
- Loading branch information
Showing
3 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package e2e | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
nmstatev1alpha1 "github.com/nmstate/kubernetes-nmstate/pkg/apis/nmstate/v1alpha1" | ||
) | ||
|
||
var _ = Describe("NodeSelector", func() { | ||
br1Up := nmstatev1alpha1.State(`interfaces: | ||
- name: br1 | ||
type: linux-bridge | ||
state: up | ||
bridge: | ||
options: | ||
stp: | ||
enabled: false | ||
port: | ||
- name: eth1 | ||
`) | ||
br1Absent := nmstatev1alpha1.State(`interfaces: | ||
- name: br1 | ||
type: linux-bridge | ||
state: absent | ||
`) | ||
nonexistentNodeSelector := map[string]string{"nonexistentKey": "nonexistentValue"} | ||
|
||
Context("when policy is set with node selector not matching any nodes", func() { | ||
BeforeEach(func() { | ||
setDesiredStateWithPolicyAndNodeSelector("br1", br1Up, nonexistentNodeSelector) | ||
}) | ||
|
||
AfterEach(func() { | ||
setDesiredStateWithPolicy("br1", br1Absent) | ||
for _, node := range nodes { | ||
interfacesNameForNode(node).ShouldNot(ContainElement("br1")) | ||
} | ||
|
||
deletePolicy("br1") | ||
}) | ||
|
||
It("should not update any nodes", func() { | ||
for _, node := range nodes { | ||
interfacesNameForNode(node).ShouldNot(ContainElement("br1")) | ||
} | ||
}) | ||
|
||
Context("and we remove the node selector", func() { | ||
BeforeEach(func() { | ||
setDesiredStateWithPolicyAndNodeSelector("br1", br1Up, map[string]string{}) | ||
}) | ||
|
||
It("should update all nodes", func() { | ||
for _, node := range nodes { | ||
interfacesNameForNode(node).Should(ContainElement("br1")) | ||
} | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters