@@ -18,7 +18,7 @@ func (service *HTTPRestService) requestIPConfigHandler(w http.ResponseWriter, r
1818 var (
1919 err error
2020 ipconfigRequest cns.GetIPConfigRequest
21- ipconfiguration cns.IPConfiguration
21+ podIpInfo cns.PodIpInfo
2222 returnCode int
2323 returnMessage string
2424 )
@@ -32,7 +32,7 @@ func (service *HTTPRestService) requestIPConfigHandler(w http.ResponseWriter, r
3232 // retrieve ipconfig from nc
3333 _ , returnCode , returnMessage = service .validateIpConfigRequest (ipconfigRequest )
3434 if returnCode == Success {
35- if ipconfiguration , err = requestIPConfigHelper (service , ipconfigRequest ); err != nil {
35+ if podIpInfo , err = requestIPConfigHelper (service , ipconfigRequest ); err != nil {
3636 returnCode = FailedToAllocateIpConfig
3737 returnMessage = fmt .Sprintf ("AllocateIPConfig failed: %v" , err )
3838 }
@@ -46,7 +46,7 @@ func (service *HTTPRestService) requestIPConfigHandler(w http.ResponseWriter, r
4646 reserveResp := & cns.GetIPConfigResponse {
4747 Response : resp ,
4848 }
49- reserveResp .IPConfiguration = ipconfiguration
49+ reserveResp .PodIpInfo = podIpInfo
5050
5151 err = service .Listener .Encode (w , & reserveResp )
5252 logger .Response (service .Name , reserveResp , resp .ReturnCode , ReturnCodeToString (resp .ReturnCode ), err )
@@ -158,10 +158,10 @@ func (service *HTTPRestService) releaseIPConfig(podInfo cns.KubernetesPodInfo) e
158158 return nil
159159}
160160
161- func (service * HTTPRestService ) GetExistingIPConfig (podInfo cns.KubernetesPodInfo ) (cns.IPConfiguration , bool , error ) {
161+ func (service * HTTPRestService ) GetExistingIPConfig (podInfo cns.KubernetesPodInfo ) (cns.PodIpInfo , bool , error ) {
162162 var (
163- ipConfiguration cns.IPConfiguration
164- isExist bool
163+ podIpInfo cns.PodIpInfo
164+ isExist bool
165165 )
166166
167167 service .RLock ()
@@ -170,19 +170,19 @@ func (service *HTTPRestService) GetExistingIPConfig(podInfo cns.KubernetesPodInf
170170 ipID := service .PodIPIDByOrchestratorContext [podInfo .GetOrchestratorContextKey ()]
171171 if ipID != "" {
172172 if ipState , isExist := service .PodIPConfigState [ipID ]; isExist {
173- err := service .populateIpConfigInfoUntransacted (ipState , & ipConfiguration )
174- return ipConfiguration , isExist , err
173+ err := service .populateIpConfigInfoUntransacted (ipState , & podIpInfo )
174+ return podIpInfo , isExist , err
175175 }
176176
177177 logger .Errorf ("Failed to get existing ipconfig. Pod to IPID exists, but IPID to IPConfig doesn't exist, CNS State potentially corrupt" )
178- return ipConfiguration , isExist , fmt .Errorf ("Failed to get existing ipconfig. Pod to IPID exists, but IPID to IPConfig doesn't exist, CNS State potentially corrupt" )
178+ return podIpInfo , isExist , fmt .Errorf ("Failed to get existing ipconfig. Pod to IPID exists, but IPID to IPConfig doesn't exist, CNS State potentially corrupt" )
179179 }
180180
181- return ipConfiguration , isExist , nil
181+ return podIpInfo , isExist , nil
182182}
183183
184- func (service * HTTPRestService ) AllocateDesiredIPConfig (podInfo cns.KubernetesPodInfo , desiredIPAddress string , orchestratorContext json.RawMessage ) (cns.IPConfiguration , error ) {
185- var ipConfiguration cns.IPConfiguration
184+ func (service * HTTPRestService ) AllocateDesiredIPConfig (podInfo cns.KubernetesPodInfo , desiredIPAddress string , orchestratorContext json.RawMessage ) (cns.PodIpInfo , error ) {
185+ var podIpInfo cns.PodIpInfo
186186 service .Lock ()
187187 defer service .Unlock ()
188188
@@ -197,62 +197,62 @@ func (service *HTTPRestService) AllocateDesiredIPConfig(podInfo cns.KubernetesPo
197197 } else {
198198 var pInfo cns.KubernetesPodInfo
199199 json .Unmarshal (ipState .OrchestratorContext , & pInfo )
200- return ipConfiguration , fmt .Errorf ("Desired IP is already allocated %+v to Pod: %+v, requested for pod %+v" , ipState , pInfo , podInfo )
200+ return podIpInfo , fmt .Errorf ("Desired IP is already allocated %+v to Pod: %+v, requested for pod %+v" , ipState , pInfo , podInfo )
201201 }
202202 } else if ipState .State == cns .Available {
203203 service .setIPConfigAsAllocated (ipState , podInfo , orchestratorContext )
204204 found = true
205205 } else {
206- return ipConfiguration , fmt .Errorf ("Desired IP is not available %+v" , ipState )
206+ return podIpInfo , fmt .Errorf ("Desired IP is not available %+v" , ipState )
207207 }
208208
209209 if found {
210- err := service .populateIpConfigInfoUntransacted (ipState , & ipConfiguration )
211- return ipConfiguration , err
210+ err := service .populateIpConfigInfoUntransacted (ipState , & podIpInfo )
211+ return podIpInfo , err
212212 }
213213 }
214214 }
215- return ipConfiguration , fmt .Errorf ("Requested IP not found in pool" )
215+ return podIpInfo , fmt .Errorf ("Requested IP not found in pool" )
216216}
217217
218- func (service * HTTPRestService ) AllocateAnyAvailableIPConfig (podInfo cns.KubernetesPodInfo , orchestratorContext json.RawMessage ) (cns.IPConfiguration , error ) {
219- var ipConfiguration cns.IPConfiguration
218+ func (service * HTTPRestService ) AllocateAnyAvailableIPConfig (podInfo cns.KubernetesPodInfo , orchestratorContext json.RawMessage ) (cns.PodIpInfo , error ) {
219+ var podIpInfo cns.PodIpInfo
220220
221221 service .Lock ()
222222 defer service .Unlock ()
223223
224224 for _ , ipState := range service .PodIPConfigState {
225225 if ipState .State == cns .Available {
226- err := service .populateIpConfigInfoUntransacted (ipState , & ipConfiguration )
226+ err := service .populateIpConfigInfoUntransacted (ipState , & podIpInfo )
227227 if err == nil {
228228 service .setIPConfigAsAllocated (ipState , podInfo , orchestratorContext )
229229 }
230- return ipConfiguration , err
230+ return podIpInfo , err
231231 }
232232 }
233233
234- return ipConfiguration , fmt .Errorf ("No more free IP's available, trigger batch" )
234+ return podIpInfo , fmt .Errorf ("No more free IP's available, trigger batch" )
235235}
236236
237237// If IPConfig is already allocated for pod, it returns that else it returns one of the available ipconfigs.
238- func requestIPConfigHelper (service * HTTPRestService , req cns.GetIPConfigRequest ) (cns.IPConfiguration , error ) {
238+ func requestIPConfigHelper (service * HTTPRestService , req cns.GetIPConfigRequest ) (cns.PodIpInfo , error ) {
239239 var (
240- podInfo cns.KubernetesPodInfo
241- ipConfiguration cns.IPConfiguration
242- isExist bool
243- err error
240+ podInfo cns.KubernetesPodInfo
241+ podIpInfo cns.PodIpInfo
242+ isExist bool
243+ err error
244244 )
245245
246246 // check if ipconfig already allocated for this pod and return if exists or error
247247 // if error, ipstate is nil, if exists, ipstate is not nil and error is nil
248248 json .Unmarshal (req .OrchestratorContext , & podInfo )
249- if ipConfiguration , isExist , err = service .GetExistingIPConfig (podInfo ); err != nil || isExist {
250- return ipConfiguration , err
249+ if podIpInfo , isExist , err = service .GetExistingIPConfig (podInfo ); err != nil || isExist {
250+ return podIpInfo , err
251251 }
252252
253253 // return desired IPConfig
254- if req .DesiredIPConfig . IPAddress != "" {
255- return service .AllocateDesiredIPConfig (podInfo , req .DesiredIPConfig . IPAddress , req .OrchestratorContext )
254+ if req .DesiredIPAddress != "" {
255+ return service .AllocateDesiredIPConfig (podInfo , req .DesiredIPAddress , req .OrchestratorContext )
256256 }
257257
258258 // return any free IPConfig
0 commit comments