controller-runtime
controller-runtime copied to clipboard
how to set client dial timeout
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