@@ -100,33 +100,33 @@ func (service *HTTPRestService) MarkIPAsPendingRelease(totalIpsToRelease int) (m
100100 defer service .Unlock ()
101101
102102 for uuid , existingIpConfig := range service .PodIPConfigState {
103- if existingIpConfig .State == cns .PendingProgramming {
104- updatedIpConfig , err := service .updateIPConfigState (uuid , cns .PendingRelease , existingIpConfig .OrchestratorContext )
105- if err != nil {
106- return nil , err
107- }
103+ if existingIpConfig .State == cns .PendingProgramming {
104+ updatedIpConfig , err := service .updateIPConfigState (uuid , cns .PendingRelease , existingIpConfig .OrchestratorContext )
105+ if err != nil {
106+ return nil , err
107+ }
108108
109- pendingReleasedIps [uuid ] = updatedIpConfig
109+ pendingReleasedIps [uuid ] = updatedIpConfig
110110 if len (pendingReleasedIps ) == totalIpsToRelease {
111111 return pendingReleasedIps , nil
112112 }
113- }
113+ }
114114 }
115-
116- // if not all expected IPs are set to PendingRelease, then check the Available IPs
115+
116+ // if not all expected IPs are set to PendingRelease, then check the Available IPs
117117 for uuid , existingIpConfig := range service .PodIPConfigState {
118- if existingIpConfig .State == cns .Available {
119- updatedIpConfig , err := service .updateIPConfigState (uuid , cns .PendingRelease , existingIpConfig .OrchestratorContext )
120- if err != nil {
121- return nil , err
122- }
123-
124- pendingReleasedIps [uuid ] = updatedIpConfig
125-
118+ if existingIpConfig .State == cns .Available {
119+ updatedIpConfig , err := service .updateIPConfigState (uuid , cns .PendingRelease , existingIpConfig .OrchestratorContext )
120+ if err != nil {
121+ return nil , err
122+ }
123+
124+ pendingReleasedIps [uuid ] = updatedIpConfig
125+
126126 if len (pendingReleasedIps ) == totalIpsToRelease {
127127 return pendingReleasedIps , nil
128- }
129- }
128+ }
129+ }
130130 }
131131
132132 logger .Printf ("[MarkIPAsPendingRelease] Set total ips to PendingRelease %d, expected %d" , len (pendingReleasedIps ), totalIpsToRelease )
@@ -140,9 +140,9 @@ func (service *HTTPRestService) updateIPConfigState(ipId string, updatedState st
140140 ipConfig .OrchestratorContext = orchestratorContext
141141 service .PodIPConfigState [ipId ] = ipConfig
142142 return ipConfig , nil
143- }
144-
145- return cns.IPConfigurationStatus {}, fmt .Errorf ("[updateIPConfigState] Failed to update state %s for the IPConfig. ID %s not found PodIPConfigState" , updatedState , ipId )
143+ }
144+
145+ return cns.IPConfigurationStatus {}, fmt .Errorf ("[updateIPConfigState] Failed to update state %s for the IPConfig. ID %s not found PodIPConfigState" , updatedState , ipId )
146146}
147147
148148// MarkIpsAsAvailableUntransacted will update pending programming IPs to available if NMAgent side's programmed nc version keep up with nc version.
@@ -152,9 +152,13 @@ func (service *HTTPRestService) MarkIpsAsAvailableUntransacted(ncID string, newH
152152 if ncInfo , exist := service .state .ContainerStatus [ncID ]; ! exist {
153153 logger .Errorf ("Can't find NC with ID %s in service state, stop updating its pending programming IP status" , ncID )
154154 } else {
155- previousHostNCVersion := ncInfo .HostVersion
155+ previousHostNCVersion , err := strconv .Atoi (ncInfo .HostVersion )
156+ if err != nil {
157+ logger .Printf ("[MarkIpsAsAvailableUntransacted] Get int value from ncInfo.HostVersion %s failed: %v, can't proceed" , ncInfo .HostVersion , err )
158+ return
159+ }
156160 // We only need to handle the situation when dnc nc version is larger than programmed nc version
157- if previousHostNCVersion < ncInfo . CreateNetworkContainerRequest . Version && previousHostNCVersion < strconv . Itoa ( newHostNCVersion ) {
161+ if previousHostNCVersion < newHostNCVersion {
158162 for uuid , secondaryIPConfigs := range ncInfo .CreateNetworkContainerRequest .SecondaryIPConfigs {
159163 if ipConfigStatus , exist := service .PodIPConfigState [uuid ]; ! exist {
160164 logger .Errorf ("IP %s with uuid as %s exist in service state Secondary IP list but can't find in PodIPConfigState" , ipConfigStatus .IPAddress , uuid )
@@ -348,7 +352,7 @@ func (service *HTTPRestService) MarkExistingIPsAsPending(pendingIPIDs []string)
348352 return fmt .Errorf ("Failed to mark IP [%v] as pending, currently allocated" , id )
349353 }
350354
351- logger .Printf ("[MarkExistingIPsAsPending]: Marking IP [%+v] to PendingRelease" , ipconfig )
355+ logger .Printf ("[MarkExistingIPsAsPending]: Marking IP [%+v] to PendingRelease" , ipconfig )
352356 ipconfig .State = cns .PendingRelease
353357 service .PodIPConfigState [id ] = ipconfig
354358 } else {
0 commit comments