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

Adds timeouts for reconciler contexts #7147

Merged
merged 14 commits into from
Mar 29, 2023

Conversation

plkokanov
Copy link
Contributor

@plkokanov plkokanov commented Dec 5, 2022

How to categorize this PR?

/area scalability
/kind enhancement

What this PR does / why we need it:
This PR introduces a timeout for contexts used by reconciler functions.

Which issue(s) this PR fixes:
Part of #4251

Special notes for your reviewer:
As the issue also mentions adding waits for cache syncs - this comes out of the box when using controller runtime with a default timeout of 2 minutes.
The shoot and seed care controllers were already using contexts that timeout for the health check functions:

careCtx, cancel := context.WithTimeout(ctx, r.config.Controllers.ShootCare.SyncPeriod.Duration)
defer cancel()

and
ctx, cancel := context.WithTimeout(reconcileCtx, r.Config.SyncPeriod.Duration)
defer cancel()

I was not sure whether we should keep those as they are, or unify them so that only one time context is used.

Release note:

The `controllermanager` and `gardenlet` controller reconciliations are now limited to a `1m` timeout. Additionally, there is a 1m limit on predicate functions that use contexts.

@gardener-prow gardener-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 5, 2022
@gardener-prow
Copy link
Contributor

gardener-prow bot commented Dec 5, 2022

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

@gardener-prow gardener-prow bot added area/scalability Scalability related kind/enhancement Enhancement, improvement, extension cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. labels Dec 5, 2022
@gardener-prow gardener-prow bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 5, 2022
@plkokanov plkokanov force-pushed the enh/add-context branch 3 times, most recently from 3cffc9a to a8cd66a Compare December 5, 2022 08:21
@plkokanov plkokanov marked this pull request as ready for review December 5, 2022 09:20
@gardener-prow gardener-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 5, 2022
@gardener-prow gardener-prow bot requested a review from acumino December 5, 2022 09:20
@plkokanov plkokanov marked this pull request as draft December 5, 2022 09:38
@gardener-prow gardener-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 5, 2022
@rfranzke
Copy link
Member

rfranzke commented Dec 5, 2022

/assign
/cc @timebertt

@plkokanov
Copy link
Contributor Author

plkokanov commented Dec 9, 2022

@timebertt thanks for the review! There was something else that I thought would be good to add - timeout contexts for some of our mapper and predicate functions that also inject the parent context (stop channel) from the manager, as they could potentially block as well, if there are calls to the api server.

@gardener-prow gardener-prow bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 16, 2022
@gardener-prow gardener-prow bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 16, 2023
@plkokanov plkokanov marked this pull request as ready for review January 16, 2023 08:10
@gardener-prow gardener-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 16, 2023
@plkokanov
Copy link
Contributor Author

plkokanov commented Jan 16, 2023

@timebertt @rfranzke, this should be ready for review now. I've still used just a single context for the backupsbucketcheck controller:

ctx, cancel := context.WithTimeout(ctx, r.Config.SyncPeriod.Duration)
defer cancel()

and the extensionscheck reconciler:
ctx, cancel := context.WithTimeout(ctx, r.Config.SyncPeriod.Duration)
defer cancel()

because those checks are actually pretty fast and small, so I think that only one context is enough there. However, if you feel that's incorrect I will apply the initial suggestion to separate them in two contexts: #7147 (comment)

Edit: oops, forgot about also adapting the tests that use mocks. Fixing them now ...
Edit2: unit tests should be fixed now.

@gardener-prow gardener-prow bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 27, 2023
@gardener-prow gardener-prow bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 28, 2023
… controllers in controllermanager

- Make `ShootQuotaControllerConfiguration` a pointer
- Make `SyncPeriod` pointer.
- Default `SyncPeriod` to 60 minutes.
pkg/controllerutils/miscellaneous.go Show resolved Hide resolved
pkg/gardenlet/controller/bastion/reconciler.go Outdated Show resolved Hide resolved
pkg/gardenlet/controller/seed/seed/reconciler.go Outdated Show resolved Hide resolved
pkg/gardenlet/controller/seed/seed/reconciler.go Outdated Show resolved Hide resolved
pkg/gardenlet/controller/shoot/shoot/reconciler.go Outdated Show resolved Hide resolved
@gardener-prow gardener-prow bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 28, 2023
@plkokanov
Copy link
Contributor Author

Thanks for addressing my comments. Leaving it to @timebertt if he wants to take one more look.

Copy link
Member

@timebertt timebertt left a comment

Choose a reason for hiding this comment

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

One remaining comment, otherwise lgtm

pkg/controllerutils/miscellaneous.go Show resolved Hide resolved
Copy link
Member

@timebertt timebertt 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

@gardener-prow gardener-prow bot added the lgtm Indicates that a PR is ready to be merged. label Mar 29, 2023
@gardener-prow
Copy link
Contributor

gardener-prow bot commented Mar 29, 2023

LGTM label has been added.

Git tree hash: 68635569718b7c4f98a87cf0e02fa42b179092d2

@gardener-prow
Copy link
Contributor

gardener-prow bot commented Mar 29, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: timebertt

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

@gardener-prow gardener-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 29, 2023
@gardener-prow gardener-prow bot merged commit dff43d9 into gardener:master Mar 29, 2023
@plkokanov plkokanov deleted the enh/add-context branch March 30, 2023 13:59
andrerun pushed a commit to andrerun/gardener that referenced this pull request Jul 6, 2023
* Add timeout for reconciler contexts

* Adapts unit tests

* Fixes integration tests

* Use separate context for garden client and seed client

* Address PR review feedback

* Fix failing test

* Address PR review feedback

* Introduce utility function to have consistent contextTimeouts in all controllers

* [PR feedback] Revert back the changes.

* Address PR review feedback

* Streamline resourcemanager controller to use context with timeouts

* Streamline ShootQuotaControllerConfiguration struct inline with other controllers in controllermanager

- Make `ShootQuotaControllerConfiguration` a pointer
- Make `SyncPeriod` pointer.
- Default `SyncPeriod` to 60 minutes.

* Remove timeout from context in case of seed and shoot reconcilers for now.

* Address PR review feedback

---------

Co-authored-by: Ashish Ranjan Yadav <ashish.ranjan.yadav@sap.com>
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. area/scalability Scalability related cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. kind/enhancement Enhancement, improvement, extension lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants