From 492544b03fc8f40cd8bf67f0ae337ef1e02b6605 Mon Sep 17 00:00:00 2001 From: Jing Ai Date: Thu, 30 Nov 2017 15:38:54 -0800 Subject: [PATCH] Revert changes in sync.go and sync_test.go as the error it intends to resolve becomes transient. --- pkg/controller/node/ipam/sync/sync.go | 8 ++++++-- pkg/controller/node/ipam/sync/sync_test.go | 18 +++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/pkg/controller/node/ipam/sync/sync.go b/pkg/controller/node/ipam/sync/sync.go index eeff4a6d5fc..4995f425543 100644 --- a/pkg/controller/node/ipam/sync/sync.go +++ b/pkg/controller/node/ipam/sync/sync.go @@ -244,7 +244,9 @@ func (op *updateOp) validateRange(ctx context.Context, sync *NodeSync, node *v1. // alias. func (op *updateOp) updateNodeFromAlias(ctx context.Context, sync *NodeSync, node *v1.Node, aliasRange *net.IPNet) error { if sync.mode != SyncFromCloud { - glog.Warningf("Detect mode %q while expect to sync from cloud", sync.mode) + sync.kubeAPI.EmitNodeWarningEvent(node.Name, InvalidModeEvent, + "Cannot sync from cloud in mode %q", sync.mode) + return fmt.Errorf("cannot sync from cloud in mode %q", sync.mode) } glog.V(2).Infof("Updating node spec with alias range, node.PodCIDR = %v", aliasRange) @@ -274,7 +276,9 @@ func (op *updateOp) updateNodeFromAlias(ctx context.Context, sync *NodeSync, nod // updateAliasFromNode updates the cloud alias given the node allocation. func (op *updateOp) updateAliasFromNode(ctx context.Context, sync *NodeSync, node *v1.Node) error { if sync.mode != SyncFromCluster { - glog.Warningf("Detect mode %q while expect to sync from cluster", sync.mode) + sync.kubeAPI.EmitNodeWarningEvent( + node.Name, InvalidModeEvent, "Cannot sync to cloud in mode %q", sync.mode) + return fmt.Errorf("cannot sync to cloud in mode %q", sync.mode) } _, aliasRange, err := net.ParseCIDR(node.Spec.PodCIDR) diff --git a/pkg/controller/node/ipam/sync/sync_test.go b/pkg/controller/node/ipam/sync/sync_test.go index 18e1335366e..d3268480439 100644 --- a/pkg/controller/node/ipam/sync/sync_test.go +++ b/pkg/controller/node/ipam/sync/sync_test.go @@ -145,9 +145,11 @@ func TestNodeSyncUpdate(t *testing.T) { events: []fakeEvent{{"node1", "CloudCIDRAllocatorMismatch"}}, }, { - desc: "update alias from node", - mode: SyncFromCloud, - node: nodeWithCIDRRange, + desc: "update alias from node", + mode: SyncFromCloud, + node: nodeWithCIDRRange, + events: []fakeEvent{{"node1", "CloudCIDRAllocatorInvalidMode"}}, + wantError: true, }, { desc: "update alias from node", @@ -163,10 +165,12 @@ func TestNodeSyncUpdate(t *testing.T) { // XXX/bowei -- validation }, { - desc: "update node from alias", - mode: SyncFromCluster, - node: nodeWithoutCIDRRange, - fake: fakeAPIs{aliasRange: test.MustParseCIDR("10.1.2.3/16")}, + desc: "update node from alias", + mode: SyncFromCluster, + node: nodeWithoutCIDRRange, + fake: fakeAPIs{aliasRange: test.MustParseCIDR("10.1.2.3/16")}, + events: []fakeEvent{{"node1", "CloudCIDRAllocatorInvalidMode"}}, + wantError: true, }, { desc: "allocate range",