Skip to content

feat(gc): add gcTimeWindow to limit periodic GC to a local time range#4017

Open
AkashKumar7902 wants to merge 1 commit into
project-zot:mainfrom
AkashKumar7902:feat/gc-time-window
Open

feat(gc): add gcTimeWindow to limit periodic GC to a local time range#4017
AkashKumar7902 wants to merge 1 commit into
project-zot:mainfrom
AkashKumar7902:feat/gc-time-window

Conversation

@AkashKumar7902

Copy link
Copy Markdown
Contributor

Summary

  • Adds a new optional gcTimeWindow storage setting that confines scheduled garbage collection to a local time range (e.g. 01.00 - 08.00), supporting both . and : separators and windows that cross midnight.
  • Honours the window for the default store and each subpath, validates the value at config load, and gates the GC task generator's readiness on the window.
  • Updates examples/README.md and examples/config-gc-periodic.json so operators can discover and copy the new option.

Closes #3001

Implementation notes

  • pkg/storage/gc/time_window.go exposes ParseTimeWindow / TimeWindow.Contains. The window is empty by default (matches today's behaviour).
  • pkg/api/controller.go plumbs the parsed window through gc.Options for both the default store and subpaths; an invalid value logs and skips scheduled GC for that store rather than failing the whole server.
  • pkg/cli/server/root.go rejects malformed values up-front and warns when a window is set without gc: true.
  • UpdateReloadableConfig carries the new field across reloads so live config edits take effect without a restart.

Test plan

  • go test ./pkg/storage/gc/... ./pkg/api/config/... ./pkg/cli/server/...
  • golangci-lint run on the touched packages
  • Verified parsing of same-day window, midnight-crossing window, and invalid inputs via unit tests
  • Verified GC task generator readiness honours the window via unit test

Periodic garbage collection acquires storage locks that can hurt
latency on high-load setups. Allow operators to confine scheduled
GC to a quiet local time window (e.g. "01.00 - 08.00"), supporting
both '.' and ':' separators and ranges that cross midnight. The
window is honoured per-store and per-subpath, validated at config
load, and applied via the GC task generator readiness check.

Closes project-zot#3001

Signed-off-by: Akash Kumar <meakash7902@gmail.com>
@codecov

codecov Bot commented Apr 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.78947% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.39%. Comparing base (8282aef) to head (c909154).
⚠️ Report is 52 commits behind head on main.

Files with missing lines Patch % Lines
pkg/storage/gc/time_window.go 80.39% 6 Missing and 4 partials ⚠️
pkg/api/controller.go 60.00% 5 Missing and 3 partials ⚠️
pkg/cli/server/root.go 64.28% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4017      +/-   ##
==========================================
- Coverage   91.42%   91.39%   -0.04%     
==========================================
  Files         197      198       +1     
  Lines       28152    28237      +85     
==========================================
+ Hits        25739    25806      +67     
- Misses       1562     1572      +10     
- Partials      851      859       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rchincha rchincha added this to the v2.1.17 milestone May 1, 2026
@rchincha

rchincha commented May 8, 2026

Copy link
Copy Markdown
Contributor

@AkashKumar7902 pls fix merge conflicts and ci failures

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat]: Implement gcTimeWindow in order to reduce storage locking during active usage time

2 participants