Skip to content

fix: create lazy OpenShift context to avoid check timeouts (#865) #866

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

adietish
Copy link
Collaborator

@adietish adietish commented Apr 16, 2025

fixes #865

@adietish adietish self-assigned this Apr 16, 2025
@adietish adietish force-pushed the issue-865 branch 9 times, most recently from 6c87476 to f8af258 Compare April 24, 2025 12:36
@adietish adietish changed the title 1st step: checking if cluster is openshift is causing big delays fix: create lazy OpenShift context to avoid check timeouts (#865) Apr 24, 2025
* @see [issue 865](https://github.com/redhat-developer/intellij-kubernetes/issues/865)
* @see ClientAdapter.toOpenShift
**/
return KubeClientAdapter(kubeClient)
Copy link
Collaborator Author

@adietish adietish Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the core of the fix: dont check if the cluster is OpenShift and create a Kubernetes- or OpenShift client. This check is costly and may timeout if the cluster is not reachable.
Create a Kubernetes client instead. It can always be adapted to an OpenShift client when needed.

client as KubeClientAdapter
)
}
return LazyOpenShiftContext(currentContext, modelChange, client as KubeClientAdapter)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the core of the fix: dont check if the cluster is OpenShift and create a Kubernetes- or OpenShift context. This check is costly and may timeout if the cluster is not reachable.
Create a Kubernetes context that async tries to upgrade to an OpenShift context instead.

config.connectionTimeout = TIMEOUT_CONNECTION
config.requestTimeout = TIMEOUT_REQUEST
config.watchReconnectLimit = LIMIT_RECONNECT
config
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an aspect of the fix: impose timeouts for connecting, requesting and reconnecting.

}

private fun createOpenShiftDelegate() {
if (client.canAdaptToOpenShift()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the core fix: a context that starts as a Kubernetes context and async tries to create and use an OpenShift context.

@adietish adietish force-pushed the issue-865 branch 2 times, most recently from d5e8a39 to 83a3b6b Compare April 24, 2025 15:39
@adietish adietish requested a review from sbouchet April 24, 2025 19:20
@adietish adietish marked this pull request as ready for review April 24, 2025 19:21
@adietish adietish requested review from msivasubramaniaan and removed request for sbouchet April 28, 2025 15:43
@adietish
Copy link
Collaborator Author

adietish commented Apr 28, 2025

@sbouchet: handing this to @msivasubramaniaan to unload you so that you can please review #858

@adietish adietish requested review from andrewballantyne and sbouchet and removed request for andrewballantyne and sbouchet April 28, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nothing happens if I try to set a non-responsive cluster as current cluster
2 participants