Merge lp:~wallyworld/juju-core/fix-unitupgrader-datadir into lp:~go-bot/juju-core/trunk
- fix-unitupgrader-datadir
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ian Booth | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 2343 | ||||
Proposed branch: | lp:~wallyworld/juju-core/fix-unitupgrader-datadir | ||||
Merge into: | lp:~go-bot/juju-core/trunk | ||||
Diff against target: |
207 lines (+21/-22) 6 files modified
juju/testing/conn.go (+2/-2) provider/dummy/environs.go (+4/-1) state/api/upgrader/unitupgrader_test.go (+1/-4) state/apiserver/root.go (+1/-1) state/apiserver/upgrader/unitupgrader.go (+4/-2) state/apiserver/upgrader/unitupgrader_test.go (+9/-12) |
||||
To merge this branch: | bzr merge lp:~wallyworld/juju-core/fix-unitupgrader-datadir | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email:
|
Commit message
Unit upgrader data dir fix
The unit upgrader was using the default datadir instead
of the one configured in the agent config.
Description of the change
Unit upgrader data dir fix
The unit upgrader was using the default datadir instead
of the one configured in the agent config.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ian Booth (wallyworld) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andrew Wilkins (axwalk) wrote : | # |
On 2014/02/20 03:14:37, wallyworld wrote:
> Please take a look.
LGTM
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~wallyworld/juju-core/fix-unitupgrader-datadir into lp:juju-core failed. Below is the output from the failed tests.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
[jujuc whatever]
[remote]
[/path/to/remote]
[remote --help]
[unknown]
[remote --error borken]
[remote --unknown]
[remote unwanted]
-------
FAIL: unit_test.go:146: UnitSuite.
[LOG] 29.87242 DEBUG juju.environs.
[LOG] 29.96522 DEBUG juju.environs.tools reading v1.* tools
[LOG] 29.96528 INFO juju environs/testing: uploading FAKE tools 1.17.3-
[LOG] 29.96754 DEBUG juju.environs.tools no architecture specified when finding tools, looking for any
[LOG] 29.96757 DEBUG juju.environs.tools no series specified when finding tools, looking for any
[LOG] 29.96767 DEBUG juju.environs.
[LOG] 29.96768 DEBUG juju.environs.
[LOG] 29.96774 DEBUG juju.environs.
[LOG] 29.96776 DEBUG juju.environs.
[LOG] 29.96810 INFO juju.environs.tools Writing tools/streams/
[LOG] 29.96822 INFO juju.environs.tools Writing tools/streams/
[LOG] 29.96828 INFO juju.environs.
[LOG] 29.96831 DEBUG juju.environs.
[LOG] 29.96832 INFO juju.environs.tools reading tools with major.minor version 1.17
[LOG] 29.96833 INFO juju.environs.tools filtering tools by version: 1.17.3
[LOG] 29.96836 INFO juju.environs.tools filtering tools by series: precise
[LOG] 29.96839 DEBUG juju.environs.tools no architecture specified when finding tools, looking for any
[LOG] 29.96843 DEBUG juju.environs.
[LOG] 29.96845 DEBUG juju.environs.
[L...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~wallyworld/juju-core/fix-unitupgrader-datadir into lp:juju-core failed. Below is the output from the failed tests.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~wallyworld/juju-core/fix-unitupgrader-datadir into lp:juju-core failed. Below is the output from the failed tests.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~wallyworld/juju-core/fix-unitupgrader-datadir into lp:juju-core failed. Below is the output from the failed tests.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
Preview Diff
1 | === modified file 'juju/testing/conn.go' |
2 | --- juju/testing/conn.go 2014-02-18 01:29:47 +0000 |
3 | +++ juju/testing/conn.go 2014-02-20 04:59:53 +0000 |
4 | @@ -177,8 +177,7 @@ |
5 | err = os.Mkdir(osenv.JujuHome(), 0777) |
6 | c.Assert(err, gc.IsNil) |
7 | |
8 | - dataDir := filepath.Join(s.RootDir, "/var/lib/juju") |
9 | - err = os.MkdirAll(dataDir, 0777) |
10 | + err = os.MkdirAll(s.DataDir(), 0777) |
11 | c.Assert(err, gc.IsNil) |
12 | s.PatchEnvironment(osenv.JujuEnvEnvKey, "") |
13 | |
14 | @@ -201,6 +200,7 @@ |
15 | c.Assert(err, gc.IsNil) |
16 | // sanity check we've got the correct environment. |
17 | c.Assert(environ.Name(), gc.Equals, "dummyenv") |
18 | + s.PatchValue(&dummy.DataDir, s.DataDir()) |
19 | |
20 | envtesting.MustUploadFakeTools(environ.Storage()) |
21 | c.Assert(bootstrap.Bootstrap(ctx, environ, constraints.Value{}), gc.IsNil) |
22 | |
23 | === modified file 'provider/dummy/environs.go' |
24 | --- provider/dummy/environs.go 2014-02-13 02:46:58 +0000 |
25 | +++ provider/dummy/environs.go 2014-02-20 04:59:53 +0000 |
26 | @@ -490,6 +490,9 @@ |
27 | |
28 | var errBroken = errors.New("broken environment") |
29 | |
30 | +// Override for testing - the data directory with which the state api server is initialised. |
31 | +var DataDir = "" |
32 | + |
33 | func (e *environ) ecfg() *environConfig { |
34 | e.ecfgMutex.Lock() |
35 | ecfg := e.ecfgUnlocked |
36 | @@ -585,7 +588,7 @@ |
37 | if err != nil { |
38 | panic(err) |
39 | } |
40 | - estate.apiServer, err = apiserver.NewServer(st, "localhost:0", []byte(testing.ServerCert), []byte(testing.ServerKey), "") |
41 | + estate.apiServer, err = apiserver.NewServer(st, "localhost:0", []byte(testing.ServerCert), []byte(testing.ServerKey), DataDir) |
42 | if err != nil { |
43 | panic(err) |
44 | } |
45 | |
46 | === modified file 'state/api/upgrader/unitupgrader_test.go' |
47 | --- state/api/upgrader/unitupgrader_test.go 2014-02-19 01:26:15 +0000 |
48 | +++ state/api/upgrader/unitupgrader_test.go 2014-02-20 04:59:53 +0000 |
49 | @@ -11,7 +11,6 @@ |
50 | |
51 | gc "launchpad.net/gocheck" |
52 | |
53 | - "launchpad.net/juju-core/environs" |
54 | "launchpad.net/juju-core/errors" |
55 | jujutesting "launchpad.net/juju-core/juju/testing" |
56 | "launchpad.net/juju-core/state" |
57 | @@ -54,9 +53,7 @@ |
58 | s.stateAPI = s.OpenAPIAs(c, s.rawUnit.Tag(), password) |
59 | |
60 | // Set up fake downloaded tools for the assigned machine. |
61 | - libDir := c.MkDir() |
62 | - s.PatchValue(&environs.DataDir, libDir) |
63 | - fakeToolsPath := filepath.Join(libDir, "tools", version.Current.String()) |
64 | + fakeToolsPath := filepath.Join(s.DataDir(), "tools", version.Current.String()) |
65 | err = os.MkdirAll(fakeToolsPath, 0700) |
66 | c.Assert(err, gc.IsNil) |
67 | s.fakeTools = &tools.Tools{ |
68 | |
69 | === modified file 'state/apiserver/root.go' |
70 | --- state/apiserver/root.go 2014-02-18 00:15:30 +0000 |
71 | +++ state/apiserver/root.go 2014-02-20 04:59:53 +0000 |
72 | @@ -211,7 +211,7 @@ |
73 | case names.MachineTagKind: |
74 | return upgrader.NewUpgraderAPI(r.srv.state, r.resources, r) |
75 | case names.UnitTagKind: |
76 | - return upgrader.NewUnitUpgraderAPI(r.srv.state, r.resources, r) |
77 | + return upgrader.NewUnitUpgraderAPI(r.srv.state, r.resources, r, r.srv.dataDir) |
78 | } |
79 | // Not a machine or unit. |
80 | return nil, common.ErrPerm |
81 | |
82 | === modified file 'state/apiserver/upgrader/unitupgrader.go' |
83 | --- state/apiserver/upgrader/unitupgrader.go 2014-02-19 01:26:15 +0000 |
84 | +++ state/apiserver/upgrader/unitupgrader.go 2014-02-20 04:59:53 +0000 |
85 | @@ -5,7 +5,6 @@ |
86 | |
87 | import ( |
88 | agenttools "launchpad.net/juju-core/agent/tools" |
89 | - "launchpad.net/juju-core/environs" |
90 | "launchpad.net/juju-core/names" |
91 | "launchpad.net/juju-core/state" |
92 | "launchpad.net/juju-core/state/api/params" |
93 | @@ -22,6 +21,7 @@ |
94 | st *state.State |
95 | resources *common.Resources |
96 | authorizer common.Authorizer |
97 | + dataDir string |
98 | } |
99 | |
100 | // NewUnitUpgraderAPI creates a new server-side UnitUpgraderAPI facade. |
101 | @@ -29,6 +29,7 @@ |
102 | st *state.State, |
103 | resources *common.Resources, |
104 | authorizer common.Authorizer, |
105 | + dataDir string, |
106 | ) (*UnitUpgraderAPI, error) { |
107 | if !authorizer.AuthUnitAgent() { |
108 | return nil, common.ErrPerm |
109 | @@ -42,6 +43,7 @@ |
110 | st: st, |
111 | resources: resources, |
112 | authorizer: authorizer, |
113 | + dataDir: dataDir, |
114 | }, nil |
115 | } |
116 | |
117 | @@ -144,7 +146,7 @@ |
118 | // download the tools even though they already have been fetched by the machine agent. Newer upgrader |
119 | // workers do not have this problem. So to be compatible across all versions, we return the full tools |
120 | // metadata as recorded in the downloaded tools directory. |
121 | - downloadedTools, err := agenttools.ReadTools(environs.DataDir, machineTools.Version) |
122 | + downloadedTools, err := agenttools.ReadTools(u.dataDir, machineTools.Version) |
123 | if err != nil { |
124 | return nil, err |
125 | } |
126 | |
127 | === modified file 'state/apiserver/upgrader/unitupgrader_test.go' |
128 | --- state/apiserver/upgrader/unitupgrader_test.go 2014-02-19 02:07:19 +0000 |
129 | +++ state/apiserver/upgrader/unitupgrader_test.go 2014-02-20 04:59:53 +0000 |
130 | @@ -11,7 +11,6 @@ |
131 | |
132 | gc "launchpad.net/gocheck" |
133 | |
134 | - "launchpad.net/juju-core/environs" |
135 | "launchpad.net/juju-core/errors" |
136 | jujutesting "launchpad.net/juju-core/juju/testing" |
137 | "launchpad.net/juju-core/state" |
138 | @@ -63,13 +62,8 @@ |
139 | LoggedIn: true, |
140 | UnitAgent: true, |
141 | } |
142 | - s.upgrader, err = upgrader.NewUnitUpgraderAPI(s.State, s.resources, s.authorizer) |
143 | - c.Assert(err, gc.IsNil) |
144 | - |
145 | // Set up fake downloaded tools for the assigned machine. |
146 | - libDir := c.MkDir() |
147 | - s.PatchValue(&environs.DataDir, libDir) |
148 | - fakeToolsPath := filepath.Join(libDir, "tools", version.Current.String()) |
149 | + fakeToolsPath := filepath.Join(s.DataDir(), "tools", version.Current.String()) |
150 | err = os.MkdirAll(fakeToolsPath, 0700) |
151 | c.Assert(err, gc.IsNil) |
152 | s.fakeTools = &tools.Tools{ |
153 | @@ -82,6 +76,9 @@ |
154 | c.Assert(err, gc.IsNil) |
155 | err = ioutil.WriteFile(filepath.Join(fakeToolsPath, "downloaded-tools.txt"), []byte(toolsMetadataData), 0644) |
156 | c.Assert(err, gc.IsNil) |
157 | + |
158 | + s.upgrader, err = upgrader.NewUnitUpgraderAPI(s.State, s.resources, s.authorizer, s.DataDir()) |
159 | + c.Assert(err, gc.IsNil) |
160 | } |
161 | |
162 | func (s *unitUpgraderSuite) TearDownTest(c *gc.C) { |
163 | @@ -125,7 +122,7 @@ |
164 | anAuthorizer := s.authorizer |
165 | anAuthorizer.MachineAgent = true |
166 | anAuthorizer.UnitAgent = false |
167 | - anUpgrader, err := upgrader.NewUnitUpgraderAPI(s.State, s.resources, anAuthorizer) |
168 | + anUpgrader, err := upgrader.NewUnitUpgraderAPI(s.State, s.resources, anAuthorizer, "") |
169 | c.Check(err, gc.NotNil) |
170 | c.Check(anUpgrader, gc.IsNil) |
171 | c.Assert(err, gc.ErrorMatches, "permission denied") |
172 | @@ -135,7 +132,7 @@ |
173 | // We are a unit agent, but not the one we are trying to track |
174 | anAuthorizer := s.authorizer |
175 | anAuthorizer.Tag = "unit-wordpress-12354" |
176 | - anUpgrader, err := upgrader.NewUnitUpgraderAPI(s.State, s.resources, anAuthorizer) |
177 | + anUpgrader, err := upgrader.NewUnitUpgraderAPI(s.State, s.resources, anAuthorizer, "") |
178 | c.Check(err, gc.IsNil) |
179 | args := params.Entities{ |
180 | Entities: []params.Entity{{Tag: s.rawUnit.Tag()}}, |
181 | @@ -158,7 +155,7 @@ |
182 | func (s *unitUpgraderSuite) TestToolsRefusesWrongAgent(c *gc.C) { |
183 | anAuthorizer := s.authorizer |
184 | anAuthorizer.Tag = "unit-wordpress-12354" |
185 | - anUpgrader, err := upgrader.NewUnitUpgraderAPI(s.State, s.resources, anAuthorizer) |
186 | + anUpgrader, err := upgrader.NewUnitUpgraderAPI(s.State, s.resources, anAuthorizer, "") |
187 | c.Check(err, gc.IsNil) |
188 | args := params.Entities{ |
189 | Entities: []params.Entity{{Tag: s.rawUnit.Tag()}}, |
190 | @@ -202,7 +199,7 @@ |
191 | func (s *unitUpgraderSuite) TestSetToolsRefusesWrongAgent(c *gc.C) { |
192 | anAuthorizer := s.authorizer |
193 | anAuthorizer.Tag = "unit-wordpress-12354" |
194 | - anUpgrader, err := upgrader.NewUnitUpgraderAPI(s.State, s.resources, anAuthorizer) |
195 | + anUpgrader, err := upgrader.NewUnitUpgraderAPI(s.State, s.resources, anAuthorizer, "") |
196 | c.Check(err, gc.IsNil) |
197 | args := params.EntitiesVersion{ |
198 | AgentTools: []params.EntityVersion{{ |
199 | @@ -259,7 +256,7 @@ |
200 | func (s *unitUpgraderSuite) TestDesiredVersionRefusesWrongAgent(c *gc.C) { |
201 | anAuthorizer := s.authorizer |
202 | anAuthorizer.Tag = "unit-wordpress-12354" |
203 | - anUpgrader, err := upgrader.NewUnitUpgraderAPI(s.State, s.resources, anAuthorizer) |
204 | + anUpgrader, err := upgrader.NewUnitUpgraderAPI(s.State, s.resources, anAuthorizer, "") |
205 | c.Check(err, gc.IsNil) |
206 | args := params.Entities{ |
207 | Entities: []params.Entity{{Tag: s.rawUnit.Tag()}}, |
Reviewers: mp+207345_ code.launchpad. net,
Message:
Please take a look.
Description:
Unit upgrader data dir fix
The unit upgrader was using the default datadir instead
of the one configured in the agent config.
https:/ /code.launchpad .net/~wallyworl d/juju- core/fix- unitupgrader- datadir/ +merge/ 207345
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/66320043/
Affected files (+17, -15 lines): /root.go /upgrader/ unitupgrader. go /upgrader/ unitupgrader_ test.go
A [revision details]
M state/apiserver
M state/apiserver
M state/apiserver
Index: [revision details] 20140219135723- ldv43e0o1e1qgii f
=== 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: state/apiserver /root.go apiserver/ root.go' /root.go 2014-02-18 00:15:30 +0000 /root.go 2014-02-20 03:12:23 +0000 gKind: NewUpgraderAPI( r.srv.state, r.resources, r) NewUnitUpgrader API(r.srv. state, r.resources, r) NewUnitUpgrader API(r.srv. state, r.resources, r,
=== modified file 'state/
--- state/apiserver
+++ state/apiserver
@@ -211,7 +211,7 @@
case names.MachineTa
return upgrader.
case names.UnitTagKind:
- return upgrader.
+ return upgrader.
r.srv.dataDir)
}
// Not a machine or unit.
return nil, common.ErrPerm
Index: state/apiserver /upgrader/ unitupgrader. go apiserver/ upgrader/ unitupgrader. go' /upgrader/ unitupgrader. go 2014-02-19 01:26:15 +0000 /upgrader/ unitupgrader. go 2014-02-20 03:12:23 +0000
=== modified file 'state/
--- state/apiserver
+++ state/apiserver
@@ -5,7 +5,6 @@
import ( net/juju- core/agent/ tools" net/juju- core/environs" net/juju- core/names" net/juju- core/state" net/juju- core/state/ api/params"
agenttools "launchpad.
- "launchpad.
"launchpad.
"launchpad.
"launchpad.
@@ -22,6 +21,7 @@
st *state.State
resources *common.Resources
authorizer common.Authorizer
+ dataDir string
}
// NewUnitUpgraderAPI creates a new server-side UnitUpgraderAPI facade. AuthUnitAgent( ) {
@@ -29,6 +29,7 @@
st *state.State,
resources *common.Resources,
authorizer common.Authorizer,
+ dataDir string,
) (*UnitUpgraderAPI, error) {
if !authorizer.
return nil, common.ErrPerm
@@ -42,6 +43,7 @@
st: st,
resources: resources,
authorizer: authorizer,
+ dataDir: dataDir,
}, nil
}
@@ -144,7 +146,7 @@ ReadTools( environs. DataDir, Version) ReadTools( u.dataDir, Version)
// download the tools even though they already have been fetched by the
machine agent. Newer upgrader
// workers do not have this problem. So to be compatible across all
versions, we return the full tools
// metadata as recorded in the downloaded tools directory.
- downloadedTools, err := agenttools.
machineTools.
+ downloadedTools, err := agenttools.
machineTools.
if err != nil {
return nil, err
}
Index: state/apiserver /upgrader/ unitupgrader_ test.go apiserver/ upgrader/ unitupgrader_ test.go' /upgrader/ unitupgrader_ test.go 2014-02-19 02:07:19 +0000...
=== modified file 'state/
--- state/apiserver