Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to set client dial timeout #2853

Open
debuggy opened this issue Jun 12, 2024 · 3 comments
Open

how to set client dial timeout #2853

debuggy opened this issue Jun 12, 2024 · 3 comments
Labels
kind/support Categorizes issue or PR as a support question.

Comments

@debuggy
Copy link

debuggy commented Jun 12, 2024

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

@troy0820
Copy link
Member

troy0820 commented Jun 12, 2024

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.

@troy0820
Copy link
Member

/kind support

@k8s-ci-robot k8s-ci-robot added the kind/support Categorizes issue or PR as a support question. label Jun 12, 2024
@debuggy
Copy link
Author

debuggy commented Jun 18, 2024

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.

Thanks, I will try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question.
Projects
None yet
Development

No branches or pull requests

3 participants