Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2487)

Issue 66340045: cmd/juju: ssh/scp commands extra arguments; fixes (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 2 months ago by dimitern
Modified:
10 years, 1 month ago
Reviewers:
mp+207498, gz, axw
Visibility:
Public.

Description

cmd/juju: ssh/scp commands extra arguments; fixes Removed the extraneous "--" that the ssh command adds to the passed arguments, so any extra arguments after the command will be forwarded to ssh properly. It worked in 1.16, so this fixes a regression. This fixes bug #1281577. The scp command claims in its help that it supports -- to pass extra arguments to scp, but it does not and also does not support multiple local/remote targets to be specified, as OpenSSH scp command does. This fixes bug #1283412. Also, improved a lot of ssh-related tests in both utils/ssh/ and in cmd/juju/, adding new tests as needed for the extra arguments. Improved help texts for ssh, scp and add-machine commands (included examples for the extra args and multiple targets for scp, added ssh: example for add-machine). All changes are tested live: - bootstrapping on EC2 and running ssh or scp to test extra args and multiple targets; - manual bootstrapping - add-machine ssh:user@host to an existing env; - using juju on Windows, to test the embedded go.crypto ssh command. https://code.launchpad.net/~dimitern/juju-core/302-lp-1281577-ssh-command-extra-args/+merge/207498 Requires: https://code.launchpad.net/~dimitern/juju-core/301-lp-1282553-use-curl-not-wget-precise/+merge/207443 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : cmd/juju: ssh/scp commands extra arguments; fixes #

Total comments: 14
Unified diffs Side-by-side diffs Delta from patch set Stats (+187 lines, -87 lines) Patch
A [revision details] View 1 1 chunk +2 lines, -0 lines 0 comments Download
M cmd/juju/addmachine.go View 1 1 chunk +1 line, -0 lines 0 comments Download
M cmd/juju/debughooks_test.go View 1 1 chunk +2 lines, -2 lines 0 comments Download
M cmd/juju/scp.go View 1 3 chunks +34 lines, -12 lines 8 comments Download
M cmd/juju/scp_test.go View 1 3 chunks +40 lines, -11 lines 0 comments Download
M cmd/juju/ssh.go View 1 2 chunks +10 lines, -8 lines 0 comments Download
M cmd/juju/ssh_test.go View 1 2 chunks +12 lines, -18 lines 0 comments Download
M utils/ssh/run_test.go View 1 1 chunk +1 line, -1 line 0 comments Download
M utils/ssh/ssh.go View 1 4 chunks +15 lines, -7 lines 4 comments Download
M utils/ssh/ssh_gocrypto.go View 1 2 chunks +2 lines, -1 line 0 comments Download
M utils/ssh/ssh_gocrypto_test.go View 1 1 chunk +1 line, -1 line 0 comments Download
M utils/ssh/ssh_openssh.go View 1 3 chunks +48 lines, -14 lines 2 comments Download
M utils/ssh/ssh_test.go View 1 9 chunks +19 lines, -12 lines 0 comments Download

Messages

Total messages: 6
dimitern
Please take a look.
10 years, 2 months ago (2014-02-20 16:59:46 UTC) #1
gz
LGTM, but there are a few other questionable bits involved with the original change in ...
10 years, 2 months ago (2014-02-20 17:14:00 UTC) #2
axw
On 2014/02/20 17:14:00, gz wrote: > LGTM, but there are a few other questionable bits ...
10 years, 2 months ago (2014-02-21 01:46:28 UTC) #3
dimitern
Please take a look.
10 years, 1 month ago (2014-02-22 16:05:12 UTC) #4
axw
https://codereview.appspot.com/66340045/diff/20001/cmd/juju/scp.go File cmd/juju/scp.go (left): https://codereview.appspot.com/66340045/diff/20001/cmd/juju/scp.go#oldcode73 cmd/juju/scp.go:73: // BUG(dfc) This will not work for IPv6 addresses ...
10 years, 1 month ago (2014-02-24 04:29:35 UTC) #5
dimitern
10 years, 1 month ago (2014-02-24 17:31:02 UTC) #6
Message was sent while issue was closed.
Thanks for the review!
Find below my answers, and please review the follow-up which implements the
suggestions, here: https://codereview.appspot.com/67820048

https://codereview.appspot.com/66340045/diff/20001/cmd/juju/scp.go
File cmd/juju/scp.go (left):

https://codereview.appspot.com/66340045/diff/20001/cmd/juju/scp.go#oldcode73
cmd/juju/scp.go:73: // BUG(dfc) This will not work for IPv6 addresses like
2001:db8::1:2:/somepath.
On 2014/02/24 04:29:36, axw wrote:
> The BUG is still relevant, no?

I thought I fixed it, but I forgot. According to
http://marc.info/?l=openssh-unix-dev&m=112975365929888 we need to add
`\[`+host+`\]:` so that IPv6 addresses will be properly separated from the path.
Fixed and added a test for it.

https://codereview.appspot.com/66340045/diff/20001/cmd/juju/scp.go
File cmd/juju/scp.go (right):

https://codereview.appspot.com/66340045/diff/20001/cmd/juju/scp.go#newcode32
cmd/juju/scp.go:32: Copy 2 files from two units to the local backup/ directory,
passig -v
On 2014/02/24 04:29:36, axw wrote:
> s/passig/passing/

Done.

https://codereview.appspot.com/66340045/diff/20001/cmd/juju/scp.go#newcode35
cmd/juju/scp.go:35: juju scp ubuntu/0:/path/file1 -- -v ubuntu/1:/path/file2
backup/
On 2014/02/24 04:29:36, axw wrote:
> While it may be possible to do this, is it useful to highlight it as an
example?
> It seems a bit pathological, and not actually useful, so I'd just move "-- -v"
> to the end.
> 
> Also, we shouldn't *need* -- at all if the options are at the end, right? It
> would good if you could just do:
>     juju scp 0:/remote/dir /local/dir -r

Good point, I've changed the implementation, help text, and tests to accept
extra arguments at the end only and -- is no longer needed or allowed.

> 
> We may want to explicitly state that options are not supported unless OpenSSH
is
> available on the system... although, Copy isn't even implemented using
go.crypto
> at the moment.
> 

Mentioning OpenSSH is useful, added.

Also improved the error message given by go.crypto's Copy, because:
$ juju scp xx yy
ERROR Copy is not implemented

> Frankly, I think it's a bad idea to rely on implementation details like this
> (which is not your fault of course). It would be better if we just implemented
a
> subset of the scp options and passed them through. Then we're more easily able
> to implement those for the go.crypto client.

Yeah, that's definitely a future improvement worth doing, but not now.

https://codereview.appspot.com/66340045/diff/20001/cmd/juju/scp.go#newcode91
cmd/juju/scp.go:91: if strings.HasPrefix(arg, "-") {
On 2014/02/24 04:29:36, axw wrote:
> Actually, one of the more common usages of pass-through args that I've seen so
> far is "-o", "option". This won't work, since the option value will end up in
> the wrong place.

It works actually, added -o SomeOption in the extra args tests.

https://codereview.appspot.com/66340045/diff/20001/utils/ssh/ssh.go
File utils/ssh/ssh.go (right):

https://codereview.appspot.com/66340045/diff/20001/utils/ssh/ssh.go#newcode72
utils/ssh/ssh.go:72: // Copy copies file(s) between the local host a remote
host(s).
On 2014/02/24 04:29:36, axw wrote:
> s/a /and /
> (or just "local and remote")

Done.

https://codereview.appspot.com/66340045/diff/20001/utils/ssh/ssh.go#newcode74
utils/ssh/ssh.go:74: // any extra arguments are specified in extraArgs, they are
passed
On 2014/02/24 04:29:36, axw wrote:
> Client is implementation agnostic. Talking about scp here is wrong.

Removed the reference.

https://codereview.appspot.com/66340045/diff/20001/utils/ssh/ssh_openssh.go
File utils/ssh/ssh_openssh.go (right):

https://codereview.appspot.com/66340045/diff/20001/utils/ssh/ssh_openssh.go#n...
utils/ssh/ssh_openssh.go:17: var opensshCommonOptions =
map[string][]string{"-o": []string{"StrictHostKeyChecking no"}}
On 2014/02/24 04:29:36, axw wrote:
> What's the point of this change? To group options? Why? Seems to be
complicating
> things for no practical benefit.

The point is to improve the debug logging mostly, because I had a really hard
time initially figuring out what's going on (command and prepared arguments
format, etc.). Since opensshOptions used to build a []string directly from
*Options, it wasn't possible to recreate the actual generated command line for
ssh/scp, so I can log it. My goal was to log a valid command, so that if you
copy it from the log and paste it in a terminal will do the same.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b