how to set client dial timeout
debuggy opened this issue · 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
Do you mean options.HTTPClient
where you can specify these options when creating a client?
https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/client#Options You can set the timeout in the options if you wish to have the client.
/kind support