Merge lp:~wallyworld/juju-core/fix-local-bootstrap-tools into lp:~go-bot/juju-core/trunk

Proposed by Ian Booth
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 2447
Proposed branch: lp:~wallyworld/juju-core/fix-local-bootstrap-tools
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 108 lines (+32/-20)
2 files modified
environs/bootstrap/bootstrap_test.go (+18/-9)
environs/bootstrap/synctools.go (+14/-11)
To merge this branch: bzr merge lp:~wallyworld/juju-core/fix-local-bootstrap-tools
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+211831@code.launchpad.net

Commit message

Fix tools upload for local provider.

Local provider inserts agent-version into config
when the environment is opened and this was
preventing tools from being uploaded.

https://codereview.appspot.com/77960043/

Description of the change

Fix tools upload for local provider.

Local provider inserts agent-version into config
when the environment is opened and this was
preventing tools from being uploaded.

https://codereview.appspot.com/77960043/

To post a comment you must log in.
Revision history for this message
Ian Booth (wallyworld) wrote :
Download full text (6.0 KiB)

Reviewers: mp+211831_code.launchpad.net,

Message:
Please take a look.

Description:
Fix tools upload for local provider.

Local provider inserts agent-version into config
when the environment is opened and this was
preventing tools from being uploaded.

https://code.launchpad.net/~wallyworld/juju-core/fix-local-bootstrap-tools/+merge/211831

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/77960043/

Affected files (+34, -20 lines):
   A [revision details]
   M environs/bootstrap/bootstrap_test.go
   M environs/bootstrap/synctools.go

Index: [revision details]
=== 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-20140319193533-t6r49574qjs0jkqw
+New revision: <email address hidden>

Index: environs/bootstrap/bootstrap_test.go
=== modified file 'environs/bootstrap/bootstrap_test.go'
--- environs/bootstrap/bootstrap_test.go 2014-03-19 01:20:14 +0000
+++ environs/bootstrap/bootstrap_test.go 2014-03-19 22:02:00 +0000
@@ -331,11 +331,13 @@
   c.Assert(bootstrap.SeriesToUpload(cfg, nil), gc.DeepEquals,
[]string{"quantal", "precise", "lucid"})
  }

