Skip to content

Commit

Permalink
Fix flake in node FV tests
Browse files Browse the repository at this point in the history
  • Loading branch information
caseydavenport committed Apr 3, 2018
1 parent 36c9535 commit 57204fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions pkg/controllers/node/node_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ func (c *NodeController) syncToCalico(key string) error {
c.nodeLookupCache.RLock()
calicoNodeName, ok = c.nodeLookupCache.nodes[key]
c.nodeLookupCache.RUnlock()
clog = log.WithField("node", calicoNodeName)
}

if ok {
Expand Down
26 changes: 13 additions & 13 deletions tests/fv/fv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ var _ = Describe("kube-controllers FV tests", func() {
_, err := calicoClient.Nodes().Create(context.Background(), cn, options.SetOptions{})
Expect(err).NotTo(HaveOccurred())

k8sClient.CoreV1().Nodes().Delete(kNodeName, &metav1.DeleteOptions{})
Eventually(func() *api.Node {
node, _ := calicoClient.Nodes().Get(context.Background(), cNodeName, options.GetOptions{})
return node
Expand Down Expand Up @@ -206,7 +205,16 @@ var _ = Describe("kube-controllers FV tests", func() {
})

It("should clean up weps, IPAM allocations, etc. when deleting a node", func() {
// Create a node.
// Create the node in the Kubernetes API.
kn := &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: kNodeName,
},
}
_, err := k8sClient.CoreV1().Nodes().Create(kn)
Expect(err).NotTo(HaveOccurred())

// Create the node object in Calico's datastore.
cn := &api.Node{
ObjectMeta: metav1.ObjectMeta{
Name: cNodeName,
Expand All @@ -220,7 +228,7 @@ var _ = Describe("kube-controllers FV tests", func() {
},
},
}
_, err := calicoClient.Nodes().Create(context.Background(), cn, options.SetOptions{})
_, err = calicoClient.Nodes().Create(context.Background(), cn, options.SetOptions{})
Expect(err).NotTo(HaveOccurred())

// Create objects associated with this node.
Expand All @@ -235,14 +243,6 @@ var _ = Describe("kube-controllers FV tests", func() {
_, err = calicoClient.IPPools().Create(context.Background(), &pool, options.SetOptions{})
Expect(err).NotTo(HaveOccurred())

kn := &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: kNodeName,
},
}
_, err = k8sClient.CoreV1().Nodes().Create(kn)
Expect(err).NotTo(HaveOccurred())

affBlock := cnet.IPNet{
IPNet: net.IPNet{
IP: net.IP{192, 168, 0, 0},
Expand Down Expand Up @@ -317,7 +317,7 @@ var _ = Describe("kube-controllers FV tests", func() {
_, err = calicoClient.BGPConfigurations().Create(context.Background(), &bgpConf, options.SetOptions{})
Expect(err).ShouldNot(HaveOccurred())

// Delete thd node.
// Delete the node.
err = k8sClient.CoreV1().Nodes().Delete(kNodeName, &metav1.DeleteOptions{})
Expect(err).NotTo(HaveOccurred())

Expand All @@ -336,7 +336,7 @@ var _ = Describe("kube-controllers FV tests", func() {
ips, _ := calicoClient.IPAM().IPsByHandle(context.Background(), handle)
Expect(ips).Should(BeNil())

// Check that the host affinity pool was released.
// Check that the host affinity was released.
be := testutils.GetBackendClient(etcd.IP)
list, err := be.List(
context.Background(),
Expand Down

0 comments on commit 57204fc

Please sign in to comment.