Skip to content

Configurable MaxConcurrentReconciles #151

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 1 commit into
base: main
Choose a base branch
from

Conversation

vaspahomov
Copy link

@vaspahomov vaspahomov commented Jun 17, 2025

Why we need this PR

Default value for controller-manager for MaxConcurrentReconciles is 1.
If we are going to start n parallel NodeMaintenances at the same time. We'll handle last one after n * d time. Where d is duration of reconcile.
In current model the longest reconcile is more then 30s

That means - if we are starting ~50 parallel NodeMaintenances and each of them are failed to finish immediately (some blocking PDB exists) we we'll came up with the last one only after ~30mins.

Changes made

Added cli arg to override MaxConcurrentReconciles

Which issue(s) this PR fixes

Test plan

Summary by CodeRabbit

  • New Features
    • Added a command-line option to control the maximum number of concurrent reconciliation processes for node maintenance.
  • Improvements
    • Enhanced configurability of node maintenance operations by allowing users to set concurrency limits.

Signed-off-by: vaspahomov <vas2142553@gmail.com>
@openshift-ci openshift-ci bot requested review from mshitrit and razo7 June 17, 2025 17:58
Copy link
Contributor

openshift-ci bot commented Jun 17, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vaspahomov
Once this PR has been reviewed and has the lgtm label, please assign clobrano for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Copy link

coderabbitai bot commented Jun 17, 2025

Walkthrough

A new configuration option for maximum concurrent reconciles was introduced for the NodeMaintenanceReconciler. This includes adding a struct field, updating the controller setup to use this concurrency limit, and exposing a command-line flag to configure it. Test setup is also updated to initialize this field.

Changes

File(s) Change Summary
controllers/nodemaintenance_controller.go Added MaxConcurrentReconciles field to reconciler struct, updated controller builder to use it, and imported required package.
main.go Added max-concurrent-reconciles flag, passed value to reconciler struct, and adjusted formatting.
controllers/controllers_suite_test.go Initialized MaxConcurrentReconciles to 1 in test reconciler setup.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Main
    participant NodeMaintenanceReconciler
    participant ControllerRuntime

    User->>Main: Start application with flags
    Main->>Main: Parse max-concurrent-reconciles flag
    Main->>NodeMaintenanceReconciler: Initialize with MaxConcurrentReconciles value
    NodeMaintenanceReconciler->>ControllerRuntime: SetupWithManager (with MaxConcurrentReconciles)
    ControllerRuntime-->>NodeMaintenanceReconciler: Controller runs with specified concurrency
Loading

Poem

In the warren, code hops anew,
Concurrency capped, just one will do.
A flag for the keepers, so clever and bright,
Now reconciles march, one per night.
With options set and tests aligned,
The rabbits rejoice—control refined!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

openshift-ci bot commented Jun 17, 2025

Hi @vaspahomov. Thanks for your PR.

I'm waiting for a medik8s 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.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
main.go (1)

72-76: Validate user input and re-phrase the flag description

maxConcurrentReconciles may be set to 0 or a negative value via the CLI, which controller-runtime will silently coerce to the default (1). A quick sanity-check makes the behaviour explicit and avoids user confusion.
While touching the flag, a slightly clearer description helps:

-	flag.IntVar(&maxConcurrentReconciles, "max-concurrent-reconciles", 1, "The number of max concurrent reconciles")
+	flag.IntVar(&maxConcurrentReconciles, "max-concurrent-reconciles", 1,
+		"Maximum number of NodeMaintenance reconciles that may run concurrently (minimum 1)")

Add a guard straight after flag.Parse():

 flag.Parse()
+
+if maxConcurrentReconciles < 1 {
+	setupLog.Info("max-concurrent-reconciles must be >= 1 – falling back to 1",
+		"providedValue", maxConcurrentReconciles)
+	maxConcurrentReconciles = 1
+}

Also applies to: 83-84

controllers/nodemaintenance_controller.go (1)

71-73: Minor: document acceptable range for MaxConcurrentReconciles

The code happily accepts 0, which controller-runtime treats as default (1). A short comment (or the validation suggested in main.go) would make this implicit behaviour explicit and prevent misconfiguration later.

Also applies to: 78-80

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9f1d95d and f032953.

📒 Files selected for processing (3)
  • controllers/controllers_suite_test.go (1 hunks)
  • controllers/nodemaintenance_controller.go (2 hunks)
  • main.go (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
main.go (2)
pkg/utils/validation.go (1)
  • NewOpenshiftValidator (15-21)
controllers/nodemaintenance_controller.go (1)
  • NodeMaintenanceReconciler (64-73)
🔇 Additional comments (2)
controllers/controllers_suite_test.go (1)

94-101: Tests: explicit concurrency setting is good 👍

Hard-coding MaxConcurrentReconciles: 1 keeps the test suite deterministic and mirrors the default controller-runtime behaviour, so the addition looks correct.

main.go (1)

127-134: Wiring the parsed flag into the reconciler looks correct

The new field is correctly initialised and passed through, so the controller receives the requested concurrency level.

@slintes
Copy link
Member

slintes commented Jun 19, 2025

some first thoughts...

  • I don't feel comfortable adding parallelism to the reconciler without any test code
  • We should do something about the logger, which is a field of the reconciler, and being overwritten at the beginning of each reconcile. Probably should not be part of the reconciler anymore. Also, the CR being processed need to be added to the logger, so it's logged in every log statement
  • The lease manager should not be an issue on a quick look

@slintes
Copy link
Member

slintes commented Jun 19, 2025

@razo7 @mshitrit WDYT?

@razo7
Copy link
Member

razo7 commented Jun 22, 2025

I agree that test code is essential here to verify that nothing is messed up for concurrent NMO reconciles

@razo7
Copy link
Member

razo7 commented Jul 6, 2025

/test 4.18-openshift-e2e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants