Skip to content

Commit 98ae311

Browse files
Merge pull request #168 from arghosh93/OCPBUGS-45891
OCPBUGS-45891: Increase API call timeout to 30 second
2 parents 7263e1c + 3f6cb04 commit 98ae311

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

pkg/controller/cloudprivateipconfig/cloudprivateipconfig_controller.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
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
483489
func (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
490501
func (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

pkg/controller/controller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ const (
3030

3131
// ClientTimeout specifies the timeout for our calls to the API server for
3232
// all client operations
33-
ClientTimeout = 2 * time.Second
33+
ClientTimeout = 30 * time.Second
34+
35+
// APIResponseSoftLimit specifies the time after which a Warning gets logged if
36+
// response from API is not received before that time
37+
APIResponseSoftLimit = 2 * time.Second
3438
)
3539

3640
type CloudNetworkConfigControllerIntf interface {

0 commit comments

Comments
 (0)