node-maintenance-operator icon indicating copy to clipboard operation
node-maintenance-operator copied to clipboard

Configurable DrainerTimeout

Open vaspahomov opened this issue 5 months ago β€’ 8 comments

Why we need this PR

Idea is the same as in #151

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.

Here we are trying to lower single reconcile maximum duration.

Changes made

Made DrainerTimeout configurable.

Which issue(s) this PR fixes

Test plan

Summary by CodeRabbit

  • New Features

    • Added a configurable command-line flag to set the drainer timeout duration.
    • Made the drainer timeout dynamically adjustable per instance, rather than using a fixed value.
  • Tests

    • Updated test deployment to use the default drainer timeout for pod termination grace period.

vaspahomov avatar Jun 17 '25 18:06 vaspahomov

[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 slintes 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

openshift-ci[bot] avatar Jun 17 '25 18:06 openshift-ci[bot]

Walkthrough

A new configurable drainer timeout is introduced for the NodeMaintenanceReconciler, replacing the previously hardcoded value. This timeout can now be set via a command-line flag and is passed through the main application, controller, and tests. Associated struct fields, function signatures, and test logic are updated to use this configurable value.

Changes

File(s) Change Summary
controllers/nodemaintenance_controller.go, controllers/controllers_suite_test.go Added DrainerTimeout field to NodeMaintenanceReconciler; made drainer timeout configurable; updated function signatures and logic to use the new field; initialized field in test setup.
main.go Added drainer-timeout command-line flag; validated and logged flag value; passed value to NodeMaintenanceReconciler; updated imports and formatting.
test/e2e/node_maintenance_test.go Updated test deployment to use DefaultDrainerTimeout for pod termination grace period calculation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Main
    participant NodeMaintenanceReconciler
    participant Drainer

    User->>Main: Start with --drainer-timeout flag
    Main->>NodeMaintenanceReconciler: Initialize with DrainerTimeout
    NodeMaintenanceReconciler->>Drainer: createDrainer(..., DrainerTimeout)
    Drainer-->>NodeMaintenanceReconciler: Drainer with configured timeout

Poem

In the warren where code runs deep,
A drainer timeout now can leap!
No more constants, set and doneβ€”
Flags and fields for everyone.
With each deploy and test anew,
The rabbits cheer: "Configurable, woohoo!"
πŸ‡β±οΈ


πŸ“œ Recent review details

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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 1ef107cd9bc998ac5e32bc446bcde4bb3ac6356e and e2712c8ebae3676967a39faf6edf91df04854359.

πŸ“’ Files selected for processing (2)
  • controllers/controllers_suite_test.go (1 hunks)
  • main.go (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • controllers/controllers_suite_test.go
  • main.go
✨ 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.

coderabbitai[bot] avatar Jun 17 '25 18:06 coderabbitai[bot]

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.

openshift-ci[bot] avatar Jun 17 '25 18:06 openshift-ci[bot]

IIUC, your suggestion follows the general line of #122

razo7 avatar Jun 18 '25 06:06 razo7

Idea is the same as in #151

@vaspahomov is this PR replacing #151 ?

mshitrit avatar Jun 23 '25 08:06 mshitrit

Idea is the same as in https://github.com/medik8s/node-maintenance-operator/pull/151 @vaspahomov is this PR replacing https://github.com/medik8s/node-maintenance-operator/pull/151 ?

It's better to have them both. Both PRs are related to speeding up simultaneous NodeMaintenances handling.

vaspahomov avatar Jul 03 '25 14:07 vaspahomov

/test 4.18-openshift-e2e

razo7 avatar Jul 06 '25 12:07 razo7

@vaspahomov Hi, how do you install NMO, with OLM? I'm wondering how to use such new flags without further modifications the the bundle? πŸ€” We can set env vars in the Subscription, but I'm not aware how to modify the command...

slintes avatar Oct 23 '25 09:10 slintes