controller-runtime icon indicating copy to clipboard operation
controller-runtime copied to clipboard

how to set client dial timeout

Open debuggy opened this issue 8 months ago • 3 comments

I have a scenario that cancels the client request after a given timeout. I write a code using context.WithTimeout like this:

ctx1, cancel := context.WithTimeout(ctx, 1*time.Second)
defer cancel()
err := d.client.List(ctx1, objList, client.InNamespace(namespace))
if err != nil {
return objList, err
}

However, this code did not work and returned error like this. Does client support to set dial timeout in this scenario, or there is any other ways? failed to get API group resources: unable to retrieve the complete list of server APIs: helm.toolkit.fluxcd.io/v2beta1: Get "https://10.12.253.172:6443/apis/helm.toolkit.fluxcd.io/v2beta1": dial tcp xxx: i/o timeout

debuggy avatar Jun 12 '24 09:06 debuggy