java icon indicating copy to clipboard operation
java copied to clipboard

OkHttp3.Call doesn't have timeout by default

Open bacek opened this issue 1 year ago • 4 comments
trafficstars

Describe the bug Java Client is using OkHttp3.Call for most (all?) of processing. Default OkHttp3.Call doesn't have timeout configured.

Which leads to problems like apiClient hanging in case of network bleeps.

Client Version 19.0.0

Kubernetes Version 1.26

Java Version Java 11

To Reproduce Steps to reproduce the behavior:

Expected behavior apiClient calls not to hang forever.

Additional context We have tightly locked k8s cluster with Istio. We submit a lot (1000+) jobs to k8s using batch/job.

When load burst happens, istio-proxy can have some hiccup, with errors like this:

WARNING: A connection to https://172.20.0.1/ was leaked. Did you forget to close a response body? To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);

When this happen call

batchApi.createNamespacedJob(this.namespace, job, null, null, "k8sBatchService", FIELD_VALIDATION);

just hangs forever.

bacek avatar Dec 07 '23 05:12 bacek

You can set various timeouts on the apiClient:

https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/openapi/ApiClient.java#L461

Does that help you?

brendandburns avatar Dec 08 '23 03:12 brendandburns

You can set various timeouts on the apiClient:

https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/openapi/ApiClient.java#L461

Does that help you?

It's missing callTimeout. Which is root cause for this issue.

bacek avatar Dec 08 '23 03:12 bacek

Ok. This would require an upstream change in the code generator here:

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache

If someone sends a PR there, we can then incorporate it into this library.

If you don't want to do that, you can also manually create the HTTP client yourself and pass it in to ApiClient:

https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/openapi/ApiClient.java#L152

brendandburns avatar Dec 08 '23 19:12 brendandburns

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Mar 07 '24 20:03 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Apr 06 '24 20:04 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar May 06 '24 21:05 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar May 06 '24 21:05 k8s-ci-robot