clusterapi: add NewProvider for in-memory configs and context lifecycle #10428
This issue is currently awaiting triage.
If SIG Autoscaling contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.
The triage/accepted label can be added by org members by writing /triage accepted in a comment.
<details>
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.
</details>
Welcome @patrostkowski! <br><br>It looks like this is your first PR to <a href='https://github.com/kubernetes/autoscaler'>kubernetes/autoscaler</a> 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval. <br><br>You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation. <br><br>You can also check if kubernetes/autoscaler has its own contribution guidelines. <br><br>You may want to refer to our testing guide if you run into trouble with your tests not passing. <br><br>If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs! <br><br>Thank you, and welcome to Kubernetes. :smiley:
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: <a href="https://github.com/kubernetes/autoscaler/pull/10428#" title="Author self-approved">patrostkowski</a>
Once this PR has been reviewed and has the lgtm label, please assign elmiko for approval. For more information see the Code Review Process.
The full list of commands accepted by this bot can be found here.
<details open>
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
</details>
<!-- META={"approvers":["elmiko"]} -->
Hi @patrostkowski. Thanks for your PR.
I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.
Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test label.
I understand the commands that are listed here.
<details>
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.
</details>
<a href="https://api.easycla.lfx.linuxfoundation.org/v2/repository-provider/github/sign/18706487/87990209/10428/#/?version=2"><img src="https://s3.amazonaws.com/cla-project-logo-prod/cla-missing-id.svg?v=2" alt="CLA Missing ID" align="left" height="28" width="328" ></a><br/><br ><ul><li>:white_check_mark: login: patrostkowski / name: Patryk Rostkowski (6207cf74dfeb3079788141040d27f9b26026517e)</li><li> :x: The email address for the commit (6207cf74dfeb3079788141040d27f9b26026517e) is not linked to the GitHub account, preventing the EasyCLA check. Consult <a href='https://linuxfoundation.atlassian.net/wiki/spaces/LP/pages/160923756/Missing+ID+on+Commit+but+I+have+an+agreement+on+file' target='_blank'>this Help Article</a> and <a href='https://help.github.com/en/github/committing-changes-to-your-project/why-are-my-commits-linked-to-the-wrong-user' target='_blank'>GitHub Help</a> to resolve. (To view the commit's email address, add .patch at the end of this PR page's URL.) For further assistance with EasyCLA, <a href='https://easycla.lfx.linuxfoundation.org/' target='_blank'>please visit our EasyCLA portal</a> and chat with our support bot.</li></ul>
One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via:
Co-authored-by: name <email>
Supported Co-authored-by: formats include:
1) Anything <id+login@users.noreply.github.com> - it will locate your GitHub user by id part.
2) Anything <login@users.noreply.github.com> - it will locate your GitHub user by login part.
3) Anything <public-email> - it will locate your GitHub user by public-email part. Note that this email must be made public on Github.
4) Anything <other-email> - it will locate your GitHub user by other-email part but only if that email was used before for any other CLA as a main commit author.
5) login <any-valid-email> - it will locate your GitHub user by login part, note that login part must be at least 3 characters long.
Alternatively, if the co-author should not be included, remove the Co-authored-by: line from the commit message.
Please update your commit message(s) by doing git commit --amend and then git push [--force] and then request re-running CLA check via commenting on this pull request:
/easycla
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->
<a href="https://app.coderabbit.ai/change-stack/kubernetes/autoscaler/pull/10428?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a>
<!-- review_stack_entry_end -->
<!-- This is an auto-generated comment: skip review by coderabbit.ai -->
[!IMPORTANT]
## Review skipped
> Auto reviews are limited based on label configuration.
> <details>
<summary><strong>:no_entry_sign: Review skipped — only excluded labels are configured.: 2</strong></summary>
<dl>
<dd>
> do-not-merge/work-in-progress
cncf-cla: no
> </dd>
</dl>
</details>
> Please check the settings in the CodeRabbit UI or the.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.
> <details>
<summary><strong>⚙️ Run configuration</strong></summary>
<dl>
<dd>
> - Configuration used: Repository: kubernetes/autoscaler/.coderabbit.yaml
- Review profile: CHILL
- Plan: Advanced
- Run ID: dd0288bc-828b-4395-901a-c4d802b9e4d4> </dd>
</dl>
</details>
> You can disable this status message by setting thereviews.review_statustofalsein the CodeRabbit configuration file.
> Use the checkbox below for a quick retry:
- [ ] <!-- {"checkboxId":"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review
<!-- end of auto-generated comment: skip review by coderabbit.ai -->
<!-- finishing_touch_checkbox_start -->
<details>
<summary><strong>✨ Finishing Touches: 💡 1</strong></summary>
<dl>
<dd>
<!-- finishing_touch_suggestion:fix_ci -->
<details open>
<summary><strong>🛠️ Fix failing CI checks: 💡</strong></summary>
<dl>
<dd>
</dd>
</dl>
</details>
<details open>
<summary><strong>🧪 Generate unit tests (beta)</strong></summary>
<dl>
<dd>
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<!-- finishing_touch_checkbox_end -->
<!-- autopilot:start -->
<!-- autopilot:end -->
<!-- tips_start -->
<sub>Comment @coderabbitai help to get the list of available commands.</sub>
<!-- tips_end -->
/easycla
The cancel function is saved inside your provider struct, but it hasn't been executed yet.
If applications creates and destroys these providers over time, or if the main application runs for months, this tracking memory will slowly pile up and never be cleaned up by the Garbage Collector.
this only leaks if the caller skips Cleanup, which is already breaking the contract, cancel runs in Cleanup and on the error paths, and in that case the informers leak too
what I think we should do tho is make Cleanup call Shutdown() on both informer factories after cancel() so it blocks until the goroutines exit.
wdyt @sarkar-deb?
thanks for proposing this @patrostkowski , it's going to take me a few days to review. cc @LucasAndFlores you might want to take a look too.
sarkar-deb
patrostkowski
What type of PR is this?
/kind feature
/area provider/cluster-api
What this PR does / why we need it:
adds
NewProviderso the clusterapi provider can be built from in-memoryrest.Configs with a context bound lifecycle, for programs that run the CA core as a librarytoday
BuildClusterAPIonly reads kubeconfig paths, never stops its informers and callsklog.Fatalon every errorthis PR adds:
NewProvider(ctx, ProviderOptions): takes management and workloadrest.Configs, informers stop whenctxis done, returns errors instead of exitingRegisterProcessors(cp, processors): wires the scale down upgrade processor, which needed the unexported controller beforeCleanupnow stops the informersBuildClusterAPIis a thin wrapper over both, same flags and same fatal on error behaviour for the stock binaryWhich issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
controller.run()instead of before, it only holds a pointer to the controller so no effectExitCleanUpskipsCloudProvider.Cleanupwhen--write-status-configmap=false, soctxis the main way to stop itDoes this PR introduce a user-facing change?
``
release-note
``clusterapi: add NewProvider for in-memory configs and context lifecycle, BuildClusterAPI behaviour is unchanged
docs
NONE
🤖 Generated with Claude Code