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

OCPBUGS-29479: Add retries to async cache initialization #13610

Merged
merged 5 commits into from Feb 28, 2024

Conversation

TheRealJon
Copy link
Member

Auth initialization can fail if the API server is not ready. This is especially common during cluster installation.

Thanks to @deads2k for doing the sleuth work on this.

Auth initialization can fail if the API server not ready yet. This is especially common during cluster install.
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 15, 2024
Copy link
Contributor

openshift-ci bot commented Feb 15, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Feb 15, 2024
@openshift-ci-robot
Copy link
Contributor

@TheRealJon: This pull request references Jira Issue OCPBUGS-29479, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.16.0) matches configured target version for branch (4.16.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Auth initialization can fail if the API server is not ready. This is especially common during cluster installation.

Thanks to @deads2k for doing the sleuth work on this.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. label Feb 15, 2024
@openshift-ci openshift-ci bot requested a review from yapei February 15, 2024 20:58
@openshift-ci openshift-ci bot added component/backend Related to backend approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 15, 2024
@@ -10,6 +10,11 @@ import (
"k8s.io/klog"
)

const (
initializationRetries = 10
initializationRetryDelay = 30 * time.Second
Copy link

Choose a reason for hiding this comment

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

you wan to be under the 150 liveness probe delay, which I think means you want this delay to 11 seconds.

Copy link
Member Author

Choose a reason for hiding this comment

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

See openshift/console-operator#869 which changes the probes for the console container.

return c, nil
}
klog.V(4).Infof("retrying async cache setup - attempt %v of %v", retries, initializationRetries)
time.Sleep(initializationRetryDelay)
Copy link

Choose a reason for hiding this comment

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

Suggested change
time.Sleep(initializationRetryDelay)
select{
case <- ctx.Done():
return nil, ctx.Error()
case <-time.After(initializationRetryDelay):
}

perhaps this, so that cancellation is honored?

Copy link
Member

Choose a reason for hiding this comment

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

replace the logic with k8s.io/apimachinery/pkg/util/wait.UntilWithContext()

Copy link
Member Author

Choose a reason for hiding this comment

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

@deads2k @stlaz @jhadvig I've addressed this feedback.

return c, nil
}
klog.V(4).Infof("retrying async cache setup - attempt %v of %v", retries, initializationRetries)
time.Sleep(initializationRetryDelay)
Copy link
Member

Choose a reason for hiding this comment

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

replace the logic with k8s.io/apimachinery/pkg/util/wait.UntilWithContext()

@TheRealJon TheRealJon marked this pull request as ready for review February 19, 2024 18:00
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 19, 2024
@@ -27,13 +31,21 @@ func NewAsyncCache[T any](ctx context.Context, reloadPeriod time.Duration, cachi
cachingFunc: cachingFunc,
}

item, err := cachingFunc(ctx)
var err error
ctx, cancel := context.WithTimeout(ctx, 5*time.Minute)
Copy link
Member

Choose a reason for hiding this comment

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

I would expect something in terms of seconds, not minutes 👀
Remember that this blocks proper startup.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is intentionally long in order to give the API server time to become available. This context gets canceled on the first successful cachingFunc call, so we only wait the full 5 minutes when there is something wrong.

}
c.cachedItem = item
cancel()
}, initializationRetryDelay)
Copy link
Member

Choose a reason for hiding this comment

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

the delay const is used in place of a check interval here

pkg/auth/asynccache.go Outdated Show resolved Hide resolved
@TheRealJon
Copy link
Member Author

/label tide/merge-method-squash

@openshift-ci openshift-ci bot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Feb 21, 2024
@TheRealJon
Copy link
Member Author

@jhadvig @stlaz I've addressed all feedback, PTAL, thanks.

@TheRealJon
Copy link
Member Author

/retest

@@ -10,6 +10,12 @@ import (
"k8s.io/klog"
)

const (
initializationRetryInterval = 30 * time.Second
Copy link
Member

Choose a reason for hiding this comment

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

5s

Copy link
Member Author

Choose a reason for hiding this comment

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

What about 10s to match the historical behavior:

backoff = time.Second * 10

@@ -10,6 +10,12 @@ import (
"k8s.io/klog"
)

const (
initializationRetryInterval = 30 * time.Second
initializationTimeout = 5 * time.Minute
Copy link
Member

Choose a reason for hiding this comment

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

@deads2k is this ok?

Copy link
Member Author

Choose a reason for hiding this comment

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

@stlaz @deads2k The startupProbe for console pod lasts 5m, which also matches the duration console would retry auth config historically (4.14 and before).

pkg/auth/asynccache.go Outdated Show resolved Hide resolved
pkg/auth/asynccache.go Outdated Show resolved Hide resolved
- Log error on each retry
- Do not return error from PollUntilContextTimeout condition func
- Reduce retry interval to 10 seconds to match historical behavior
@TheRealJon
Copy link
Member Author

@jhadvig @stlaz I've updated according to the last comments. PTAL when you can.

@TheRealJon
Copy link
Member Author

/retest

Copy link
Member

@jhadvig jhadvig left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 27, 2024
Copy link
Contributor

openshift-ci bot commented Feb 27, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jhadvig, TheRealJon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jhadvig
Copy link
Member

jhadvig commented Feb 28, 2024

/retest

@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD 97b74c6 and 2 for PR HEAD 5f03015 in total

Copy link
Contributor

openshift-ci bot commented Feb 28, 2024

@TheRealJon: all tests passed!

Full PR test history. Your PR dashboard.

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/test-infra repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 0a4e4b1 into openshift:master Feb 28, 2024
6 checks passed
@openshift-ci-robot
Copy link
Contributor

@TheRealJon: Jira Issue OCPBUGS-29479: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-29479 has been moved to the MODIFIED state.

In response to this:

Auth initialization can fail if the API server is not ready. This is especially common during cluster installation.

Thanks to @deads2k for doing the sleuth work on this.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-bot
Copy link
Contributor

[ART PR BUILD NOTIFIER]

This PR has been included in build openshift-enterprise-console-container-v4.16.0-202402282339.p0.g0a4e4b1.assembly.stream.el8 for distgit openshift-enterprise-console.
All builds following this will include this PR.

@TheRealJon
Copy link
Member Author

/cherry-pick release-4.15

@TheRealJon TheRealJon deleted the OCPBUGS-29479 branch March 4, 2024 16:45
@openshift-cherrypick-robot

@TheRealJon: new pull request created: #13645

In response to this:

/cherry-pick release-4.15

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/test-infra repository.

@openshift-merge-robot
Copy link
Contributor

Fix included in accepted release 4.16.0-0.nightly-2024-03-30-033956

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/backend Related to backend jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants