Merge lp:~thumper/juju-core/fast-lxc into lp:~go-bot/juju-core/trunk
- fast-lxc
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Tim Penhey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2400 |
Proposed branch: | lp:~thumper/juju-core/fast-lxc |
Merge into: | lp:~go-bot/juju-core/trunk |
Prerequisite: | lp:~thumper/juju-core/maybe-add-cloud-archive-func |
Diff against target: |
373 lines (+205/-20) 7 files modified
provider/local/environ.go (+5/-2) provider/local/export_test.go (+8/-5) provider/local/lxc.go (+38/-0) provider/local/lxc_test.go (+59/-0) version/export_test.go (+4/-1) version/version.go (+25/-4) version/version_test.go (+66/-8) |
To merge this branch: | bzr merge lp:~thumper/juju-core/fast-lxc |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+209801@code.launchpad.net |
Commit message
Local provider flag for fast-lxc
The flag is determined by the distro release from the
/etc/lsb-release file.
There is an override environment variable that can be
set to keep existing behaviour. Although no actual
behaviour is introduced in this branch.
Description of the change
Local provider flag for fast-lxc
The flag is determined by the distro release from the
/etc/lsb-release file.
There is an override environment variable that can be
set to keep existing behaviour. Although no actual
behaviour is introduced in this branch.
Tim Penhey (thumper) wrote : | # |
Sidnei da Silva (sidnei) wrote : | # |
https:/
File provider/
https:/
provider/
Is it possible at all to do a feature check instead of a version check
here (even if it means parsing lxc-create --help)? It should technically
be possible to use fast lxc if you have a backport of lxc 1.0 for
anything between precise and trusty.
Ian Booth (wallyworld) wrote : | # |
https:/
File provider/
https:/
provider/
There's a method in version.go which reads the series from lsb-release -
readSeries(). I think it would be best to enhance this function to
return version also or otherwise put this functionality there and export
it, so that the version related stuff is kept together.
Tim Penhey (thumper) wrote : | # |
On 2014/03/06 23:20:15, sidnei.da.silva wrote:
> https:/
> File provider/
https:/
> provider/
> Is it possible at all to do a feature check instead of a version check
here
> (even if it means parsing lxc-create --help)? It should technically be
possible
> to use fast lxc if you have a backport of lxc 1.0 for anything between
precise
> and trusty.
While technically possible, it seemed reasonable to me and others to
keep it simple and say this is a trusty feature.
Tim Penhey (thumper) wrote : | # |
Please take a look.
https:/
File provider/
https:/
provider/
On 2014/03/06 23:24:19, wallyworld wrote:
> There's a method in version.go which reads the series from lsb-release
-
> readSeries(). I think it would be best to enhance this function to
return
> version also or otherwise put this functionality there and export it,
so that
> the version related stuff is kept together.
Moved.
William Reade (fwereade) wrote : | # |
really messy diff, please repropose
Tim Penhey (thumper) wrote : | # |
Please take a look.
Ian Booth (wallyworld) wrote : | # |
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~thumper/juju-core/fast-lxc 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.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? 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.
? launchp...
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~thumper/juju-core/fast-lxc 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.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? 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.
? launchp...
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~thumper/juju-core/fast-lxc 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.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? 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.
? launch...
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~thumper/juju-core/fast-lxc 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.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? 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.
? launchpa...
Preview Diff
1 | === modified file 'provider/local/environ.go' |
2 | --- provider/local/environ.go 2014-03-07 15:56:55 +0000 |
3 | +++ provider/local/environ.go 2014-03-11 01:19:21 +0000 |
4 | @@ -1,4 +1,4 @@ |
5 | -// Copyright 2013 Canonical Ltd. |
6 | +// Copyright 2013, 2014 Canonical Ltd. |
7 | // Licensed under the AGPLv3, see LICENCE file for details. |
8 | |
9 | package local |
10 | @@ -60,6 +60,7 @@ |
11 | localStorage storage.Storage |
12 | storageListener net.Listener |
13 | containerManager container.Manager |
14 | + fastLXC bool |
15 | } |
16 | |
17 | // GetToolsSources returns a list of sources which are used to search for simplestreams tools metadata. |
18 | @@ -210,9 +211,11 @@ |
19 | defer env.localMutex.Unlock() |
20 | env.config = ecfg |
21 | env.name = ecfg.Name() |
22 | + containerType := ecfg.container() |
23 | + env.fastLXC = useFastLXC(containerType) |
24 | |
25 | env.containerManager, err = factory.NewContainerManager( |
26 | - ecfg.container(), |
27 | + containerType, |
28 | container.ManagerConfig{ |
29 | container.ConfigName: env.config.namespace(), |
30 | container.ConfigLogDir: env.config.logDir(), |
31 | |
32 | === modified file 'provider/local/export_test.go' |
33 | --- provider/local/export_test.go 2014-02-14 04:26:21 +0000 |
34 | +++ provider/local/export_test.go 2014-03-11 01:19:21 +0000 |
35 | @@ -10,11 +10,14 @@ |
36 | ) |
37 | |
38 | var ( |
39 | - Provider = providerInstance |
40 | - FinishBootstrap = &finishBootstrap |
41 | - CheckLocalPort = &checkLocalPort |
42 | - DetectAptProxies = &detectAptProxies |
43 | - UserCurrent = &userCurrent |
44 | + CheckLocalPort = &checkLocalPort |
45 | + DetectAptProxies = &detectAptProxies |
46 | + EnvKeyTestingForceSlow = envKeyTestingForceSlow |
47 | + FinishBootstrap = &finishBootstrap |
48 | + Provider = providerInstance |
49 | + ReleaseVersion = &releaseVersion |
50 | + UseFastLXC = useFastLXC |
51 | + UserCurrent = &userCurrent |
52 | ) |
53 | |
54 | // SetRootCheckFunction allows tests to override the check for a root user. |
55 | |
56 | === added file 'provider/local/lxc.go' |
57 | --- provider/local/lxc.go 1970-01-01 00:00:00 +0000 |
58 | +++ provider/local/lxc.go 2014-03-11 01:19:21 +0000 |
59 | @@ -0,0 +1,38 @@ |
60 | +// Copyright 2014 Canonical Ltd. |
61 | +// Licensed under the AGPLv3, see LICENCE file for details. |
62 | + |
63 | +package local |
64 | + |
65 | +import ( |
66 | + "os" |
67 | + "strconv" |
68 | + |
69 | + "launchpad.net/juju-core/instance" |
70 | + "launchpad.net/juju-core/version" |
71 | +) |
72 | + |
73 | +// envKeyTestingForceSlow is an environment variable name to force the slow |
74 | +// lxc path. Setting to any non-empty value will force the slow path. |
75 | +const envKeyTestingForceSlow = "JUJU_TESTING_LXC_FORCE_SLOW" |
76 | + |
77 | +// releaseVersion is a function that returns a string representing the |
78 | +// DISTRIB_RELEASE from the /etc/lsb-release file. |
79 | +var releaseVersion = version.ReleaseVersion |
80 | + |
81 | +func useFastLXC(containerType instance.ContainerType) bool { |
82 | + if containerType != instance.LXC { |
83 | + return false |
84 | + } |
85 | + if os.Getenv(envKeyTestingForceSlow) != "" { |
86 | + return false |
87 | + } |
88 | + release := releaseVersion() |
89 | + if release == "" { |
90 | + return false |
91 | + } |
92 | + value, err := strconv.ParseFloat(release, 64) |
93 | + if err != nil { |
94 | + return false |
95 | + } |
96 | + return value >= 14.04 |
97 | +} |
98 | |
99 | === added file 'provider/local/lxc_test.go' |
100 | --- provider/local/lxc_test.go 1970-01-01 00:00:00 +0000 |
101 | +++ provider/local/lxc_test.go 2014-03-11 01:19:21 +0000 |
102 | @@ -0,0 +1,59 @@ |
103 | +// Copyright 2014 Canonical Ltd. |
104 | +// Licensed under the AGPLv3, see LICENCE file for details. |
105 | + |
106 | +package local_test |
107 | + |
108 | +import ( |
109 | + gc "launchpad.net/gocheck" |
110 | + |
111 | + "launchpad.net/juju-core/instance" |
112 | + "launchpad.net/juju-core/provider/local" |
113 | + jc "launchpad.net/juju-core/testing/checkers" |
114 | + "launchpad.net/juju-core/testing/testbase" |
115 | +) |
116 | + |
117 | +type lxcTest struct { |
118 | + testbase.LoggingSuite |
119 | +} |
120 | + |
121 | +var _ = gc.Suite(&lxcTest{}) |
122 | + |
123 | +func (*lxcTest) TestUseFastLXCForContainer(c *gc.C) { |
124 | + c.Assert(local.UseFastLXC(instance.ContainerType("")), jc.IsFalse) |
125 | + c.Assert(local.UseFastLXC(instance.KVM), jc.IsFalse) |
126 | +} |
127 | + |
128 | +func (t *lxcTest) TestUseFastLXC(c *gc.C) { |
129 | + for i, test := range []struct { |
130 | + message string |
131 | + releaseVersion string |
132 | + expected bool |
133 | + overrideSlow string |
134 | + }{{ |
135 | + message: "missing release file", |
136 | + }, { |
137 | + message: "precise release", |
138 | + releaseVersion: "12.04", |
139 | + }, { |
140 | + message: "trusty release", |
141 | + releaseVersion: "14.04", |
142 | + expected: true, |
143 | + }, { |
144 | + message: "unstable unicorn", |
145 | + releaseVersion: "14.10", |
146 | + expected: true, |
147 | + }, { |
148 | + message: "jaunty", |
149 | + releaseVersion: "9.10", |
150 | + }, { |
151 | + message: "env override", |
152 | + releaseVersion: "14.04", |
153 | + overrideSlow: "value", |
154 | + }} { |
155 | + c.Logf("%v: %v", i, test.message) |
156 | + t.PatchValue(local.ReleaseVersion, func() string { return test.releaseVersion }) |
157 | + t.PatchEnvironment(local.EnvKeyTestingForceSlow, test.overrideSlow) |
158 | + value := local.UseFastLXC(instance.LXC) |
159 | + c.Assert(value, gc.Equals, test.expected) |
160 | + } |
161 | +} |
162 | |
163 | === modified file 'version/export_test.go' |
164 | --- version/export_test.go 2013-09-04 13:24:57 +0000 |
165 | +++ version/export_test.go 2014-03-11 01:19:21 +0000 |
166 | @@ -3,4 +3,7 @@ |
167 | |
168 | package version |
169 | |
170 | -var ReadSeries = readSeries |
171 | +var ( |
172 | + ReadSeries = readSeries |
173 | + LSBReleaseFileVar = &lsbReleaseFile |
174 | +) |
175 | |
176 | === modified file 'version/version.go' |
177 | --- version/version.go 2014-03-06 16:08:30 +0000 |
178 | +++ version/version.go 2014-03-11 01:19:21 +0000 |
179 | @@ -24,12 +24,16 @@ |
180 | // number of the release package. |
181 | const version = "1.17.5" |
182 | |
183 | +// lsbReleaseFile is the name of the file that is read in order to determine |
184 | +// the release version of ubuntu. |
185 | +var lsbReleaseFile = "/etc/lsb-release" |
186 | + |
187 | // Current gives the current version of the system. If the file |
188 | // "FORCE-VERSION" is present in the same directory as the running |
189 | // binary, it will override this. |
190 | var Current = Binary{ |
191 | Number: MustParse(version), |
192 | - Series: readSeries("/etc/lsb-release"), |
193 | + Series: readSeries(lsbReleaseFile), |
194 | Arch: ubuntuArch(runtime.GOARCH), |
195 | } |
196 | |
197 | @@ -311,14 +315,31 @@ |
198 | return "unknown" |
199 | } |
200 | for _, line := range strings.Split(string(data), "\n") { |
201 | - const p = "DISTRIB_CODENAME=" |
202 | - if strings.HasPrefix(line, p) { |
203 | - return strings.Trim(line[len(p):], "\t '\"") |
204 | + const prefix = "DISTRIB_CODENAME=" |
205 | + if strings.HasPrefix(line, prefix) { |
206 | + return strings.Trim(line[len(prefix):], "\t '\"") |
207 | } |
208 | } |
209 | return "unknown" |
210 | } |
211 | |
212 | +// ReleaseVersion looks for the value of DISTRIB_RELEASE in the content of |
213 | +// the lsbReleaseFile. If the value is not found, the file is not found, or |
214 | +// an error occurs reading the file, an empty string is returned. |
215 | +func ReleaseVersion() string { |
216 | + content, err := ioutil.ReadFile(lsbReleaseFile) |
217 | + if err != nil { |
218 | + return "" |
219 | + } |
220 | + const prefix = "DISTRIB_RELEASE=" |
221 | + for _, line := range strings.Split(string(content), "\n") { |
222 | + if strings.HasPrefix(line, prefix) { |
223 | + return strings.Trim(line[len(prefix):], "\t '\"") |
224 | + } |
225 | + } |
226 | + return "" |
227 | +} |
228 | + |
229 | func ubuntuArch(arch string) string { |
230 | if arch == "386" { |
231 | arch = "i386" |
232 | |
233 | === modified file 'version/version_test.go' |
234 | --- version/version_test.go 2014-03-06 16:08:30 +0000 |
235 | +++ version/version_test.go 2014-03-11 01:19:21 +0000 |
236 | @@ -5,6 +5,8 @@ |
237 | |
238 | import ( |
239 | "encoding/json" |
240 | + "io/ioutil" |
241 | + "path/filepath" |
242 | "strings" |
243 | "testing" |
244 | |
245 | @@ -12,12 +14,15 @@ |
246 | gc "launchpad.net/gocheck" |
247 | "launchpad.net/goyaml" |
248 | |
249 | + "launchpad.net/juju-core/testing/testbase" |
250 | "launchpad.net/juju-core/version" |
251 | ) |
252 | |
253 | -type suite struct{} |
254 | +type suite struct { |
255 | + testbase.LoggingSuite |
256 | +} |
257 | |
258 | -var _ = gc.Suite(suite{}) |
259 | +var _ = gc.Suite(&suite{}) |
260 | |
261 | func Test(t *testing.T) { |
262 | gc.TestingT(t) |
263 | @@ -44,7 +49,7 @@ |
264 | {"2.0.1.10", "2.0.0.0", 1}, |
265 | } |
266 | |
267 | -func (suite) TestCompare(c *gc.C) { |
268 | +func (*suite) TestCompare(c *gc.C) { |
269 | for i, test := range cmpTests { |
270 | c.Logf("test %d", i) |
271 | v1, err := version.Parse(test.v1) |
272 | @@ -106,7 +111,7 @@ |
273 | err: "invalid version.*", |
274 | }} |
275 | |
276 | -func (suite) TestParse(c *gc.C) { |
277 | +func (*suite) TestParse(c *gc.C) { |
278 | for i, test := range parseTests { |
279 | c.Logf("test %d", i) |
280 | got, err := version.Parse(test.v) |
281 | @@ -152,7 +157,7 @@ |
282 | err: "invalid binary version.*", |
283 | }} |
284 | |
285 | -func (suite) TestParseBinary(c *gc.C) { |
286 | +func (*suite) TestParseBinary(c *gc.C) { |
287 | for i, test := range parseBinaryTests { |
288 | c.Logf("test 1: %d", i) |
289 | got, err := version.ParseBinary(test.v) |
290 | @@ -201,7 +206,7 @@ |
291 | goyaml.Unmarshal, |
292 | }} |
293 | |
294 | -func (suite) TestBinaryMarshalUnmarshal(c *gc.C) { |
295 | +func (*suite) TestBinaryMarshalUnmarshal(c *gc.C) { |
296 | for _, m := range marshallers { |
297 | c.Logf("encoding %v", m.name) |
298 | type doc struct { |
299 | @@ -220,7 +225,7 @@ |
300 | } |
301 | } |
302 | |
303 | -func (suite) TestNumberMarshalUnmarshal(c *gc.C) { |
304 | +func (*suite) TestNumberMarshalUnmarshal(c *gc.C) { |
305 | for _, m := range marshallers { |
306 | c.Logf("encoding %v", m.name) |
307 | type doc struct { |
308 | @@ -260,7 +265,7 @@ |
309 | err: `invalid major version number blah: strconv.ParseInt: parsing "blah": invalid syntax`, |
310 | }} |
311 | |
312 | -func (suite) TestParseMajorMinor(c *gc.C) { |
313 | +func (*suite) TestParseMajorMinor(c *gc.C) { |
314 | for i, test := range parseMajorMinorTests { |
315 | c.Logf("test %d", i) |
316 | major, minor, err := version.ParseMajorMinor(test.v) |
317 | @@ -273,3 +278,56 @@ |
318 | } |
319 | } |
320 | } |
321 | + |
322 | +func (s *suite) TestUseFastLXC(c *gc.C) { |
323 | + for i, test := range []struct { |
324 | + message string |
325 | + releaseContent string |
326 | + expected string |
327 | + }{{ |
328 | + message: "missing release file", |
329 | + }, { |
330 | + message: "missing prefix in file", |
331 | + releaseContent: "some junk\nand more junk", |
332 | + }, { |
333 | + message: "precise release", |
334 | + releaseContent: ` |
335 | +DISTRIB_ID=Ubuntu |
336 | +DISTRIB_RELEASE=12.04 |
337 | +DISTRIB_CODENAME=precise |
338 | +DISTRIB_DESCRIPTION="Ubuntu 12.04.3 LTS" |
339 | +`, |
340 | + expected: "12.04", |
341 | + }, { |
342 | + message: "trusty release", |
343 | + releaseContent: ` |
344 | +DISTRIB_ID=Ubuntu |
345 | +DISTRIB_RELEASE=14.04 |
346 | +DISTRIB_CODENAME=trusty |
347 | +DISTRIB_DESCRIPTION="Ubuntu Trusty Tahr (development branch)" |
348 | +`, |
349 | + expected: "14.04", |
350 | + }, { |
351 | + message: "minimal trusty release", |
352 | + releaseContent: `DISTRIB_RELEASE=14.04`, |
353 | + expected: "14.04", |
354 | + }, { |
355 | + message: "minimal unstable unicorn", |
356 | + releaseContent: `DISTRIB_RELEASE=14.10`, |
357 | + expected: "14.10", |
358 | + }, { |
359 | + message: "minimal jaunty", |
360 | + releaseContent: `DISTRIB_RELEASE=9.10`, |
361 | + expected: "9.10", |
362 | + }} { |
363 | + c.Logf("%v: %v", i, test.message) |
364 | + filename := filepath.Join(c.MkDir(), "lsbRelease") |
365 | + s.PatchValue(version.LSBReleaseFileVar, filename) |
366 | + if test.releaseContent != "" { |
367 | + err := ioutil.WriteFile(filename, []byte(test.releaseContent+"\n"), 0644) |
368 | + c.Assert(err, gc.IsNil) |
369 | + } |
370 | + value := version.ReleaseVersion() |
371 | + c.Assert(value, gc.Equals, test.expected) |
372 | + } |
373 | +} |
Reviewers: mp+209801_ code.launchpad. net,
Message:
Please take a look.
Description:
Local provider flag for fast-lxc
The flag is determined by the distro release from the
/etc/lsb-release file.
There is an override environment variable that can be
set to keep existing behaviour. Although no actual
behaviour is introduced in this branch.
https:/ /code.launchpad .net/~thumper/ juju-core/ fast-lxc/ +merge/ 209801
Requires: /code.launchpad .net/~thumper/ juju-core/ maybe-add- cloud-archive- func/+merge/ 209798
https:/
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/72210043/
Affected files (+154, -7 lines): local/environ. go local/export_ test.go local/lxc. go local/lxc_ test.go
A [revision details]
M provider/
M provider/
A provider/
A provider/