Merge lp:~wallyworld/juju-core/deprecate-tools-url into lp:~go-bot/juju-core/trunk

Proposed by Ian Booth
Status: Merged
Approved by: Ian Booth
Approved revision: no longer in the source branch.
Merged at revision: 2043
Proposed branch: lp:~wallyworld/juju-core/deprecate-tools-url
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 175 lines (+115/-3)
2 files modified
environs/config/config.go (+28/-0)
environs/config/config_test.go (+87/-3)
To merge this branch: bzr merge lp:~wallyworld/juju-core/deprecate-tools-url
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+194649@code.launchpad.net

Commit message

Add back support for deprecated tools-url

Removing tools-url from config too early breaks
upgrades so add it back for the next release.

https://codereview.appspot.com/24340043/

Description of the change

Add back support for deprecated tools-url

Removing tools-url from config too early breaks
upgrades so add it back for the next release.

https://codereview.appspot.com/24340043/

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

Reviewers: mp+194649_code.launchpad.net,

Message:
Please take a look.

Description:
Add back support for deprecated tools-url

Removing tools-url from config too early breaks
upgrades so add it back for the next release.

https://code.launchpad.net/~wallyworld/juju-core/deprecate-tools-url/+merge/194649

(do not edit description out of merge proposal)

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

Affected files (+117, -3 lines):
   A [revision details]
   M environs/config/config.go
   M environs/config/config_test.go

Revision history for this message
John A Meinel (jameinel) wrote :
Revision history for this message
Go Bot (go-bot) wrote :
Download full text (18.3 KiB)

The attempt to merge lp:~wallyworld/juju-core/deprecate-tools-url into lp:juju-core failed. Below is the output from the failed tests.

