Description:
cmd/juju: check use-proxy before resolving address
We were translating machin/unit IDs to internal addresses
even if use-proxy=false. This manifested most prominently
when attempting to juju ssh to a machine or unit in a 1.18
environment.
-func (s *SSHCommonSuite) makeMachines(n int, c *gc.C, setAddress bool)
[]*state.Machine {
+func (s *SSHCommonSuite) makeMachines(n int, c *gc.C, setAddresses bool)
[]*state.Machine {
var machines = make([]*state.Machine, n)
for i := 0; i < n; i++ {
m, err := s.State.AddMachine("quantal", state.JobHostUnits)
c.Assert(err, gc.IsNil)
- if setAddress {
- s.setAddress(m, c)
+ if setAddresses {
+ s.setAddresses(m, c)
}
// must set an instance id as the ssh command uses that as a signal the
// machine has been provisioned
Reviewers: mp+218911_ code.launchpad. net,
Message:
Please take a look.
Description:
cmd/juju: check use-proxy before resolving address
We were translating machin/unit IDs to internal addresses
even if use-proxy=false. This manifested most prominently
when attempting to juju ssh to a machine or unit in a 1.18
environment.
Fixes lp:1313785
https:/ /code.launchpad .net/~axwalk/ juju-core/ lp1313785- ssh-useproxy/ +merge/ 218911
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/97230043/
Affected files (+23, -19 lines): ssh_test. go
A [revision details]
M cmd/juju/scp.go
M cmd/juju/ssh.go
M cmd/juju/
Index: [revision details] 20140509022908- 5uihgtxv6350ydf q
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: cmd/juju/scp.go
=== modified file 'cmd/juju/scp.go'
--- cmd/juju/scp.go 2014-04-12 05:53:58 +0000
+++ cmd/juju/scp.go 2014-05-09 05:17:45 +0000
@@ -102,19 +102,19 @@
return err
}
defer c.apiClient.Close()
- args, err := expandArgs(c.Args, c.hostFromTarget)
- if err != nil {
- return err
- }
var options *ssh.Options nd(options) ; err != nil {
- if proxy, err := c.proxySSH(); err != nil {
+ if c.proxy, err = c.proxySSH(); err != nil {
return err
- } else if proxy {
+ } else if c.proxy {
options = new(ssh.Options)
if err := c.setProxyComma
return err
}
}
+ args, err := expandArgs(c.Args, c.hostFromTarget)
+ if err != nil {
+ return err
+ }
return ssh.Copy(args, options)
}
Index: cmd/juju/ssh.go t(c.Target) EnablePTY( ) nd(&options) ; err != nil { t(c.Target) "ubuntu@ "+host, c.Args, &options)
=== modified file 'cmd/juju/ssh.go'
--- cmd/juju/ssh.go 2014-04-02 06:15:57 +0000
+++ cmd/juju/ssh.go 2014-05-09 05:17:45 +0000
@@ -124,21 +124,22 @@
}
}()
}
- host, err := c.hostFromTarge
- if err != nil {
- return err
- }
var options ssh.Options
if c.pty {
options.
}
- if proxy, err := c.proxySSH(); err != nil {
+ var err error
+ if c.proxy, err = c.proxySSH(); err != nil {
return err
- } else if proxy {
+ } else if c.proxy {
if err := c.setProxyComma
return err
}
}
+ host, err := c.hostFromTarge
+ if err != nil {
+ return err
+ }
cmd := ssh.Command(
cmd.Stdin = ctx.Stdin
cmd.Stdout = ctx.Stdout
Index: cmd/juju/ ssh_test. go ssh_test. go' ssh_test. go 2014-04-07 00:36:36 +0000 ssh_test. go 2014-05-09 05:17:45 +0000 er.next = func() bool { m[0], c)
=== modified file 'cmd/juju/
--- cmd/juju/
+++ cmd/juju/
@@ -182,7 +182,7 @@
attemptStart
called++
if called > 1 {
- s.setAddress(m[0], c)
+ s.setAddresses(
}
return true
}
@@ -191,19 +191,20 @@
c.Assert(called, gc.Equals, 2)
}
-func (s *SSHCommonSuite) setAddress(m *state.Machine, c *gc.C) { NewAddress( fmt.Sprintf( "dummyenv- %s.dns" , m.Id()), NetworkPublic) addr) NewAddress( fmt.Sprintf( "dummyenv- %s.dns" , m.Id()), NetworkPublic) NewAddress( fmt.Sprintf( "dummyenv- %s.internal" , NetworkCloudLoc al) addrPub, addrPriv)
- addr := instance.
instance.
- err := m.SetAddresses(
+func (s *SSHCommonSuite) setAddresses(m *state.Machine, c *gc.C) {
+ addrPub := instance.
instance.
+ addrPriv := instance.
m.Id()), instance.
+ err := m.SetAddresses(
c.Assert(err, gc.IsNil)
}
-func (s *SSHCommonSuite) makeMachines(n int, c *gc.C, setAddress bool) *state. Machine, n) AddMachine( "quantal" , state.JobHostUnits)
[]*state.Machine {
+func (s *SSHCommonSuite) makeMachines(n int, c *gc.C, setAddresses bool)
[]*state.Machine {
var machines = make([]
for i := 0; i < n; i++ {
m, err := s.State.
c.Assert(err, gc.IsNil)
- if setAddress {
- s.setAddress(m, c)
+ if setAddresses {
+ s.setAddresses(m, c)
}
// must set an instance id as the ssh command uses that as a signal the
// machine has been provisioned