Merge lp:~dimitern/juju-core/lp-1308146-1.18-backport into lp:~go-bot/juju-core/trunk

Proposed by Dimiter Naydenov
Status: Superseded
Proposed branch: lp:~dimitern/juju-core/lp-1308146-1.18-backport
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 290 lines (+165/-1) (has conflicts)
8 files modified
agent/mongo/mongo.go (+25/-0)
environs/cloudinit/cloudinit_test.go (+51/-0)
provider/ec2/image_test.go (+11/-0)
scripts/win-installer/setup.iss (+4/-0)
state/charm.go (+11/-0)
state/state.go (+10/-1)
state/state_test.go (+49/-0)
version/version.go (+4/-0)
Text conflict in agent/mongo/mongo.go
Text conflict in environs/cloudinit/cloudinit_test.go
Text conflict in provider/ec2/image_test.go
Text conflict in scripts/win-installer/setup.iss
Text conflict in state/state_test.go
Text conflict in version/version.go
To merge this branch: bzr merge lp:~dimitern/juju-core/lp-1308146-1.18-backport
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+235115@code.launchpad.net

This proposal has been superseded by a proposal from 2014-09-18.

Description of the change

Fixed lp:1308146 - backported from github/trunk

See http://pad.lv/1308146 - this fixes the issue by backporting
the already landed fix from github.com/juju/juju/ trunk - for
more info, see https://github.com/juju/juju/pull/786.

https://codereview.appspot.com/138640043/

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

Reviewers: mp+235115_code.launchpad.net,

Message:
Please take a look.

Description:
Fixed lp:1308146 - backported from github/trunk

See http://pad.lv/1308146 - this fixes the issue by backporting
the already landed fix from github.com/juju/juju/ trunk - for
more info, see https://github.com/juju/juju/pull/786.

https://code.launchpad.net/~dimitern/juju-core/lp-1308146-1.18-backport/+merge/235115

(do not edit description out of merge proposal)

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

Affected files (+85, -12 lines):
   A [revision details]
   M agent/mongo/mongo.go
   M environs/cloudinit/cloudinit_test.go
   M environs/instances/instancetype.go
   M environs/instances/instancetype_test.go
   M environs/testing/tools.go
   M provider/ec2/image_test.go
   M scripts/win-installer/setup.iss
   M state/charm.go
   M state/state.go
   M state/state_test.go
   M version/version.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-20140513040856-lm051mdy3n916km6
+New revision:
<email address hidden>

Index: state/state_test.go
=== modified file 'state/state_test.go'
--- state/state_test.go 2014-03-27 12:53:54 +0000
+++ state/state_test.go 2014-09-18 12:52:26 +0000
@@ -6,6 +6,7 @@
  import (
   "fmt"
   "net/url"
+ "path/filepath"
   "sort"
   "strconv"
   "time"
@@ -340,6 +341,50 @@
   c.Assert(sch.BundleSha256(), gc.Equals, "missing")
  }