ok launchpad.net/juju-core/agent 1.131s
ok launchpad.net/juju-core/agent/tools 0.224s
ok launchpad.net/juju-core/bzr 6.920s
ok launchpad.net/juju-core/cert 3.767s
ok launchpad.net/juju-core/charm 0.557s
? launchpad.net/juju-core/charm/hooks [no test files]
ok launchpad.net/juju-core/cloudinit 0.026s
ok launchpad.net/juju-core/cmd 0.226s
? launchpad.net/juju-core/cmd/charmd [no test files]
? launchpad.net/juju-core/cmd/charmload [no test files]
ok launchpad.net/juju-core/cmd/juju 177.696s
ok launchpad.net/juju-core/cmd/jujud 55.687s
ok launchpad.net/juju-core/cmd/plugins/juju-metadata 2.814s
ok launchpad.net/juju-core/constraints 0.027s
ok launchpad.net/juju-core/container/lxc 0.289s
? launchpad.net/juju-core/container/lxc/mock [no test files]
ok launchpad.net/juju-core/downloader 5.272s
ok launchpad.net/juju-core/environs 3.156s
ok launchpad.net/juju-core/environs/bootstrap 5.013s
ok launchpad.net/juju-core/environs/cloudinit 0.527s
ok launchpad.net/juju-core/environs/config 1.419s
ok launchpad.net/juju-core/environs/configstore 0.040s
ok launchpad.net/juju-core/environs/filestorage 0.031s
ok launchpad.net/juju-core/environs/httpstorage 0.989s
ok launchpad.net/juju-core/environs/imagemetadata 0.500s
? launchpad.net/juju-core/environs/imagemetadata/testing [no test files]
ok launchpad.net/juju-core/environs/instances 0.051s
ok launchpad.net/juju-core/environs/jujutest 0.248s
ok launchpad.net/juju-core/environs/manual 5.727s
ok launchpad.net/juju-core/environs/simplestreams 0.348s
? launchpad.net/juju-core/environs/simplestreams/testing [no test files]
ok launchpad.net/juju-core/environs/sshstorage 1.065s
ok launchpad.net/juju-core/environs/storage 1.133s
ok launchpad.net/juju-core/environs/sync 28.383s
ok launchpad.net/juju-core/environs/testing 0.186s
ok launchpad.net/juju-core/environs/tools 6.671s
? launchpad.net/juju-core/environs/tools/testing [no test files]
ok launchpad.net/juju-core/errors 0.015s
ok launchpad.net/juju-core/instance 0.021s
? launchpad.net/juju-core/instance/testing [no test files]
ok launchpad.net/juju-core/juju 17.879s
ok launchpad.net/juju-core/juju/osenv 0.018s
? launchpad.net/juju-core/juju/testing [no test files]
ok launchpad.net/juju-core/log 0.016s
ok launchpad.net/juju-core/log/syslog 0.024s
ok launchpad.net/juju-core/names 0.024s
? launchpad.net/juju-core/provider [no test files]
? launchpad.net/juju-core/provider/all [no test files]
ok launchpad.net/juju-core/provider/azure 6.427s
ok launchpad.net/juju-core/provider/common 0.333s
ok launchpad.net/juju-core/provider/dummy 21.159s
ok launchpad.net/juju-core/provider/ec2 5.056s
ok launchpad.net/juju-core/provider/ec2/httpstorage 0.233s
ok launchpad.net/juju-core/provider/local 2.196s
ok launchpad.net/juju-core/provider/maas 9.985s
ok launchpad.net/juju-core/provider/null 1.347s
ok launchpad.net/juju-core/provider/openstack 11.639s
ok launchpad.net/juju-core/rpc 0.077s
ok launchpad.net/juju-core/rpc/json...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'environs/config/config.go'
--- environs/config/config.go 2013-11-04 02:01:19 +0000
+++ environs/config/config.go 2013-11-11 02:04:03 +0000
@@ -244,6 +244,28 @@
244 }244 }
245 }245 }
246 }246 }
247
248 // The tools url has changed so see if the old one is still in use.
249 if oldToolsURL := cfg.m["tools-url"]; oldToolsURL != nil && oldToolsURL.(string) != "" {
250 _, newToolsSpecified := cfg.ToolsURL()
251 var msg string
252 if newToolsSpecified {
253 msg = fmt.Sprintf(
254 "Config attribute %q (%v) is deprecated and will be ignored since\n"+
255 "the new tools URL attribute %q has also been used.\n"+
256 "The attribute % should be removed from your configuration.",
257 "tools-url", oldToolsURL, "tools-metadata-url", "tools-url")
258 } else {
259 msg = fmt.Sprintf(
260 "Config attribute %q (%v) is deprecated.\n"+
261 "The location to find tools is now specified using the %q attribute.\n"+
262 "Your configuration should be upddated to set %q as follows\n%v: %v.",
263 "tools-url", oldToolsURL, "tools-metadata-url", "tools-metadata-url", "tools-metadata-url", oldToolsURL)
264 cfg.m["tools-metadata-url"] = oldToolsURL
265 }
266 logger.Warningf(msg)
267 delete(cfg.m, "tools-url")
268 }
247 return nil269 return nil
248}270}
249271
@@ -495,6 +517,9 @@
495 "state-port": schema.ForceInt(),517 "state-port": schema.ForceInt(),
496 "api-port": schema.ForceInt(),518 "api-port": schema.ForceInt(),
497 "logging-config": schema.String(),519 "logging-config": schema.String(),
520
521 // Deprecated fields, retain for backwards compatibility.
522 "tools-url": schema.String(),
498}523}
499524
500// alwaysOptional holds configuration defaults for attributes that may525// alwaysOptional holds configuration defaults for attributes that may
@@ -514,6 +539,9 @@
514 "ca-private-key-path": schema.Omit,539 "ca-private-key-path": schema.Omit,
515 "logging-config": schema.Omit,540 "logging-config": schema.Omit,
516541
542 // Deprecated fields, retain for backwards compatibility.
543 "tools-url": schema.Omit,
544
517 // For backward compatibility reasons, the following545 // For backward compatibility reasons, the following
518 // attributes default to empty strings rather than being546 // attributes default to empty strings rather than being
519 // omitted.547 // omitted.
520548
=== modified file 'environs/config/config_test.go'
--- environs/config/config_test.go 2013-11-04 02:01:19 +0000
+++ environs/config/config_test.go 2013-11-11 02:04:03 +0000
@@ -5,6 +5,7 @@
55
6import (6import (
7 "fmt"7 "fmt"
8 "strings"
8 stdtesting "testing"9 stdtesting "testing"
9 "time"10 "time"
1011
@@ -79,6 +80,23 @@
79 "tools-metadata-url": "tools-metadata-url",80 "tools-metadata-url": "tools-metadata-url",
80 },81 },
81 }, {82 }, {
83 about: "Deprecated tools metadata URL used",
84 useDefaults: config.UseDefaults,
85 attrs: testing.Attrs{
86 "type": "my-type",
87 "name": "my-name",
88 "tools-url": "tools-metadata-url",
89 },
90 }, {
91 about: "Deprecated tools metadata URL ignored",
92 useDefaults: config.UseDefaults,
93 attrs: testing.Attrs{
94 "type": "my-type",
95 "name": "my-name",
96 "tools-metadata-url": "tools-metadata-url",
97 "tools-url": "ignore-me",
98 },
99 }, {
82 about: "Explicit series",100 about: "Explicit series",
83 useDefaults: config.UseDefaults,101 useDefaults: config.UseDefaults,
84 attrs: testing.Attrs{102 attrs: testing.Attrs{
@@ -745,13 +763,21 @@
745 } else {763 } else {
746 c.Assert(urlPresent, jc.IsFalse)764 c.Assert(urlPresent, jc.IsFalse)
747 }765 }
748 url, urlPresent = cfg.ToolsURL()766 toolsURL, urlPresent := cfg.ToolsURL()
749 if v, _ := test.attrs["tools-metadata-url"].(string); v != "" {767 deprecatedToolsURLTestValue, deprecatedURLPresent := test.attrs["tools-url"]
750 c.Assert(url, gc.Equals, v)768 toolsURLTestValue := test.attrs["tools-metadata-url"]
769 if toolsURLTestValue == nil {
770 toolsURLTestValue = deprecatedToolsURLTestValue
771 }
772 if toolsURLTestValue != nil && toolsURLTestValue != "" {
773 c.Assert(toolsURL, gc.Equals, toolsURLTestValue)
751 c.Assert(urlPresent, jc.IsTrue)774 c.Assert(urlPresent, jc.IsTrue)
752 } else {775 } else {
753 c.Assert(urlPresent, jc.IsFalse)776 c.Assert(urlPresent, jc.IsFalse)
777 c.Assert(deprecatedURLPresent, jc.IsFalse)
754 }778 }
779 _, urlPresent = cfg.AllAttrs()["tools-url"]
780 c.Assert(urlPresent, jc.IsFalse)
755}781}
756782
757func (s *ConfigSuite) TestConfigAttrs(c *gc.C) {783func (s *ConfigSuite) TestConfigAttrs(c *gc.C) {
@@ -1101,3 +1127,61 @@
1101MIIBOgIBAAJAZabKgKInuOxj5vDWLwHHQtK3/45KB+32D15w94Nt83BmuGxo90lw1127MIIBOgIBAAJAZabKgKInuOxj5vDWLwHHQtK3/45KB+32D15w94Nt83BmuGxo90lw
1102-----END CERTIFICATE-----1128-----END CERTIFICATE-----
1103`[1:]1129`[1:]
1130
1131type ConfigDeprecationSuite struct {
1132 ConfigSuite
1133 writer *testWriter
1134}
1135
1136var _ = gc.Suite(&ConfigDeprecationSuite{})
1137
1138func (s *ConfigDeprecationSuite) SetUpTest(c *gc.C) {
1139 s.ConfigSuite.SetUpTest(c)
1140}
1141
1142func (s *ConfigDeprecationSuite) TearDownTest(c *gc.C) {
1143 s.ConfigSuite.TearDownTest(c)
1144}
1145
1146func (s *ConfigDeprecationSuite) setupLogger(c *gc.C) {
1147 var err error
1148 s.writer = &testWriter{}
1149 err = loggo.RegisterWriter("test", s.writer, loggo.WARNING)
1150 c.Assert(err, gc.IsNil)
1151}
1152
1153func (s *ConfigDeprecationSuite) resetLogger(c *gc.C) {
1154 _, _, err := loggo.RemoveWriter("test")
1155 c.Assert(err, gc.IsNil)
1156}
1157
1158type testWriter struct {
1159 messages []string
1160}
1161
1162func (t *testWriter) Write(level loggo.Level, module, filename string, line int, timestamp time.Time, message string) {
1163 t.messages = append(t.messages, message)
1164}
1165
1166func (s *ConfigDeprecationSuite) setupEnv(c *gc.C, deprecatedKey, value string) {
1167 attrs := testing.FakeConfig().Merge(testing.Attrs{
1168 "name": "testenv",
1169 "type": "openstack",
1170 deprecatedKey: value,
1171 })
1172 _, err := config.New(config.NoDefaults, attrs)
1173 c.Assert(err, gc.IsNil)
1174}
1175
1176func (s *ConfigDeprecationSuite) TestDeprecationWarnings(c *gc.C) {
1177 for attr, value := range map[string]string{
1178 "tools-url": "foo",
1179 } {
1180 s.setupLogger(c)
1181 s.setupEnv(c, attr, value)
1182 s.resetLogger(c)
1183 stripped := strings.Replace(s.writer.messages[0], "\n", "", -1)
1184 expected := fmt.Sprintf(`.*Config attribute "%s" \(%s\) is deprecated.*`, attr, value)
1185 c.Assert(stripped, gc.Matches, expected)
1186 }
1187}

Subscribers

People subscribed via source and target branches

to status/vote changes: