@@ -12,6 +12,7 @@ import (
1212 "github.com/Azure/azure-container-networking/cns/logger"
1313 "github.com/Azure/azure-container-networking/cns/middlewares/mock"
1414 "github.com/Azure/azure-container-networking/cns/types"
15+ "github.com/Azure/azure-container-networking/common"
1516 "github.com/Azure/azure-container-networking/crd/multitenancy/api/v1alpha1"
1617 "github.com/google/go-cmp/cmp"
1718 "gotest.tools/v3/assert"
4142
4243 testPod9GUID = "2006cad4-e54d-472e-863d-c4bac66200a7"
4344 testPod9Info = cns .NewPodInfo ("2006cad4-eth0" , testPod9GUID , "testpod9" , "testpod9namespace" )
44-
45- kubeletExpectedString = "network is not ready"
4645)
4746
4847func TestMain (m * testing.M ) {
@@ -211,14 +210,14 @@ func TestValidateMultitenantIPConfigsRequestFailure(t *testing.T) {
211210 failReq .OrchestratorContext = b
212211 _ , respCode , msg := middleware .GetPodInfoForIPConfigsRequest (context .TODO (), failReq )
213212 assert .Equal (t , respCode , types .UnexpectedError )
214- assert .Assert (t , strings .Contains (msg , kubeletExpectedString ), "expected error message to be '%s', got '%s'" , kubeletExpectedString , msg )
213+ assert .Assert (t , strings .Contains (msg , common . KubeletNetworkNotReadyMsg ), "expected error message to contain '%s', got '%s'" , common . KubeletNetworkNotReadyMsg , msg )
215214
216215 // MTPNC not ready
217216 b , _ = testPod4Info .OrchestratorContext ()
218217 failReq .OrchestratorContext = b
219218 _ , respCode , msg = middleware .GetPodInfoForIPConfigsRequest (context .TODO (), failReq )
220219 assert .Equal (t , respCode , types .UnexpectedError )
221- assert .Assert (t , strings .Contains (msg , kubeletExpectedString ), "expected error message to be '%s', got '%s'" , kubeletExpectedString , msg )
220+ assert .Assert (t , strings .Contains (msg , common . KubeletNetworkNotReadyMsg ), "expected error message to contain '%s', got '%s'" , common . KubeletNetworkNotReadyMsg , msg )
222221}
223222
224223func TestGetSWIFTv2IPConfigSuccess (t * testing.T ) {
@@ -237,21 +236,18 @@ func TestGetSWIFTv2IPConfigSuccess(t *testing.T) {
237236 assert .Equal (t , ipInfos [0 ].SkipDefaultRoutes , false )
238237}
239238
240- // In AKS, for kubelet to retry faster it is particularly looking for "network is not ready" error string.
241- // https://github.com/kubernetes/kubernetes/blob/efd2a0d1f514be96a2f012fc3cb40f7c872b4e67/pkg/kubelet/pod_workers.go#L1495C2-L1501C3
242- // This test is to ensure that the error string contains "network is not ready"
243239func TestGetSWIFTv2IPConfigFailure (t * testing.T ) {
244240 middleware := K8sSWIFTv2Middleware {Cli : mock .NewClient ()}
245241
246242 // Pod's MTPNC doesn't exist in cache test
247243 _ , err := middleware .getIPConfig (context .TODO (), testPod3Info )
248244 assert .Assert (t , errors .Is (err , errMTPNCNotFound ), "expected error to wrap errMTPNCNotFound, got: %v" , err )
249- assert .ErrorContains (t , err , kubeletExpectedString )
245+ assert .ErrorContains (t , err , common . KubeletNetworkNotReadyMsg )
250246
251247 // Pod's MTPNC is not ready test
252248 _ , err = middleware .getIPConfig (context .TODO (), testPod4Info )
253249 assert .Assert (t , errors .Is (err , errMTPNCNotReady ), "expected error to wrap errMTPNCNotReady, got: %v" , err )
254- assert .ErrorContains (t , err , kubeletExpectedString )
250+ assert .ErrorContains (t , err , common . KubeletNetworkNotReadyMsg )
255251}
256252
257253func TestSetRoutesSuccess (t * testing.T ) {
0 commit comments