-
Notifications
You must be signed in to change notification settings - Fork 5k
feat: support customize the job execution retention count by env #22129
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
feat: support customize the job execution retention count by env #22129
Conversation
Signed-off-by: chlins <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #22129 +/- ##
===========================================
+ Coverage 45.36% 65.89% +20.52%
===========================================
Files 244 1072 +828
Lines 13333 115713 +102380
Branches 2719 2925 +206
===========================================
+ Hits 6049 76246 +70197
- Misses 6983 35243 +28260
- Partials 301 4224 +3923
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Vad1mo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this config option bypassing config.go, and the usual way of on how new configuration options are introduced into Harbor?
@Vad1mo Currently, not all configurations go through config. The configurations that do are generally focused on a specific function and need to be exposed to users during deployment and installation. However, some configurations don't necessarily need to be exposed—they might just be advanced settings that most users don't need to customize. Adding another config layer in such cases would actually increase complexity and maintenance costs. In my opinion, these configurations are just custom needs for a small number of users and won't be reused elsewhere, so directly reading environment variables is the simplest approach. |
wy65701436
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…arbor#22129) Signed-off-by: chlins <[email protected]> Signed-off-by: AYDEV-FR <[email protected]>
…arbor#22129) Signed-off-by: chlins <[email protected]>
This pull request introduces a new utility function for reading environment variables and updates the job execution retention logic to use environment-configurable values. It also includes comprehensive unit tests for the new utility function. Below are the most important changes:
New Utility Function for Environment Variables
GetEnvInt64function insrc/lib/env.goto read environment variables asint64with a default fallback value. This ensures flexibility in configuring values through environment variables.Refactoring of Job Execution Retention Logic
executionSweeperCountmap insrc/jobservice/job/known_jobs.goto use theGetEnvInt64function for fetching retention counts from environment variables. This allows dynamic configuration of retention counts without changing the code.libpackage insrc/jobservice/job/known_jobs.goto utilize the new utility function.Unit Testing for the Utility Function
src/lib/env_test.gowith comprehensive test cases forGetEnvInt64, covering scenarios such as valid values, unset variables, invalid values, zero, negative, and large numbers. This ensures reliability and correctness of the function.Thank you for contributing to Harbor!
Comprehensive Summary of your change
Issue being fixed
#20777
Please indicate you've done the following: