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

cmd/sync: add 'max-failure' to exit when the transfer encounters more than a certain number of errors #5142

Merged
merged 8 commits into from
Sep 12, 2024

Conversation

zhijian-pro
Copy link
Contributor

@zhijian-pro zhijian-pro commented Sep 4, 2024

close #5140

@zhijian-pro zhijian-pro marked this pull request as draft September 4, 2024 09:55
@davies
Copy link
Contributor

davies commented Sep 5, 2024

Maybe --max-errors or --max-failure? we have --max-failure for warmup

@zhijian-pro
Copy link
Contributor Author

Maybe --max-errors or --max-failure? we have --max-failure for warmup

ok

Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 10.86957% with 41 lines in your changes missing coverage. Please review.

Project coverage is 44.60%. Comparing base (b6582db) to head (7b54930).
Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
pkg/sync/sync.go 0.00% 40 Missing ⚠️
pkg/sync/config.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5142      +/-   ##
==========================================
- Coverage   44.65%   44.60%   -0.05%     
==========================================
  Files         159      159              
  Lines       43347    43471     +124     
==========================================
+ Hits        19355    19389      +34     
- Misses      21566    21656      +90     
  Partials     2426     2426              

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

@zhijian-pro zhijian-pro marked this pull request as ready for review September 5, 2024 13:50
@zhijian-pro zhijian-pro changed the title cmd/sync: add --fail-fast to exit as soon as the transfer encounters an error cmd/sync: add 'max-failure' to exit when the transfer encounters more than a certain number of errors Sep 6, 2024
@zhijian-pro zhijian-pro requested review from SandyXSD and jiefenghuang and removed request for SandyXSD September 9, 2024 01:17
pkg/sync/sync.go Outdated Show resolved Hide resolved
Copy link
Contributor

@jiefenghuang jiefenghuang left a comment

Choose a reason for hiding this comment

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

for supporting fast failed, add context to worker may be more concise and simple

func worker(ctx context.Context, tasks <-chan object.Object, src, dst object.ObjectStorage, config *Config) {
    for {
        select {
            case <-ctx.Done():
                // cancel
                return
             case obj := <-tasks:
                 // origin logic
        }
        if failed >= xxx {
            ctx.cancel()
            ...
        }
    }
}

@zhijian-pro
Copy link
Contributor Author

for supporting fast failed, add context to worker may be more concise and simple

func worker(ctx context.Context, tasks <-chan object.Object, src, dst object.ObjectStorage, config *Config) {
    for {
        select {
            case <-ctx.Done():
                // cancel
                return
             case obj := <-tasks:
                 // origin logic
        }
        if failed >= xxx {
            ctx.cancel()
            ...
        }
    }
}

ok

@zhijian-pro zhijian-pro marked this pull request as ready for review September 10, 2024 02:49
Copy link
Contributor

@jiefenghuang jiefenghuang left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@davies davies left a comment

Choose a reason for hiding this comment

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

this may not work in cluster mode

This reverts commit 1d12366.
This reverts commit 234b809.
@zhijian-pro
Copy link
Contributor Author

for supporting fast failed, add context to worker may be more concise and simple

func worker(ctx context.Context, tasks <-chan object.Object, src, dst object.ObjectStorage, config *Config) {
    for {
        select {
            case <-ctx.Done():
                // cancel
                return
             case obj := <-tasks:
                 // origin logic
        }
        if failed >= xxx {
            ctx.cancel()
            ...
        }
    }
}

Let's do it the easy way, it's a little bit more complicated

@davies davies merged commit e5a821d into main Sep 12, 2024
39 checks passed
@davies davies deleted the sync-fail-fast branch September 12, 2024 03:15
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.

Sync tool support fail on error mode
3 participants