@@ -281,22 +281,24 @@ func (cdh *cniDaemonHandler) handleAdd(req *restful.Request, resp *restful.Respo
281
281
"macAddr" , macAddr )
282
282
283
283
// update IPInstance crd status
284
- for _ , ip := range affectedIPInstances {
285
- if err := retry .RetryOnConflict (retry .DefaultRetry , func () error {
286
- var updateTimestamp string
287
- updateTimestamp , err = metav1 .Now ().MarshalQueryParameter ()
288
- if err != nil {
289
- return fmt .Errorf ("failed to generate update timestamp: %v" , err )
284
+ if cdh .config .UpdateIPInstanceStatus {
285
+ for _ , ip := range affectedIPInstances {
286
+ if err := retry .RetryOnConflict (retry .DefaultRetry , func () error {
287
+ var updateTimestamp string
288
+ updateTimestamp , err = metav1 .Now ().MarshalQueryParameter ()
289
+ if err != nil {
290
+ return fmt .Errorf ("failed to generate update timestamp: %v" , err )
291
+ }
292
+
293
+ return cdh .mgrClient .Status ().Patch (context .TODO (), ip ,
294
+ client .RawPatch (types .MergePatchType ,
295
+ []byte (fmt .Sprintf (`{"status":{"sandboxID":%q,"nodeName":%q,"podNamespace":%q,"podName":%q,"updateTimestamp":%q}}` ,
296
+ podRequest .ContainerID , cdh .config .NodeName , podRequest .PodNamespace , podRequest .PodName , updateTimestamp ))))
297
+ }); err != nil {
298
+ errMsg := fmt .Errorf ("failed to update IPInstance crd for %s, %v" , ip .Name , err )
299
+ cdh .errorWrapper (errMsg , http .StatusInternalServerError , resp )
300
+ return
290
301
}
291
-
292
- return cdh .mgrClient .Status ().Patch (context .TODO (), ip ,
293
- client .RawPatch (types .MergePatchType ,
294
- []byte (fmt .Sprintf (`{"status":{"sandboxID":%q,"nodeName":%q,"podNamespace":%q,"podName":%q,"phase":null,"updateTimestamp":%q}}` ,
295
- podRequest .ContainerID , cdh .config .NodeName , podRequest .PodNamespace , podRequest .PodName , updateTimestamp ))))
296
- }); err != nil {
297
- errMsg := fmt .Errorf ("failed to update IPInstance crd for %s, %v" , ip .Name , err )
298
- cdh .errorWrapper (errMsg , http .StatusInternalServerError , resp )
299
- return
300
302
}
301
303
}
302
304
0 commit comments