Skip to content

Commit

Permalink
Fix default network not being set when priority changes
Browse files Browse the repository at this point in the history
If the priorities (sorted by name) of the configured networks change,
then the default network needs to be adapted to ensure it is actually
being used.

Signed-off-by: Sascha Grunert <[email protected]>
  • Loading branch information
saschagrunert committed Jun 13, 2019
1 parent a4c8e18 commit db4d13e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions pkg/ocicni/ocicni.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,9 @@ func (plugin *cniNetworkPlugin) syncNetworkConfig() error {
}

plugin.Lock()
defer plugin.Unlock()
if plugin.defaultNetName == "" {
plugin.defaultNetName = defaultNetName
}
plugin.defaultNetName = defaultNetName
plugin.networks = networks
plugin.Unlock()

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ocicni/ocicni_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ var _ = Describe("ocicni operations", func() {
// Writing a config that doesn't match the default network
_, _, err = writeConfig(tmpDir, "5-notdefault.conf", "notdefault", "myplugin")
Expect(err).NotTo(HaveOccurred())
Consistently(ocicni.Status, 5).Should(HaveOccurred())
Eventually(ocicni.Status, 5).Should(HaveOccurred())

_, _, err = writeConfig(tmpDir, "10-test.conf", "test", "myplugin")
Expect(err).NotTo(HaveOccurred())
Expand Down

0 comments on commit db4d13e

Please sign in to comment.