Skip to content

feat(colocation): make node monitor thresholds configurable - #4935

Closed
AmanKumar1411 wants to merge 3 commits into
masterfrom
unknown repository
Closed

feat(colocation): make node monitor thresholds configurable#4935
AmanKumar1411 wants to merge 3 commits into
masterfrom
unknown repository

Conversation

@AmanKumar1411

Copy link
Copy Markdown

What is the problem you're trying to solve

Currently, in the Volcano colocation scenario, when the usage of a resource such as CPU exceeds a configured threshold, eviction of BE pods is triggered only after six consecutive high-usage detections. These detections are performed every 10 seconds. Both the detection intervals and the consecutive high-usage count limit are hard-coded in the node monitor implementation, which prevents users from tuning node pressure sensitivity based on their cluster size or workload characteristics.

Specifically, the highUsageCountLimit is hard-coded, and the utilisation monitoring and eviction detection intervals are also fixed at 10 seconds.

Describe the solution you'd like

Introduce configurable node monitor parameters under ColocationConfig to allow users to customise the utilisation monitoring interval, eviction detection interval, and the consecutive high-usage count limit. The default values will remain unchanged, with 10 seconds for both intervals and 6 as the highUsageCountLimit, ensuring backward compatibility.

Additional context

No additional context.

Documentation Updates

This change introduces new user-facing configuration options. Documentation updates are required to describe the new nodeMonitor configuration fields. The relevant documentation will be updated and published to the Volcano official website through the volcano-sh/website repository

@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

Details 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

@volcano-sh-bot

Copy link
Copy Markdown
Contributor

Welcome @AmanKumar1411! It looks like this is your first PR to volcano-sh/volcano 🎉

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @AmanKumar1411, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the flexibility of Volcano's colocation eviction mechanism by making key node monitor thresholds configurable. Previously, parameters like resource utilization monitoring intervals, eviction detection intervals, and the consecutive high-usage count limit were hard-coded, limiting tuning options. The changes introduce a new NodeMonitor configuration section within ColocationConfig, allowing users to fine-tune these values to better suit their cluster size and workload characteristics. The default values remain unchanged to ensure seamless backward compatibility.

Highlights

  • Configurable Node Monitor Thresholds: Introduced new configuration parameters under ColocationConfig.NodeMonitor to allow users to customize the behavior of node pressure detection and eviction.
  • Customizable Intervals: The utilization monitoring interval (UtilizationIntervalSeconds) and eviction detection interval (DetectIntervalSeconds) are now configurable, moving away from hard-coded 10-second values.
  • Adjustable High Usage Count Limit: The HighUsageCountLimit, which determines how many consecutive high-usage detections trigger eviction, is now configurable instead of being a hard-coded value of 6.
  • Backward Compatibility: Default values for the new configurable parameters (10 seconds for intervals, 6 for high usage count) ensure backward compatibility with existing deployments.
  • Validation Logic Added: New validation logic has been implemented for the NodeMonitor configuration to ensure that the provided interval and limit values are positive.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@volcano-sh-bot volcano-sh-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 11, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces configurability for the node monitor's thresholds, which is a great enhancement for tuning node pressure sensitivity. The implementation correctly defines the new configuration options and adds validation for them.

However, I've identified a few issues that need to be addressed:

  1. In pkg/agent/config/api/validate.go, the new validation error messages are hardcoded, which is inconsistent with the existing practice of using constants.
  2. The RefreshCfg function in pkg/agent/events/probes/nodemonitor/node_monitor.go is incomplete. It doesn't update the monitor with the new configuration values for highUsageCountLimit, utilizationInterval, and detectInterval.
  3. Most critically, the Run method in node_monitor.go uses wait.Until, which does not support dynamic updates of the execution interval. This means that changes to utilizationIntervalSeconds and detectIntervalSeconds in the configuration will not take effect at runtime.

I've provided detailed comments and suggestions to address these points. Once these are fixed, the feature will be robust and work as expected.