-func (s *bootstrapSuite) assertUploadTools(c *gc.C, vers version.Binary,
allowRelease bool, errMessage string) {
+func (s *bootstrapSuite) assertUploadTools(c *gc.C, vers version.Binary,
allowRelease bool,
+ extraConfig map[string]interface{}, errMessage string) {
+
   s.PatchValue(&version.Current, vers)
   // If we allow released tools to be uploaded, the build number is
incremented so in that case
   // we need to ensure the environment is set up to allow dev tools to be
used.
- env := newEnviron("foo", useDefaultKeys,
map[string]interface{}{"development": allowRelease})
+ env := newEnviron("foo", useDefaultKeys, extraConfig)
   s.setDummyStorage(c, env)
   envtesting.RemoveFakeTools(c, env.Storage())

@@ -372,17 +374,24 @@

  func (s *bootstrapSuite) TestUploadTools(c *gc.C) {
   vers := version.MustParseBinary("1.19.0-trusty-arm64")
- s.assertUploadTools(c, vers, false, "")
-}
-
-func (s *bootstrapSuite) TestUploadToolsReleaseVersionAllowed(c *gc.C) {
- vers := version.MustParseBinary("1.18.0-trusty-arm64")
- s.assertUploadTools(c, vers, true, "")
+ s.assertUploadTools(c, vers, false, nil, "")
+}
+
+func (s *bootstrapSuite) TestUploadToolsForceVersionAllowsReleaseTools(c
*gc.C) {
+ vers := version.MustParseBinary("1.18.0-trusty-arm64")
+ extraCfg := map[string]interface{}{"development": true}
+ s.assertUploadTools(c, vers, true, extraCfg, "")
+}
+
+func (s *bootstrapSuite)
TestUploadToolsForceVersionAllowsAgentVersionSet(c *gc.C) {
+ vers := version.MustParseBinary("1.18.0-trusty-arm64")
+ extraCfg :=
map[string]interface{}{"agent-version": "1.18.0", "development": true}
+ s.assertUploadTools(c, vers, true, extraCfg, "")
  }

  func (s *bootstrapSuite) TestUploadToolsReleaseVersionDisallowed(c *gc.C) {
   vers := version.MustParseBinary("1.18.0-trusty-arm64")
- s.assertUploadTools(c, vers, false, "Juju cannot bootstrap because no
tools are available for your environment.*")
+ ...

Read more...

Revision history for this message
Tim Penhey (thumper) wrote :

On 2014/03/19 22:04:26, wallyworld wrote:
> Please take a look.

LGTM

https://codereview.appspot.com/77960043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'environs/bootstrap/bootstrap_test.go'
2--- environs/bootstrap/bootstrap_test.go 2014-03-19 01:20:14 +0000
3+++ environs/bootstrap/bootstrap_test.go 2014-03-19 22:04:18 +0000
4@@ -331,11 +331,13 @@
5 c.Assert(bootstrap.SeriesToUpload(cfg, nil), gc.DeepEquals, []string{"quantal", "precise", "lucid"})
6 }
7
8-func (s *bootstrapSuite) assertUploadTools(c *gc.C, vers version.Binary, allowRelease bool, errMessage string) {
9+func (s *bootstrapSuite) assertUploadTools(c *gc.C, vers version.Binary, allowRelease bool,
10+ extraConfig map[string]interface{}, errMessage string) {
11+
12 s.PatchValue(&version.Current, vers)
13 // If we allow released tools to be uploaded, the build number is incremented so in that case
14 // we need to ensure the environment is set up to allow dev tools to be used.
15- env := newEnviron("foo", useDefaultKeys, map[string]interface{}{"development": allowRelease})
16+ env := newEnviron("foo", useDefaultKeys, extraConfig)
17 s.setDummyStorage(c, env)
18 envtesting.RemoveFakeTools(c, env.Storage())
19
20@@ -372,17 +374,24 @@
21
22 func (s *bootstrapSuite) TestUploadTools(c *gc.C) {
23 vers := version.MustParseBinary("1.19.0-trusty-arm64")
24- s.assertUploadTools(c, vers, false, "")
25-}
26-
27-func (s *bootstrapSuite) TestUploadToolsReleaseVersionAllowed(c *gc.C) {
28- vers := version.MustParseBinary("1.18.0-trusty-arm64")
29- s.assertUploadTools(c, vers, true, "")
30+ s.assertUploadTools(c, vers, false, nil, "")
31+}
32+
33+func (s *bootstrapSuite) TestUploadToolsForceVersionAllowsReleaseTools(c *gc.C) {
34+ vers := version.MustParseBinary("1.18.0-trusty-arm64")
35+ extraCfg := map[string]interface{}{"development": true}
36+ s.assertUploadTools(c, vers, true, extraCfg, "")
37+}
38+
39+func (s *bootstrapSuite) TestUploadToolsForceVersionAllowsAgentVersionSet(c *gc.C) {
40+ vers := version.MustParseBinary("1.18.0-trusty-arm64")
41+ extraCfg := map[string]interface{}{"agent-version": "1.18.0", "development": true}
42+ s.assertUploadTools(c, vers, true, extraCfg, "")
43 }
44
45 func (s *bootstrapSuite) TestUploadToolsReleaseVersionDisallowed(c *gc.C) {
46 vers := version.MustParseBinary("1.18.0-trusty-arm64")
47- s.assertUploadTools(c, vers, false, "Juju cannot bootstrap because no tools are available for your environment.*")
48+ s.assertUploadTools(c, vers, false, nil, "Juju cannot bootstrap because no tools are available for your environment.*")
49 }
50
51 type bootstrapEnviron struct {
52
53=== modified file 'environs/bootstrap/synctools.go'
54--- environs/bootstrap/synctools.go 2014-03-19 02:55:15 +0000
55+++ environs/bootstrap/synctools.go 2014-03-19 22:04:18 +0000
56@@ -27,8 +27,10 @@
57 `
58
59 // UploadTools uploads tools for the specified series and any other relevant series to
60-// the environment storage, after which it sets the agent-version.
61-func UploadTools(env environs.Environ, toolsArch *string, allowRelease bool, bootstrapSeries ...string) error {
62+// the environment storage, after which it sets the agent-version. If forceVersion is true,
63+// we allow uploading release tools versions and allow uploading even when the agent-version is
64+// already set in the environment.
65+func UploadTools(env environs.Environ, toolsArch *string, forceVersion bool, bootstrapSeries ...string) error {
66 logger.Infof("checking that upload is possible")
67 // Check the series are valid.
68 for _, series := range bootstrapSeries {
69@@ -37,15 +39,15 @@
70 }
71 }
72 // See that we are allowed to upload the tools.
73- if err := validateUploadAllowed(env, toolsArch, allowRelease); err != nil {
74+ if err := validateUploadAllowed(env, toolsArch, forceVersion); err != nil {
75 return err
76 }
77
78 cfg := env.Config()
79- forceVersion := uploadVersion(version.Current.Number, nil)
80+ explicitVersion := uploadVersion(version.Current.Number, nil)
81 uploadSeries := SeriesToUpload(cfg, bootstrapSeries)
82 logger.Infof("uploading tools for series %s", uploadSeries)
83- tools, err := sync.Upload(env.Storage(), &forceVersion, uploadSeries...)
84+ tools, err := sync.Upload(env.Storage(), &explicitVersion, uploadSeries...)
85 if err != nil {
86 return err
87 }
88@@ -91,13 +93,14 @@
89
90 // validateUploadAllowed returns an error if an attempt to upload tools should
91 // not be allowed.
92-func validateUploadAllowed(env environs.Environ, toolsArch *string, allowRelease bool) error {
93- // First, check that there isn't already an agent version specified, and that we
94- // are running a development version.
95- if _, hasAgentVersion := env.Config().AgentVersion(); hasAgentVersion || (!allowRelease && !version.Current.IsDev()) {
96- return fmt.Errorf(noToolsNoUploadMessage)
97+func validateUploadAllowed(env environs.Environ, toolsArch *string, forceVersion bool) error {
98+ if !forceVersion {
99+ // First, check that there isn't already an agent version specified, and that we
100+ // are running a development version.
101+ if _, hasAgentVersion := env.Config().AgentVersion(); hasAgentVersion || !version.Current.IsDev() {
102+ return fmt.Errorf(noToolsNoUploadMessage)
103+ }
104 }
105-
106 // Now check that the architecture for which we are setting up an
107 // environment matches that from which we are bootstrapping.
108 hostArch := arch.HostArch()

Subscribers

People subscribed via source and target branches

to status/vote changes: