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

fix #3271: refining the wait logic #3274

Merged
merged 4 commits into from
Jun 29, 2021
Merged

fix #3271: refining the wait logic #3274

merged 4 commits into from
Jun 29, 2021

Conversation

shawkins
Copy link
Contributor

@shawkins shawkins commented Jun 25, 2021

Description

To address #3271 the only time to retry is on http gone - the watch framework will already handle all of the other retries.
delete does not need special handling in the watcher

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@centos-ci
Copy link

Can one of the admins verify this patch?

@shawkins
Copy link
Contributor Author

shawkins commented Jun 26, 2021

Like most things this turned out to be bigger than I thought at first glance... It makes sense to me to switch the implementation to be based upon an informer instead - as that already has the necessary retry logic and it's simple to express.

With this change it is unnecessary to specifically configure an exponential backoff for this operation - it should use the defaults for watches / informers. I did not remove those fields from all of the relevant contexts as that greatly expands the scope of these changes.

This change also reuses the existing KubernetesClientTimeoutException instead of using an IllegalArgumentException for timed out wait calls - I'll note that as a breaking change.

This also simplifies the logic in NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl - it was somewhat idiosyncratic and should be using the fork join pool for the potentially long running waitUntilCondition tasks. At some point the resource handlers and underlying logic should exposes the underlying futures as that would prevent this needless usage of threads.

This addresses having duplicate metadata.name fields in the watch url, but the real problem is #3275

Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

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

LGTM, thx!

@manusa manusa added this to the 5.5.0 milestone Jun 28, 2021
@shawkins
Copy link
Contributor Author

As mentioned on the issue, the subsequent commit removes the declared interruptedexception to simplify internal code and for consistency with the rest of the api. @manusa if that doesn't seem reasonable I can pull that out.

executor.shutdown();
}
public List<HasMetadata> waitUntilReady(final long amount, final TimeUnit timeUnit) {
return waitUntilCondition(resource -> Objects.nonNull(resource) && getReadiness().isReady(resource), amount, timeUnit);
Copy link
Member

@manusa manusa Jun 29, 2021

Choose a reason for hiding this comment

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

The statement

getReadiness().isReady(resource)

is not equivalent to

handlerOf(resource).waitUntilReady(...)

However the former doesn't make much sense since the effective call of waitUntilRady should be that of the applicable *OperationsImpl (e.g. ServiceHandler->ServiceOperationsImpl), especially considering the ServiceTest. Are we sure the Endpoints are being queried after these changes?

Copy link
Member

Choose a reason for hiding this comment

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

the only time to retry is on http gone
delete does not need special handling in the watcher
also fully removing the additional operation/context fields
@sonarcloud
Copy link

sonarcloud bot commented Jun 29, 2021

@manusa manusa merged commit 64dce1f into fabric8io:master Jun 29, 2021
Vlatombe added a commit to Vlatombe/kubernetes-plugin that referenced this pull request Mar 31, 2022
InterruptedException is no longer thrown on websocket timeout, rather a
KubernetesClientException. Unfortunately there is no way to
differentiate between a timeout and an error.

* fabric8io/kubernetes-client#3274
* fabric8io/kubernetes-client#3197
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.

5 participants