Skip to content

feat:NodeLockTimeout set from env - #1244

Merged
hami-robot[bot] merged 1 commit into
Project-HAMi:masterfrom
miaobyte:master
Aug 6, 2025
Merged

feat:NodeLockTimeout set from env#1244
hami-robot[bot] merged 1 commit into
Project-HAMi:masterfrom
miaobyte:master

Conversation

@miaobyte

@miaobyte miaobyte commented Jul 31, 2025

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR adds functionality to configure the node lock timeout duration via an environment variable (HAMI_NODELOCK_EXPIRE). This allows users to customize the timeout period according to their specific requirements without needing to modify and recompile the code.

Which issue(s) this PR fixes:
Fixes #810

Special notes for your reviewer:

The default timeout remains at 5 minutes when the environment variable is not set or cannot be parsed correctly. When parsing fails, an error log is generated, and the system falls back to the default value.

Does this PR introduce a user-facing change?:
Yes. Users can now set the HAMI_NODELOCK_EXPIRE environment variable to customize the node lock timeout duration.

@hami-robot

hami-robot Bot commented Jul 31, 2025

Copy link
Copy Markdown
Contributor

Welcome @miaobyte! It looks like this is your first PR to Project-HAMi/HAMi 🎉

@hami-robot hami-robot Bot added the size/S label Jul 31, 2025

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary of Changes

Hello @miaobyte, 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 significantly improves the operational flexibility of the system by externalizing the node lock timeout configuration. Users can now easily customize this critical duration through an environment variable, which can be managed and deployed via Helm. This change streamlines the process of adapting the system to specific environmental requirements without requiring recompilation or direct code modification.

Highlights

  • Configurability via Environment Variable: This pull request introduces the capability to configure the node lock timeout duration using the HAMI_NODELOCK_EXPIRE environment variable, allowing for dynamic adjustment without code changes.
  • Helm Chart Integration: The new nodeLockExpire setting has been integrated into the Helm chart (charts/hami/values.yaml and charts/hami/templates/scheduler/deployment.yaml), enabling users to set this timeout directly through their deployment configurations.
  • Robust Default and Fallback: The system maintains a default node lock timeout of 5 minutes. If the HAMI_NODELOCK_EXPIRE environment variable is not set or its value cannot be parsed, the system gracefully falls back to this default, logging an error for clarity.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 or fill out our survey to provide feedback.

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.

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

Copy link
Copy Markdown
Contributor

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 a feature to configure the node lock timeout via the HAMI_NODELOCK_EXPIRE environment variable. The changes include updates to the Helm chart to expose this configuration and the core logic in Go to read the environment variable.

The implementation is straightforward, but there's a critical issue where the new configuration from the environment variable is overridden by an existing command-line flag configuration in cmd/scheduler/main.go, rendering the new feature ineffective. I've detailed this issue in my comments.

Additionally, I've provided a couple of suggestions to improve code maintainability and testability regarding comments, logging, and unit testing. Please address the critical issue to ensure the feature works as intended.

Comment thread pkg/util/nodelock/nodelock.go Outdated
Comment thread pkg/util/nodelock/nodelock.go Outdated
Comment thread pkg/util/nodelock/nodelock.go Outdated
Comment thread pkg/util/nodelock/nodelock.go Outdated
@hami-robot

hami-robot Bot commented Aug 1, 2025

Copy link
Copy Markdown
Contributor

@miaobyte: you cannot LGTM your own PR.

Details

In response to this:

/lgtm

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.

@wawa0210

wawa0210 commented Aug 1, 2025

Copy link
Copy Markdown
Member

@miaobyte Could you please pay attention to the review suggestions of Gemini and make targeted modifications?

@miaobyte

miaobyte commented Aug 1, 2025

Copy link
Copy Markdown
Contributor Author

@wawa0210 ok

@wawa0210

wawa0210 commented Aug 1, 2025

Copy link
Copy Markdown
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@wawa0210 OK

@miaobyte

miaobyte commented Aug 1, 2025

Copy link
Copy Markdown
Contributor Author

In scenarios where a large number of tasks are submitted in a short period, the current 5-minute node lock timeout can cause nodes to remain locked for extended periods, preventing new tasks from being scheduled.

Based on practical experience, reducing the timeout to 1 minute is a more reasonable choice that significantly improves cluster resource utilization and task throughput efficiency.

This environment variable configuration approach maintains flexibility (allowing users to customize timeout periods according to their specific scenarios) while providing a better default experience for high-frequency task submission environments.

The PR introduces this configuration option while maintaining backward compatibility with existing deployments.

@miaobyte

miaobyte commented Aug 1, 2025

Copy link
Copy Markdown
Contributor Author

@wawa0210 done

@wawa0210

wawa0210 commented Aug 1, 2025

Copy link
Copy Markdown
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@wawa0210 done

@miaobyte

miaobyte commented Aug 1, 2025

Copy link
Copy Markdown
Contributor Author

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

@wawa0210 done

@wawa0210
@ouyangluwei163
need LGTM to this PR

@miaobyte

miaobyte commented Aug 1, 2025

Copy link
Copy Markdown
Contributor Author

/kind feature

Comment thread charts/hami/values.yaml Outdated
Comment thread charts/hami/values.yaml Outdated
@codecov

codecov Bot commented Aug 4, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/util/nodelock/nodelock.go 33.33% 7 Missing and 1 partial ⚠️
Flag Coverage Δ
unittests 65.92% <33.33%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/util/nodelock/nodelock.go 51.81% <33.33%> (-2.27%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

set to default 5m

Signed-off-by: peng.li24 <peng.li24@nio.com>
@wawa0210

wawa0210 commented Aug 5, 2025

Copy link
Copy Markdown
Member

/lgtm
/approve

@Shouren Shouren left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@hami-robot

hami-robot Bot commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: miaobyte, Shouren, wawa0210

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

The pull request process is described 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

@hami-robot
hami-robot Bot merged commit d2cef08 into Project-HAMi:master Aug 6, 2025
16 checks passed
@fishman fishman mentioned this pull request Jul 1, 2026
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.

this pr will lead pod schedule hang very long time. https://github.com/Project-HAMi/HAMi/pull/714

3 participants