Merge lp:~rvb/juju-core/fix-maas-pvd-conf into lp:~juju/juju-core/trunk

Proposed by Raphaël Badin
Status: Rejected
Rejected by: Dimiter Naydenov
Proposed branch: lp:~rvb/juju-core/fix-maas-pvd-conf
Merge into: lp:~juju/juju-core/trunk
Diff against target: 45 lines (+26/-1)
2 files modified
environs/maas/environprovider.go (+5/-1)
environs/maas/environprovider_test.go (+21/-0)
To merge this branch: bzr merge lp:~rvb/juju-core/fix-maas-pvd-conf
Reviewer Review Type Date Requested Status
Dimiter Naydenov (community) Approve
Review via email: mp+158938@code.launchpad.net

Commit message

Fix maasEnvironProvider.Open() so that it returns a nil object when it fails.

Description of the change

[Note: I did not use rietveld because I ran into errors like: http://paste.ubuntu.com/5710470/ when trying to use lbox propose]

This branch fixes a problem we saw happening in the MAAS lab while testing the MAAS provider. The symptom was that, after having installed the bootstrap node ok, Juju was unable to deploy any service. The error found in the bootstrap node's logs: http://paste.ubuntu.com/5709878/.

The problem is that, from this code in cmd/jujud/upgrade.go: http://paste.ubuntu.com/5710182/, environs/maas/environ.go:SetConfig ends up being called on a nil object. After investigating the problem, I found that environs/maas/environprovider.go:Open(), when the config is invalid, returns a interface that has a nil value but a non-nil type (http://golang.org/doc/faq#nil_error) and thus, in cmd/jujud/upgrade.go (see snippet above), 'environ.SetConfig(cfg)' gets called on a nil 'environ'.

To post a comment you must log in.
Revision history for this message
Dimiter Naydenov (dimitern) wrote :

LGTM

review: Approve
Revision history for this message
William Reade (fwereade) wrote :

[0] env, err := NewEnviron(cfg)

This deserves a comment. But otherwise LGTM trivial.

Revision history for this message
Dimiter Naydenov (dimitern) wrote :

Due to the problems rvba had with lbox, he asked to land this for him.
It was proposed as https://codereview.appspot.com/8772043
So I'm setting this as Rejected and the one above will be merged.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'environs/maas/environprovider.go'
--- environs/maas/environprovider.go 2013-04-12 09:45:01 +0000
+++ environs/maas/environprovider.go 2013-04-15 14:31:30 +0000
@@ -19,7 +19,11 @@
1919
20func (maasEnvironProvider) Open(cfg *config.Config) (environs.Environ, error) {20func (maasEnvironProvider) Open(cfg *config.Config) (environs.Environ, error) {
21 log.Debugf("environs/maas: opening environment %q.", cfg.Name())21 log.Debugf("environs/maas: opening environment %q.", cfg.Name())
22 return NewEnviron(cfg)22 env, err := NewEnviron(cfg)
23 if err != nil {
24 return nil, err
25 }
26 return env, nil
23}27}
2428
25// Boilerplate config YAML. Don't mess with the indentation or add newlines!29// Boilerplate config YAML. Don't mess with the indentation or add newlines!
2630
=== modified file 'environs/maas/environprovider_test.go'
--- environs/maas/environprovider_test.go 2013-04-11 10:33:21 +0000
+++ environs/maas/environprovider_test.go 2013-04-15 14:31:30 +0000
@@ -92,3 +92,24 @@
92 c.Assert(err, IsNil)92 c.Assert(err, IsNil)
93 c.Check(privateAddress, Equals, hostname)93 c.Check(privateAddress, Equals, hostname)
94}94}
95
96func (suite *EnvironProviderSuite) TestOpenReturnsNilInterfaceUponFailure(c *C) {
97 testJujuHome := c.MkDir()
98 defer config.SetJujuHome(config.SetJujuHome(testJujuHome))
99 const oauth = "wrongly-formatted-oauth-string"
100 attrs := map[string]interface{}{
101 "maas-oauth": oauth,
102 "maas-server": "http://maas.example.com/maas/",
103 "name": "wheee",
104 "type": "maas",
105 "authorized-keys": "I-am-not-a-real-key",
106 }
107 config, err := config.New(attrs)
108 c.Assert(err, IsNil)
109 env, err := suite.environ.Provider().Open(config)
110 // When Open() fails (i.e. returns a non-nil error), it returns an
111 // environs.Environ interface object with a nil value and a nil
112 // type.
113 c.Check(env, Equals, nil)
114 c.Check(err, ErrorMatches, ".*malformed maas-oauth.*")
115}

Subscribers

People subscribed via source and target branches