@@ -101,6 +101,51 @@ func TestReconcileNCStatePrimaryIPChangeShouldFail(t *testing.T) {
101101 assert .Equal (t , types .PrimaryCANotSame , resp )
102102}
103103
104+ // TestReconcileNCStatePrimaryIPChangeShouldNotFail tests that reconciling NC state with
105+ // a NC whose IP has changed should not fail
106+ func TestReconcileNCStatePrimaryIPChangeShouldNotFail (t * testing.T ) {
107+ restartService ()
108+ setEnv (t )
109+ setOrchestratorTypeInternal (cns .KubernetesCRD )
110+ svc .state .ContainerStatus = make (map [string ]containerstatus )
111+
112+ // start with a NC in state
113+ ncID := "555ac5c9-89f2-4b5d-b8d0-616894d6d151"
114+ svc .state .ContainerStatus [ncID ] = containerstatus {
115+ ID : ncID ,
116+ VMVersion : "0" ,
117+ HostVersion : "0" ,
118+ CreateNetworkContainerRequest : cns.CreateNetworkContainerRequest {
119+ NetworkContainerid : ncID ,
120+ IPConfiguration : cns.IPConfiguration {
121+ IPSubnet : cns.IPSubnet {
122+ IPAddress : "10.0.1.0" ,
123+ PrefixLength : 24 ,
124+ },
125+ },
126+ },
127+ }
128+
129+ ncReqs := []* cns.CreateNetworkContainerRequest {
130+ {
131+ NetworkContainerid : ncID ,
132+ IPConfiguration : cns.IPConfiguration {
133+ IPSubnet : cns.IPSubnet {
134+ IPAddress : "10.0.2.0" , // note this IP has changed
135+ PrefixLength : 24 ,
136+ },
137+ },
138+ Scenario : v1alpha .Overlay , // overlay cluster - skip primary CA check
139+ NetworkContainerType : cns .Kubernetes ,
140+ },
141+ }
142+
143+ // now try to reconcile the state where the NC primary IP has changed
144+ resp := svc .ReconcileIPAMStateForSwift (ncReqs , map [string ]cns.PodInfo {}, & v1alpha.NodeNetworkConfig {})
145+
146+ assert .Equal (t , types .Success , resp )
147+ }
148+
104149// TestReconcileNCStateGatewayChange tests that NC state gets updated when reconciled
105150// if the NC's gateway IP has changed
106151func TestReconcileNCStateGatewayChange (t * testing.T ) {
0 commit comments