66 "errors"
77 "fmt"
88 "reflect"
9+ "time"
910
1011 cloudnetworkv1 "github.com/openshift/api/cloudnetwork/v1"
1112 cloudnetworkclientset "github.com/openshift/client-go/cloudnetwork/clientset/versioned"
@@ -444,9 +445,14 @@ func (c *CloudPrivateIPConfigController) updateCloudPrivateIPConfigStatus(cloudP
444445 err := retry .RetryOnConflict (retry .DefaultRetry , func () error {
445446 ctx , cancel := context .WithTimeout (c .ctx , controller .ClientTimeout )
446447 defer cancel ()
448+ warningTime := time .Now ().Add (controller .APIResponseSoftLimit )
447449 var err error
448450 cloudPrivateIPConfig .Status = * status
449451 updatedCloudPrivateIPConfig , err = c .cloudNetworkClient .CloudV1 ().CloudPrivateIPConfigs ().UpdateStatus (ctx , cloudPrivateIPConfig , metav1.UpdateOptions {})
452+ if time .Until (warningTime ) <= 0 {
453+ klog .Warningf ("CloudPrivateIPConfig: Update API call took longer than expected for resource %q, Egress IP configuration might be delayed" ,
454+ cloudPrivateIPConfig .Name )
455+ }
450456 return err
451457 })
452458 return updatedCloudPrivateIPConfig , err
@@ -483,13 +489,19 @@ func (c *CloudPrivateIPConfigController) patchCloudPrivateIPConfigFinalizer(clou
483489func (c * CloudPrivateIPConfigController ) patchCloudPrivateIPConfig (name string , patchData []byte ) (* cloudnetworkv1.CloudPrivateIPConfig , error ) {
484490 ctx , cancel := context .WithTimeout (c .ctx , controller .ClientTimeout )
485491 defer cancel ()
486- return c .cloudNetworkClient .CloudV1 ().CloudPrivateIPConfigs ().Patch (ctx , name , types .JSONPatchType , patchData , metav1.PatchOptions {})
492+ warningTime := time .Now ().Add (controller .APIResponseSoftLimit )
493+ cloudPrivateIPConfig , err := c .cloudNetworkClient .CloudV1 ().CloudPrivateIPConfigs ().Patch (ctx , name , types .JSONPatchType , patchData , metav1.PatchOptions {})
494+ if time .Until (warningTime ) <= 0 {
495+ klog .Warningf ("CloudPrivateIPConfig: Patch API call took longer than expected for resource %q, Egress IP configuration might be delayed" , name )
496+ }
497+ return cloudPrivateIPConfig , err
487498}
488499
489500// getCloudPrivateIPConfig retrieves the object from the API server
490501func (c * CloudPrivateIPConfigController ) getCloudPrivateIPConfig (name string ) (* cloudnetworkv1.CloudPrivateIPConfig , error ) {
491502 ctx , cancel := context .WithTimeout (c .ctx , controller .ClientTimeout )
492503 defer cancel ()
504+ warningTime := time .Now ().Add (controller .APIResponseSoftLimit )
493505 // This object will repeatedly be updated during this sync, hence we need to
494506 // retrieve the object from the API server as opposed to the informer cache
495507 // for every sync, otherwise we risk acting on an old object
@@ -504,6 +516,9 @@ func (c *CloudPrivateIPConfigController) getCloudPrivateIPConfig(name string) (*
504516 }
505517 return nil , err
506518 }
519+ if time .Until (warningTime ) <= 0 {
520+ klog .Warningf ("CloudPrivateIPConfig: Get API call took longer than expected for resource %q, Egress IP configuration might be delayed" , name )
521+ }
507522 return cloudPrivateIPConfig , nil
508523}
509524
0 commit comments