Skip to content

Conversation

chlins
Copy link
Member

@chlins chlins commented May 19, 2025

This pull request introduces a new Garbage Collection (GC) job functionality to the system, including its creation, execution, and management. The changes span across multiple files and involve updates to constants, context handling, service interfaces, and job creation logic. Below is a summary of the most important changes:

New GC Job Functionality:

  • Added a new constant GCJob to represent the GC job type in internal/job/constants.go.
  • Introduced a CreateGCJob method in the service layer to handle the creation of GC jobs. This includes asynchronous execution and polling for job completion. [1] [2]
  • Added a new CreateGCJobRequest type in manager/types/job.go to define the structure for GC job creation requests.

Context Enhancements:

  • Introduced ContextKeyUserID and ContextKeyTaskID in pkg/gc/gc.go to manage user and task IDs in the context, enabling better tracking of GC jobs.
  • Updated recorder.Init methods in manager/gc/audit.go and manager/gc/job.go to include user and task IDs from the context. [1] [2]

Service and Job Management Updates:

  • Modified the Service interface in manager/service/service.go to include the new CreateGCJob method.
  • Updated the service struct to include a gc field for managing GC tasks, and updated its initialization in the New function. [1] [2]
  • Added mock implementations for CreateGCJob in manager/service/mocks/service_mock.go for testing purposes.

Miscellaneous Changes:

  • Updated the manager/manager.go file to properly initialize and register GC tasks using the new managergc package alias. [1] [2]
  • Enhanced the jobRecorder.Init method to support the new GC job type by including the UserID field.

Description

Related Issue

Motivation and Context

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@chlins chlins requested a review from a team as a code owner May 19, 2025 06:35
@chlins chlins added the enhancement New feature or request label May 19, 2025
@chlins chlins requested review from jim3ma, gaius-qi and hyy0322 May 19, 2025 06:35
yxxhero
yxxhero previously approved these changes May 19, 2025
Signed-off-by: chlins <chlins.zhang@gmail.com>
Copy link

codecov bot commented May 20, 2025

Codecov Report

Attention: Patch coverage is 1.02041% with 97 lines in your changes missing coverage. Please review.

Project coverage is 33.18%. Comparing base (c63b794) to head (a541bed).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
manager/service/job.go 0.00% 35 Missing ⚠️
manager/gc/audit.go 0.00% 15 Missing ⚠️
manager/gc/job.go 0.00% 15 Missing ⚠️
manager/handlers/job.go 8.33% 11 Missing ⚠️
manager/service/mocks/service_mock.go 0.00% 9 Missing ⚠️
manager/manager.go 0.00% 6 Missing ⚠️
manager/gc/recorder.go 0.00% 2 Missing ⚠️
manager/service/service.go 0.00% 2 Missing ⚠️
pkg/gc/gc.go 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4074      +/-   ##
==========================================
- Coverage   33.25%   33.18%   -0.08%     
==========================================
  Files         346      346              
  Lines       40493    40581      +88     
==========================================
  Hits        13466    13466              
- Misses      26134    26222      +88     
  Partials      893      893              
Flag Coverage Δ
unittests 33.18% <1.02%> (-0.08%) ⬇️

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

Files with missing lines Coverage Δ
manager/gc/recorder.go 0.00% <0.00%> (ø)
manager/service/service.go 0.00% <0.00%> (ø)
pkg/gc/gc.go 91.17% <0.00%> (-2.77%) ⬇️
manager/manager.go 0.00% <0.00%> (ø)
manager/service/mocks/service_mock.go 93.73% <0.00%> (-1.05%) ⬇️
manager/handlers/job.go 45.80% <8.33%> (-4.62%) ⬇️
manager/gc/audit.go 0.00% <0.00%> (ø)
manager/gc/job.go 0.00% <0.00%> (ø)
manager/service/job.go 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@gaius-qi gaius-qi left a comment

Choose a reason for hiding this comment

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

LGTM

@chlins chlins enabled auto-merge (squash) May 20, 2025 11:52
Copy link

@Liam-Zhao Liam-Zhao left a comment

Choose a reason for hiding this comment

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

LGTM

@chlins chlins merged commit 93aefb4 into main May 20, 2025
28 checks passed
@chlins chlins deleted the feat/manual-gc branch May 20, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants