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. |
pkg/cmd/cli/cmd/rsync/rsync.go
Outdated
| } | ||
|
|
||
| // 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.
Feels like this should be in a different package
There was a problem hiding this comment.
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? ;-) |
pkg/cmd/cli/cmd/rsync/rsync.go
Outdated
| time.Sleep(2 * time.Second) | ||
| } | ||
| // unreachable | ||
| return nil |
There was a problem hiding this comment.
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|
This might be a starting point for documenting the behavior (incl. max files): |
pkg/cmd/cli/cmd/rsync/rsync.go
Outdated
| if event.Op&fsnotify.Remove == fsnotify.Remove { | ||
| watcher.Remove(event.Name) | ||
| } else { | ||
| fsnotification.AddRecursiveWatch(watcher, event.Name) |
There was a problem hiding this comment.
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.
Oh well, AddRecursiveWatch actually ignores paths that are not directories. That's subtle.
There was a problem hiding this comment.
Shouldn't we check the error returned by fsnotification.AddRecursiveWatch?
There was a problem hiding this comment.
will add a comment to the function.
There was a problem hiding this comment.
and yes, should. will assign it to watchError
| return nil | ||
| } | ||
|
|
||
| // getSubFolders recursively retrieves all subfolders of the specified path |
|
Two documentation nits, code LGTM. Nice stuff @bparees, thanks! |
fe639f9 to
42faf99
Compare
|
nits addressed, thanks @rhcarvalho |
| 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.
This is consistent with get, correct? Will we ever introduce a "watch" flag?
There was a problem hiding this comment.
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.
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.
It's fine, just wanted to check
On Tue, Apr 26, 2016 at 12:42 PM, Ben Parees notifications@github.com
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 notifications@github.com
|
|
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 notifications@github.com
|
|
@thesteve0 yeah. |
add a --watch flag to oc rsync so it watches the filesystem for changes and automatically syncs when the filesystem changes