Skip to content
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: optimize implement of the sync peers #3677

Merged
merged 1 commit into from
Nov 29, 2024
Merged

Conversation

gaius-qi
Copy link
Member

Description

This pull request includes significant changes to the synchronization of peer information in the manager package, specifically focusing on improving the sync process and validation. The most important changes include updating the peer sync logic, adding validation for the BatchSize parameter, and modifying related tests.

Improvements to peer synchronization:

  • manager/job/sync_peers.go: Refactored the SyncPeers interface and related methods to make the sync operation synchronous, ensuring no concurrent sync jobs run simultaneously. The new logic merges sync peer results with the database and handles batch operations more efficiently. [1] [2] [3]

Validation enhancements:

  • manager/config/config.go: Added validation to ensure BatchSize is not zero in the Validate method and updated the SyncPeersConfig struct to clarify the purpose of the BatchSize field. [1] [2]

Test updates:

Configuration updates:

These changes enhance the robustness and efficiency of the peer synchronization process and ensure proper configuration validation.

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.

@gaius-qi gaius-qi added the enhancement New feature or request label Nov 29, 2024
@gaius-qi gaius-qi added this to the v2.2.0 milestone Nov 29, 2024
@gaius-qi gaius-qi self-assigned this Nov 29, 2024
@gaius-qi gaius-qi requested a review from a team as a code owner November 29, 2024 06:15
@gaius-qi gaius-qi force-pushed the feature/sync-peers branch 2 times, most recently from 8a1941e to 0a2873b Compare November 29, 2024 06:17
Copy link

codecov bot commented Nov 29, 2024

Codecov Report

Attention: Patch coverage is 5.85106% with 177 lines in your changes missing coverage. Please review.

Project coverage is 35.45%. Comparing base (d0e41b5) to head (da3184a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
manager/job/sync_peers.go 0.00% 123 Missing ⚠️
manager/service/job.go 0.00% 44 Missing ⚠️
manager/job/mocks/sync_peers_mock.go 0.00% 4 Missing ⚠️
manager/service/mocks/service_mock.go 0.00% 3 Missing ⚠️
manager/handlers/job.go 0.00% 2 Missing ⚠️
pkg/digest/digest.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3677      +/-   ##
==========================================
- Coverage   35.50%   35.45%   -0.05%     
==========================================
  Files         336      335       -1     
  Lines       37657    37617      -40     
==========================================
- Hits        13369    13337      -32     
+ Misses      23461    23457       -4     
+ Partials      827      823       -4     
Flag Coverage Δ
unittests 35.45% <5.85%> (-0.05%) ⬇️

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

Files with missing lines Coverage Δ
api/manager/docs.go 0.00% <ø> (ø)
manager/config/config.go 96.34% <100.00%> (+0.04%) ⬆️
manager/job/job.go 16.07% <ø> (ø)
manager/service/service.go 0.00% <ø> (ø)
scheduler/service/service_v1.go 85.33% <100.00%> (+0.31%) ⬆️
scheduler/service/service_v2.go 68.46% <100.00%> (+0.21%) ⬆️
pkg/digest/digest.go 71.00% <0.00%> (ø)
manager/handlers/job.go 50.42% <0.00%> (+0.42%) ⬆️
manager/service/mocks/service_mock.go 95.52% <0.00%> (+0.12%) ⬆️
manager/job/mocks/sync_peers_mock.go 0.00% <0.00%> (ø)
... and 2 more

... and 4 files with indirect coverage changes

@gaius-qi gaius-qi requested a review from a team as a code owner November 29, 2024 07:27
@gaius-qi gaius-qi force-pushed the feature/sync-peers branch 2 times, most recently from 0b273ad to 1a855da Compare November 29, 2024 07:47
chlins
chlins previously approved these changes Nov 29, 2024
Copy link
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

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

lgtm

@gaius-qi gaius-qi force-pushed the feature/sync-peers branch 2 times, most recently from af40d1a to 3a0ba1f Compare November 29, 2024 11:27
Signed-off-by: Gaius <gaius.qi@gmail.com>
@gaius-qi gaius-qi merged commit aa78396 into main Nov 29, 2024
35 checks passed
@gaius-qi gaius-qi deleted the feature/sync-peers branch November 29, 2024 13:13
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.

2 participants