+func (s *StateSuite) TestUpdateUploadedCharmEscapesSpecialCharsInConfig(c
*gc.C) {
+ // Make sure when we have mongodb special characters like "$" and
+ // "." in the name of any charm config option, we do proper
+ // escaping before storing them and unescaping after loading. See
+ // also http://pad.lv/1308146.
+
+ // Clone the dummy charm and change the config.
+ configWithProblematicKeys := []byte(`
+options:
+ $bad.key: {default: bad, description: bad, type: string}
+ not.ok.key: {description: not ok, type: int}
+ valid-key: {description: all good, type: boolean}
+ still$bad.: {description: not good, type: float}
+ $.$: {description: awful, type: string}
+ ...: {description: oh boy, type: int}
+ just$: {description: no no, type: float}
+`[1:])
+ chDir := testing.Charms.ClonedDirPath(c.MkDir(), "dummy")
+ err := utils.AtomicWriteFile(
+ filepath.Join(chDir, "config.yaml"),
+ configWithProblematicKeys,
+ 0666,
+ )
+ c.Assert(err, gc.IsNil)
+ ch, err := charm.ReadDir(chDir)
+ c.Assert(err, gc.IsNil)
+ missingCurl := charm.MustParseURL("local:quantal/missing-1")
+ bundleURL, err := url.Parse("http://bundles.testing.invalid/dummy-1")
+ c.Assert(err, gc.IsNil)
+
+ _, err = s.State.PrepareLocalCharmUpload(missingCurl)
+ c.Assert(err, gc.IsNil)
+ sch, err := s.State.UpdateUploadedCharm(ch, missingCurl,
bundleURL, "missing")
+ c.Assert(err, gc.IsNil)
+ c.Assert(sch.URL(), gc.DeepEquals, missingCurl)
+ c.Assert(sch.Revision(), gc.Equals, missingCurl.Revision)
+ c.Assert(sch.IsUploaded(), jc.IsTrue)
+ c.Assert(sch.IsPlaceholder(), jc.IsFalse)
+ c.Assert(sch.Meta(), gc.DeepEquals, ch.Meta()...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'agent/mongo/mongo.go'
2--- agent/mongo/mongo.go 2014-05-28 10:24:07 +0000
3+++ agent/mongo/mongo.go 2014-09-18 12:56:08 +0000
4@@ -54,6 +54,7 @@
5 upstartServiceStart = (*upstart.Service).Start
6 )
7
8+<<<<<<< TREE
9 // WithAddresses represents an entity that has a set of
10 // addresses. e.g. a state Machine object
11 type WithAddresses interface {
12@@ -113,6 +114,30 @@
13 }
14
15 // Path returns the executable path to be used to run mongod on this
16+=======
17+// MongoPackageForSeries returns the name of the mongo package for the series
18+// of the machine that it is going to be running on.
19+func MongoPackageForSeries(series string) string {
20+ switch series {
21+ case "precise", "quantal", "raring", "saucy":
22+ return "mongodb-server"
23+ default:
24+ // trusty and onwards
25+ return "juju-mongodb"
26+ }
27+}
28+
29+// MongodPathForSeries returns the path to the mongod executable for the
30+// series of the machine that it is going to be running on.
31+func MongodPathForSeries(series string) string {
32+ if MongoPackageForSeries(series) == "juju-mongodb" {
33+ return JujuMongodPath
34+ }
35+ return MongodbServerPath
36+}
37+
38+// MongoPath returns the executable path to be used to run mongod on this
39+>>>>>>> MERGE-SOURCE
40 // machine. If the juju-bundled version of mongo exists, it will return that
41 // path, otherwise it will return the command to run mongod from the path.
42 func Path() (string, error) {
43
44=== modified file 'environs/cloudinit/cloudinit_test.go'
45--- environs/cloudinit/cloudinit_test.go 2014-05-20 04:27:02 +0000
46+++ environs/cloudinit/cloudinit_test.go 2014-09-18 12:56:08 +0000
47@@ -182,6 +182,47 @@
48 ln -s 1\.2\.3-raring-amd64 '/var/lib/juju/tools/machine-0'
49 `,
50 }, {
51+<<<<<<< TREE
52+=======
53+ // utopic state server - use the new mongo from juju-mongodb
54+ cfg: cloudinit.MachineConfig{
55+ MachineId: "0",
56+ AuthorizedKeys: "sshkey1",
57+ AgentEnvironment: map[string]string{agent.ProviderType: "dummy"},
58+ // raring provides mongo in the archive
59+ Tools: newSimpleTools("1.2.3-utopic-amd64"),
60+ StateServer: true,
61+ StateServerCert: serverCert,
62+ StateServerKey: serverKey,
63+ StatePort: 37017,
64+ APIPort: 17070,
65+ MachineNonce: "FAKE_NONCE",
66+ StateInfo: &state.Info{
67+ Password: "arble",
68+ CACert: []byte("CA CERT\n" + testing.CACert),
69+ },
70+ APIInfo: &api.Info{
71+ Password: "bletch",
72+ CACert: []byte("CA CERT\n" + testing.CACert),
73+ },
74+ Constraints: envConstraints,
75+ DataDir: environs.DataDir,
76+ LogDir: agent.DefaultLogDir,
77+ Jobs: allMachineJobs,
78+ CloudInitOutputLog: environs.CloudInitOutputLog,
79+ InstanceId: "i-bootstrap",
80+ SystemPrivateSSHKey: "private rsa key",
81+ MachineAgentServiceName: "jujud-machine-0",
82+ MongoServiceName: "juju-db",
83+ },
84+ setEnvConfig: true,
85+ inexactMatch: true,
86+ expectScripts: `
87+echo 'Starting MongoDB server \(juju-db\)'.*
88+cat >> /etc/init/juju-db\.conf << 'EOF'\\ndescription "juju state database"\\nauthor "Juju Team <juju@lists\.ubuntu\.com>"\\nstart on runlevel \[2345\]\\nstop on runlevel \[!2345\]\\nrespawn\\nnormal exit 0\\n\\nlimit nofile 65000 65000\\nlimit nproc 20000 20000\\n\\nexec /usr/lib/juju/bin/mongod --auth --dbpath=/var/lib/juju/db --sslOnNormalPorts --sslPEMKeyFile '/var/lib/juju/server\.pem' --sslPEMKeyPassword ignored --bind_ip 0\.0\.0\.0 --port 37017 --noprealloc --syslog --smallfiles\\nEOF\\n
89+`,
90+ }, {
91+>>>>>>> MERGE-SOURCE
92 // non state server.
93 cfg: cloudinit.MachineConfig{
94 MachineId: "99",
95@@ -392,6 +433,16 @@
96 // TestCloudInit checks that the output from the various tests
97 // in cloudinitTests is well formed.
98 func (*cloudinitSuite) TestCloudInit(c *gc.C) {
99+<<<<<<< TREE
100+=======
101+ expectedMongoPackage := map[string]string{
102+ "precise": "mongodb-server",
103+ "raring": "mongodb-server",
104+ "trusty": "juju-mongodb",
105+ "utopic": "juju-mongodb",
106+ }
107+
108+>>>>>>> MERGE-SOURCE
109 for i, test := range cloudinitTests {
110 c.Logf("test %d", i)
111 if test.setEnvConfig {
112
113=== modified file 'environs/instances/instancetype_test.go'
114=== modified file 'environs/testing/tools.go'
115=== modified file 'provider/ec2/image_test.go'
116--- provider/ec2/image_test.go 2014-06-02 05:50:33 +0000
117+++ provider/ec2/image_test.go 2014-09-18 12:56:08 +0000
118@@ -103,6 +103,7 @@
119 series: "quantal",
120 arches: both,
121 cons: "arch=amd64",
122+<<<<<<< TREE
123 itype: "cc2.8xlarge",
124 image: "ami-01000035",
125 }, {
126@@ -123,6 +124,16 @@
127 cons: "mem=4G root-disk=16384M",
128 itype: "m1.large",
129 image: "ami-00000033",
130+=======
131+ itype: "cc1.4xlarge",
132+ image: "ami-01000035",
133+ }, {
134+ series: "precise",
135+ arches: both,
136+ cons: "mem=4G root-disk=16384M",
137+ itype: "m1.large",
138+ image: "ami-00000033",
139+>>>>>>> MERGE-SOURCE
140 },
141 }
142
143
144=== modified file 'scripts/win-installer/setup.iss'
145--- scripts/win-installer/setup.iss 2014-05-30 17:17:02 +0000
146+++ scripts/win-installer/setup.iss 2014-09-18 12:56:08 +0000
147@@ -2,7 +2,11 @@
148 ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
149
150 #define MyAppName "Juju"
151+<<<<<<< TREE
152 #define MyAppVersion "1.19.4"
153+=======
154+#define MyAppVersion "1.18.5"
155+>>>>>>> MERGE-SOURCE
156 #define MyAppPublisher "Canonical, Ltd"
157 #define MyAppURL "http://juju.ubuntu.com/"
158 #define MyAppExeName "juju.exe"
159
160=== modified file 'state/charm.go'
161--- state/charm.go 2014-01-29 20:57:31 +0000
162+++ state/charm.go 2014-09-18 12:56:08 +0000
163@@ -27,6 +27,17 @@
164 }
165
166 func newCharm(st *State, cdoc *charmDoc) (*Charm, error) {
167+ // Because we probably just read the doc from state, make sure we
168+ // unescape any config option names for "$" and ".". See
169+ // http://pad.lv/1308146
170+ if cdoc != nil && cdoc.Config != nil {
171+ unescapedConfig := charm.NewConfig()
172+ for optionName, option := range cdoc.Config.Options {
173+ unescapedName := unescapeReplacer.Replace(optionName)
174+ unescapedConfig.Options[unescapedName] = option
175+ }
176+ cdoc.Config = unescapedConfig
177+ }
178 return &Charm{st: st, doc: *cdoc}, nil
179 }
180
181
182=== modified file 'state/state.go'
183--- state/state.go 2014-05-27 14:02:22 +0000
184+++ state/state.go 2014-09-18 12:56:08 +0000
185@@ -870,9 +870,18 @@
186 func (st *State) updateCharmDoc(
187 ch charm.Charm, curl *charm.URL, bundleURL *url.URL, bundleSha256 string, preReq interface{}) (*Charm, error) {
188
189+ // Make sure we escape any "$" and "." in config option names
190+ // first. See http://pad.lv/1308146.
191+ cfg := ch.Config()
192+ escapedConfig := charm.NewConfig()
193+ for optionName, option := range cfg.Options {
194+ escapedName := escapeReplacer.Replace(optionName)
195+ escapedConfig.Options[escapedName] = option
196+ }
197+
198 updateFields := bson.D{{"$set", bson.D{
199 {"meta", ch.Meta()},
200- {"config", ch.Config()},
201+ {"config", escapedConfig},
202 {"bundleurl", bundleURL},
203 {"bundlesha256", bundleSha256},
204 {"pendingupload", false},
205
206=== modified file 'state/state_test.go'
207--- state/state_test.go 2014-05-27 06:12:16 +0000
208+++ state/state_test.go 2014-09-18 12:56:08 +0000
209@@ -6,6 +6,11 @@
210 import (
211 "fmt"
212 "net/url"
213+<<<<<<< TREE
214+=======
215+ "path/filepath"
216+ "sort"
217+>>>>>>> MERGE-SOURCE
218 "strconv"
219 "strings"
220 "time"
221@@ -351,6 +356,50 @@
222 c.Assert(sch.BundleSha256(), gc.Equals, "missing")
223 }
224
225+func (s *StateSuite) TestUpdateUploadedCharmEscapesSpecialCharsInConfig(c *gc.C) {
226+ // Make sure when we have mongodb special characters like "$" and
227+ // "." in the name of any charm config option, we do proper
228+ // escaping before storing them and unescaping after loading. See
229+ // also http://pad.lv/1308146.
230+
231+ // Clone the dummy charm and change the config.
232+ configWithProblematicKeys := []byte(`
233+options:
234+ $bad.key: {default: bad, description: bad, type: string}
235+ not.ok.key: {description: not ok, type: int}
236+ valid-key: {description: all good, type: boolean}
237+ still$bad.: {description: not good, type: float}
238+ $.$: {description: awful, type: string}
239+ ...: {description: oh boy, type: int}
240+ just$: {description: no no, type: float}
241+`[1:])
242+ chDir := testing.Charms.ClonedDirPath(c.MkDir(), "dummy")
243+ err := utils.AtomicWriteFile(
244+ filepath.Join(chDir, "config.yaml"),
245+ configWithProblematicKeys,
246+ 0666,
247+ )
248+ c.Assert(err, gc.IsNil)
249+ ch, err := charm.ReadDir(chDir)
250+ c.Assert(err, gc.IsNil)
251+ missingCurl := charm.MustParseURL("local:quantal/missing-1")
252+ bundleURL, err := url.Parse("http://bundles.testing.invalid/dummy-1")
253+ c.Assert(err, gc.IsNil)
254+
255+ _, err = s.State.PrepareLocalCharmUpload(missingCurl)
256+ c.Assert(err, gc.IsNil)
257+ sch, err := s.State.UpdateUploadedCharm(ch, missingCurl, bundleURL, "missing")
258+ c.Assert(err, gc.IsNil)
259+ c.Assert(sch.URL(), gc.DeepEquals, missingCurl)
260+ c.Assert(sch.Revision(), gc.Equals, missingCurl.Revision)
261+ c.Assert(sch.IsUploaded(), jc.IsTrue)
262+ c.Assert(sch.IsPlaceholder(), jc.IsFalse)
263+ c.Assert(sch.Meta(), gc.DeepEquals, ch.Meta())
264+ c.Assert(sch.Config(), gc.DeepEquals, ch.Config())
265+ c.Assert(sch.BundleURL(), gc.DeepEquals, bundleURL)
266+ c.Assert(sch.BundleSha256(), gc.Equals, "missing")
267+}
268+
269 func (s *StateSuite) assertPlaceholderCharmExists(c *gc.C, curl *charm.URL) {
270 // Find charm directly and verify only the charm URL and
271 // Placeholder are set.
272
273=== modified file 'version/version.go'
274--- version/version.go 2014-06-02 17:12:27 +0000
275+++ version/version.go 2014-09-18 12:56:08 +0000
276@@ -24,10 +24,14 @@
277 // The presence and format of this constant is very important.
278 // The debian/rules build recipe uses this value for the version
279 // number of the release package.
280+<<<<<<< TREE
281 const version = "1.19.4"
282
283 // The version that we switched over from old style numbering to new style.
284 var switchOverVersion = MustParse("1.19.9")
285+=======
286+const version = "1.18.5"
287+>>>>>>> MERGE-SOURCE
288
289 // lsbReleaseFile is the name of the file that is read in order to determine
290 // the release version of ubuntu.

Subscribers

People subscribed via source and target branches

to status/vote changes: