lp:1616098: ssh,scp,dh pick reachable address among all #6481

Merged
merged 5 commits into from Oct 21, 2016

Conversation

Projects
None yet
6 participants
Contributor

dimitern commented Oct 20, 2016

Uses the new SSHClient API facade v2 (from #6468), if
available, and network.ReachableHostPort() (#6454) in
code shared between the ssh, scp, and debug-hooks CLI
commands, to select a reachable address from all known
addresses of the target (machine/unit/host).

Fixes http://pad.lv/1616098.

QA steps (live tested on both MAAS 1.9 with multiple-
NIC nodes and on lxd - see below):

  1. Using the tip of develop, bootstrap a lxd xenial controller.
  2. juju switch controller
  3. juju status 0 # note of the IP address (IP1)
  4. lxc exec -- ip addr add /24 dev eth0
    (add an extra IP on machine-0, from the same subnet)
  5. lxc exec -- systemctl restart jujud-machine-0.service
    (bounce the controller agent to pick up the new IP)
  6. juju ssh 0 # should work
  7. sudo ip route add blackhole /32
    (make the preferred public IP unreachable from your laptop)
  8. juju --debug ssh 0 # should fail with 'Invalid argument'
  9. git checkout dimitern/lp-1616098-ssh+scp-alladdresses
    (switch to this PR's branch and rebuild juju & jujud)
  10. juju ssh 0 # should work now, using IP2
  11. juju scp 0:/etc/issue . # as above
  12. juju deploy ubuntu --to 0
  13. juju debug-hooks ubuntu/0 # should work as well
    (small delay ~10s observed on lxd, because of 'sudo')
Contributor

dimitern commented Oct 20, 2016

@nskaggs Why are my PR not picked up by the pre-check job (almost every one I had to poke to get a run)?

Contributor

dimitern commented Oct 20, 2016

!!build!!

Owner

nskaggs commented Oct 20, 2016

@dimitern I'm not sure. Ping me on IRC and I can check the logs when you open a new one to see what the reason is.

This is a large change (> 500 lines). Somebody else needs to bless it.

As a nit, I did find the TestSSHCommandHostAddressRetry* functions non-obvious in how/what they were testing.

@@ -154,6 +220,7 @@ func (s *SSHCommonSuite) setupModel(c *gc.C) {
m := s.getMachineForUnit(c, u)
s.setAddresses(c, m)
s.setKeys(c, m)
+ s.setLinkLayerDevicesAddresses(c, m)
@frobware

frobware Oct 20, 2016

Contributor

This stuck out - why does the change require this?

@dimitern

dimitern Oct 21, 2016

Contributor

This adds LinkLayerDevices and sets addresses for them, to exercise apiClient.AllAddresses() returns them in addition to m.Addresses() already set above (only the public and private). Also setupModel is used in all 3 commands' test suites, so it seemed best to add it here only.

cmd/juju/commands/ssh_unix_test.go
- args: []string{"0", "uname", "-a"},
+ about: "connect to machine 0 (api v2)",
+ args: []string{"0"},
+ dialWith: dialerFuncFor("0.private", "0.public", "0.1.2.3"), // last one set on machine 0 eth0
@frobware

frobware Oct 20, 2016

Contributor

It's not clear what the comment means.

@dimitern

dimitern Oct 21, 2016

Contributor

It tries to clarify where that "0.1.2.3" came from - it was set by suite.setLinkLayerDevicesAddresses() for suite.m (machine-0). I'll rephrase it to make it clearer.

Contributor

frobware commented Oct 20, 2016

I did actually QA this change with the LXD provider and it worked as advertised. Subjectively, it also "feels" quicker when running juju ssh 0, for example.

Contributor

macgreagoir commented Oct 21, 2016

I can't bless it, but LGTM.

bz2 approved these changes Oct 21, 2016

+1

Contributor

dimitern commented Oct 21, 2016

$$fixes-1616098$$

Contributor

jujubot commented Oct 21, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Oct 21, 2016

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/9543

Contributor

dimitern commented Oct 21, 2016

$$retry-transient-failure$$

Contributor

jujubot commented Oct 21, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Oct 21, 2016

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/9544

Contributor

dimitern commented Oct 21, 2016

$$windows-this-time$$

Contributor

jujubot commented Oct 21, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Oct 21, 2016

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/9545

Contributor

dimitern commented Oct 21, 2016

$$again$$

Contributor

jujubot commented Oct 21, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit dd11dad into juju:develop Oct 21, 2016

1 check failed

github-check-merge-juju Built PR, ran unit tests, and tested LXD deploy.
Details

@dimitern dimitern deleted the dimitern:lp-1616098-ssh+scp-alladdresses branch Oct 21, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment