-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
add a --watch flag to oc rsync #8268
Conversation
@csrwng @smarterclayton ptal |
8417f21
to
dcc7d3c
Compare
also if one of you could test this on a mac that'd be awesome :) |
So it works on the Mac, at least on my simple test. One thing I ran into though as soon as I tried it is that fsnotify complained of not being able to open a file. I realized that the default limit for open files on the Mac is tiny (256). We may want to mention that in the doc. |
yeah so as you see i have a comment in the code about that, it's probably so common that the error should say "try this...." if we get an error adding the watch. |
} | ||
|
||
// recursive logic from https://github.com/bronze1man/kmg/blob/master/fsnotify/Watcher.go | ||
func watchRecursion(watcher *fsnotify.Watcher, path string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like this should be in a different package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, i debated moving this whole watcher mess to a helper package. i can do that.
6e2798c
to
c0485dc
Compare
@smarterclayton helpers moved to package |
@bparees test will come as follow up, right? ;-) |
time.Sleep(2 * time.Second) | ||
} | ||
// unreachable | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two lines above can/should be removed. The compiler knows about unreachable code, and so does go vet
:
$ go vet pkg/cmd/cli/cmd/rsync/rsync.go
pkg/cmd/cli/cmd/rsync/rsync.go:308: unreachable code
exit status 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool
This might be a starting point for documenting the behavior (incl. max files): https://github.com/fsnotify/fsnotify/wiki/FAQ |
if event.Op&fsnotify.Remove == fsnotify.Remove { | ||
watcher.Remove(event.Name) | ||
} else { | ||
fsnotification.AddRecursiveWatch(watcher, event.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK we don't need to add watchers per file, only directories. Watching a directory gets events for all files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
howeyc/fsnotify#56 (comment) for reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh well, AddRecursiveWatch
actually ignores paths that are not directories. That's subtle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we check the error returned by fsnotification.AddRecursiveWatch
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will add a comment to the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and yes, should. will assign it to watchError
return nil | ||
} | ||
|
||
// getSubFolders recursively retrieves all subfolders of the specified path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a final period.
Two documentation nits, code LGTM. Nice stuff @bparees, thanks! |
fe639f9
to
42faf99
Compare
nits addressed, thanks @rhcarvalho |
@@ -111,6 +117,7 @@ func NewCmdRsync(name, parent string, f *clientcmd.Factory, out, errOut io.Write | |||
cmd.Flags().StringVar(&o.RsyncInclude, "include", "", "rsync - include files matching specified pattern") | |||
cmd.Flags().BoolVar(&o.RsyncProgress, "progress", false, "rsync - show progress during transfer") | |||
cmd.Flags().BoolVar(&o.RsyncNoPerms, "no-perms", false, "rsync - do not transfer permissions") | |||
cmd.Flags().BoolVarP(&o.Watch, "watch", "w", false, "Watch directory for changes and resync automatically") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is consistent with get
, correct? Will we ever introduce a "watch" flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if by "consistent" with get you mean that get has a --watch flag, then yes. Whether what get --watch does is similar enough to rsync --watch that they should be using the same argument name is debatable. (get is reading something and display you the result whenever it changes. rsync is monitoring the filesystem for changes and sending them to the container whenever it changes). So...similarish, not identical.
would we ever want the equivalent of get --watch functionality in rsync? I have a hard time envisioning that we would.
overall watch feels like the right name here i think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would we ever want the equivalent of get --watch functionality in rsync? I have a hard time envisioning that we would.
by which i mean, i have a hard time envisioning what that would mean/do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine, just wanted to check
On Tue, Apr 26, 2016 at 12:42 PM, Ben Parees [email protected]
wrote:
In pkg/cmd/cli/cmd/rsync/rsync.go
#8268 (comment):@@ -111,6 +117,7 @@ func NewCmdRsync(name, parent string, f *clientcmd.Factory, out, errOut io.Write
cmd.Flags().StringVar(&o.RsyncInclude, "include", "", "rsync - include files matching specified pattern")
cmd.Flags().BoolVar(&o.RsyncProgress, "progress", false, "rsync - show progress during transfer")
cmd.Flags().BoolVar(&o.RsyncNoPerms, "no-perms", false, "rsync - do not transfer permissions")
- cmd.Flags().BoolVarP(&o.Watch, "watch", "w", false, "Watch directory for changes and resync automatically")
would we ever want the equivalent of get --watch functionality in rsync? I
have a hard time envisioning that we would.by which i mean, i have a hard time envisioning what that would mean/do.
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/8268/files/b9f4b16543df4fb40bdd86f2797f6d2dd2e14093..5b20fcd4b5c6e42bdf67cf7b118d57d95e532e6f#r61120407
da64699
to
62808bc
Compare
So much pull through, so much fail. [test] On Tue, Apr 26, 2016 at 7:05 PM, OpenShift Bot [email protected]
|
Evaluated for origin test up to 899f157 |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/3397/) |
Evaluated for origin testonlyextended up to 899f157 |
continuous-integration/openshift-jenkins/testonlyextended SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin_extended/119/) (Extended Tests: core(rsync)) |
[merge] |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/5740/) (Image: devenv-rhel7_4057) |
Evaluated for origin merge up to 899f157 |
@thesteve0 fyi. merged. |
And there was much rejoicing!!!! So this will be in the next origin release? On Thu, Apr 28, 2016 at 5:55 PM, Ben Parees [email protected]
|
@thesteve0 yeah. |
add a --watch flag to oc rsync so it watches the filesystem for changes and automatically syncs when the filesystem changes