Skip to content

Commit ed382b7

Browse files
committed
refactored
1 parent 0a374f3 commit ed382b7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

cns/middlewares/k8sSwiftV2.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ func (k *K8sSWIFTv2Middleware) GetPodInfoForIPConfigsRequest(ctx context.Context
5555
}
5656

5757
// update ipConfigRequest
58-
respCode, message = k.UpdateIPConfigRequest(mtpnc, podInfo, req)
58+
respCode, message = k.UpdateIPConfigRequest(mtpnc, req)
5959
if respCode != types.Success {
6060
return nil, respCode, message
6161
}
6262
}
63+
logger.Printf("[SWIFTv2Middleware] pod %s has secondary interface : %v", podInfo.Name(), req.SecondaryInterfacesExist)
64+
logger.Printf("[SWIFTv2Middleware] pod %s has backend interface : %v", podInfo.Name(), req.BackendInterfaceExist)
6365

6466
return podInfo, types.Success, ""
6567
}
@@ -203,10 +205,15 @@ func (k *K8sSWIFTv2Middleware) getMTPNC(ctx context.Context, podInfo cns.PodInfo
203205
}
204206

205207
// Updates Ip Config Request
206-
func (k *K8sSWIFTv2Middleware) UpdateIPConfigRequest(mtpnc v1alpha1.MultitenantPodNetworkConfig, podInfo cns.PodInfo, req *cns.IPConfigsRequest) (
208+
func (k *K8sSWIFTv2Middleware) UpdateIPConfigRequest(mtpnc v1alpha1.MultitenantPodNetworkConfig, req *cns.IPConfigsRequest) (
207209
respCode types.ResponseCode,
208210
message string,
209211
) {
212+
// If primary Ip is set in status field, it indicates the presence of secondary interfaces
213+
if mtpnc.Status.PrimaryIP != "" {
214+
req.SecondaryInterfacesExist = true
215+
}
216+
210217
interfaceInfos := mtpnc.Status.InterfaceInfos
211218
for _, interfaceInfo := range interfaceInfos {
212219
if interfaceInfo.DeviceType == v1alpha1.DeviceTypeInfiniBandNIC {
@@ -222,8 +229,5 @@ func (k *K8sSWIFTv2Middleware) UpdateIPConfigRequest(mtpnc v1alpha1.MultitenantP
222229
}
223230
}
224231

225-
logger.Printf("[SWIFTv2Middleware] pod %s has secondary interface : %v", podInfo.Name(), req.SecondaryInterfacesExist)
226-
logger.Printf("[SWIFTv2Middleware] pod %s has backend interface : %v", podInfo.Name(), req.BackendInterfaceExist)
227-
228232
return types.Success, ""
229233
}

0 commit comments

Comments
 (0)