Comment on lines 90 to 94
func (m *monitor) Run(stop <-chan struct{}) {
klog.InfoS("Started nodePressure probe")
go wait.Until(m.utilizationMonitoring, 10*time.Second, stop)
go wait.Until(m.detect, 10*time.Second, stop)
go wait.Until(m.utilizationMonitoring, m.utilizationInterval, stop)
go wait.Until(m.detect, m.detectInterval, stop)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The Run method starts two goroutines using wait.Until. The period argument for wait.Until is passed by value, which means the goroutines will continue to use the initial interval values for their entire lifetime. Any subsequent updates to m.utilizationInterval or m.detectInterval via RefreshCfg will not be picked up by the running goroutines. This defeats the purpose of making the intervals configurable at runtime.

To fix this, you should change the implementation to periodically re-evaluate the interval. A simple way is to replace wait.Until with a custom loop that reads the interval on each iteration.

func (m *monitor) Run(stop <-chan struct{}) {
	klog.InfoS("Started nodePressure probe")
	go func() {
		for {
			m.Lock()
			interval := m.utilizationInterval
			m.Unlock()
			select {
			case <-time.After(interval):
				m.utilizationMonitoring()
			case <-stop:
				return
			}
		}
	}()
	go func() {
		for {
			m.Lock()
			interval := m.detectInterval
			m.Unlock()
			select {
			case <-time.After(interval):
				m.detect()
			case <-stop:
				return
			}
		}
	}()
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the detailed review.
I’ve updated the Run loop to dynamically re-evaluate intervals, wired NodeMonitor values in RefreshCfg, and moved validation messages to constants for consistency.

Comment on lines +117 to 125
if n.UtilizationIntervalSeconds != nil && *n.UtilizationIntervalSeconds <= 0 {
errs = append(errs, errors.New("utilizationIntervalSeconds must be positive"))
}
if n.DetectIntervalSeconds != nil && *n.DetectIntervalSeconds <= 0 {
errs = append(errs, errors.New("detectIntervalSeconds must be positive"))
}
if n.HighUsageCountLimit != nil && *n.HighUsageCountLimit <= 0 {
errs = append(errs, errors.New("highUsageCountLimit must be positive"))
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For consistency with other validation functions in this file, it's better to define the error messages as constants at the package level instead of using hardcoded strings. This improves maintainability and makes it easier to manage error messages.

You can add these constants to the var block at the top of the file:

var (
    // ... existing error messages
    IllegalUtilizationIntervalSecondsMsg = "utilizationIntervalSeconds must be positive"
    IllegalDetectIntervalSecondsMsg      = "detectIntervalSeconds must be positive"
    IllegalHighUsageCountLimitMsg        = "highUsageCountLimit must be positive"
)
Suggested change
if n.UtilizationIntervalSeconds != nil && *n.UtilizationIntervalSeconds <= 0 {
errs = append(errs, errors.New("utilizationIntervalSeconds must be positive"))
}
if n.DetectIntervalSeconds != nil && *n.DetectIntervalSeconds <= 0 {
errs = append(errs, errors.New("detectIntervalSeconds must be positive"))
}
if n.HighUsageCountLimit != nil && *n.HighUsageCountLimit <= 0 {
errs = append(errs, errors.New("highUsageCountLimit must be positive"))
}
if n.UtilizationIntervalSeconds != nil && *n.UtilizationIntervalSeconds <= 0 {
errs = append(errs, errors.New(IllegalUtilizationIntervalSecondsMsg))
}
if n.DetectIntervalSeconds != nil && *n.DetectIntervalSeconds <= 0 {
errs = append(errs, errors.New(IllegalDetectIntervalSecondsMsg))
}
if n.HighUsageCountLimit != nil && *n.HighUsageCountLimit <= 0 {
errs = append(errs, errors.New(IllegalHighUsageCountLimitMsg))
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the detailed review.
I’ve updated the Run loop to dynamically re-evaluate intervals, wired NodeMonitor values in RefreshCfg, and moved validation messages to constants for consistency.

Signed-off-by: AmanKumar <itsamankumar786@gmail.com>
Signed-off-by: AmanKumar <itsamankumar786@gmail.com>
Signed-off-by: AmanKumar <itsamankumar786@gmail.com>
@JesseStutler

Copy link
Copy Markdown
Member

Hi @AmanKumar1411 I think #4924 already worked on this

@AmanKumar1411

Copy link
Copy Markdown
Author

@JesseStutler i think the #4924 is till open

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

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants