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

mirror with --watch should copy and exit for s3 endpoints #2345

Merged
merged 1 commit into from
Jan 8, 2018

Conversation

harshavardhana
Copy link
Member

Current code wouldn't exit unless we press CTRL+C
even if the endpoints do not support --watch, this PR
fixes this behavior.

@codecov-io
Copy link

codecov-io commented Jan 3, 2018

Codecov Report

Merging #2345 into master will decrease coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2345      +/-   ##
==========================================
- Coverage   10.76%   10.76%   -0.01%     
==========================================
  Files         103      103              
  Lines        7721     7723       +2     
==========================================
  Hits          831      831              
- Misses       6756     6758       +2     
  Partials      134      134
Impacted Files Coverage Δ
cmd/mirror-main.go 0% <0%> (ø) ⬆️
cmd/parallel-manager.go 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9da4929...ce2f2ae. Read the comment docs.

@kannappanr kannappanr requested review from vadmeste and krisis January 3, 2018 19:06
fn := <-p.queueCh
if fn == nil {
fn, ok := <-p.queueCh
if fn == nil || !ok {
Copy link
Member

Choose a reason for hiding this comment

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

why are you using fn before checking ok?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can use only one..

scanBar: func(s string) {},
statusCh: make(chan URLs),
queueCh: make(chan func() URLs),
wgStatus: new(sync.WaitGroup),
Copy link
Member

Choose a reason for hiding this comment

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

is watcherRunning member needed elsewhere or can it be removed from mirrorJob?

Copy link
Member Author

Choose a reason for hiding this comment

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

It can be removed not needed.

@harshavardhana harshavardhana force-pushed the fix-mirror branch 3 times, most recently from a042ca1 to ef47270 Compare January 5, 2018 06:46
Copy link
Member

@krisis krisis left a comment

Choose a reason for hiding this comment

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

LGTM and tested.

@harshavardhana
Copy link
Member Author

@vadmeste PTAL

@harshavardhana
Copy link
Member Author

@vadmeste can you take a look?

if mj.isWatch {
<-mj.trapCh
mj.watchMirror(ctx, cancelMirror)
Copy link
Member

Choose a reason for hiding this comment

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

We need to check the error message returned by this error, and I guess only print it as a warning.

Copy link
Member Author

Choose a reason for hiding this comment

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

Requires some restructuring let me do that.

// start the status go routine
mj.startStatus()

// Starts additional watcher thread for watching for new events.
if mj.isWatch {
go mj.watchMirror(ctx, cancelMirror)
Copy link
Member

Choose a reason for hiding this comment

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

It is not commented in the code, but the reason why we have this in a go-routine is to avoid missing new changes in source such as removing files, adding new files.. this is very useful especially when mirroring takes some times. Any reason why you are removing this @harshavardhana ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I know the reason @vadmeste , i generally thought it is not a big deal. Since they will be caught up later but i see now that it might be not a good idea and it is possible that we do not exit properly.

@harshavardhana
Copy link
Member Author

harshavardhana commented Jan 7, 2018

Simplified the code further @vadmeste - avoiding racy updates to provide struct members. Removed watchErr, mirrorErr

return
default:
errorIf(err, "Unexpected error during monitoring.")
errorIf(err.Trace(), "Watch is not implemented ignoring.")
Copy link
Member

Choose a reason for hiding this comment

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

I think this message is better, 'Unable to watch source path'.

Current code wouldn't exit unless we press CTRL+C
even if the endpoints do not support --watch, this PR
fixes this behavior.
@harshavardhana
Copy link
Member Author

fixed @vadmeste PTAL

Copy link
Member

@vadmeste vadmeste left a comment

Choose a reason for hiding this comment

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

LGTM & tested

@kannappanr kannappanr merged commit 13259ee into minio:master Jan 8, 2018
@harshavardhana harshavardhana deleted the fix-mirror branch January 8, 2018 18:58
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.

5 participants