Merge lp:~dave-cheney/juju-core/082-conn-update-secrets-only-if-needed into lp:~juju/juju-core/trunk

Proposed by Dave Cheney
Status: Rejected
Rejected by: Dave Cheney
Proposed branch: lp:~dave-cheney/juju-core/082-conn-update-secrets-only-if-needed
Merge into: lp:~juju/juju-core/trunk
Prerequisite: lp:~rogpeppe/juju-core/042-environs-bootstrap-config
Diff against target: 114 lines (+53/-4) (has conflicts)
4 files modified
environs/cloudinit/cloudinit.go (+0/-3)
juju/conn.go (+20/-0)
juju/conn_test.go (+24/-1)
testing/imports.go (+9/-0)
Text conflict in juju/conn.go
To merge this branch: bzr merge lp:~dave-cheney/juju-core/082-conn-update-secrets-only-if-needed
Reviewer Review Type Date Requested Status
The Go Language Gophers Pending
Review via email: mp+122183@code.launchpad.net

Description of the change

juju: update unknown config attrs once

Additional UnknownAttrs from the local environment
will only be applied if they do not already exist in
the state.

https://codereview.appspot.com/6503056/

To post a comment you must log in.
453. By Dave Cheney

Import packages required for testing

Unmerged revisions

453. By Dave Cheney

Import packages required for testing

452. By Dave Cheney

merge from prereq

451. By Dave Cheney

wip

450. By Dave Cheney

only update non existing UnknownAttrs

449. By Dave Cheney

merge from trunk

448. By Dave Cheney

wip

447. By Dave Cheney

environs/dummy: add delay

This proposal implements a delay in most dummy operations. The delay
can be set test wide by setting JUJU_DUMMY_DELAY to a time.Duration
parsable value.

R=niemeyer
CC=
https://codereview.appspot.com/6482081

446. By Dave Cheney

environs/ec2: log open/close port details

https://bugs.launchpad.net/juju-core/+bug/1042073

Added logging of security group name to successful
open/close port operation.

R=niemeyer
CC=
https://codereview.appspot.com/6490049

445. By Dave Cheney

environs/cloudinit: deploy mongo debs

Install mongo debs alongside zookeeper ones.

R=niemeyer
CC=
https://codereview.appspot.com/6501054

444. By Dave Cheney

environs/cloudinit: ZooKeeper -> StateServer

This proposal is part of a set to add support for deploying
an environment on MongoDB in parallel with ZooKeeper.

R=niemeyer
CC=
https://codereview.appspot.com/6497051

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'environs/cloudinit/cloudinit.go'
2--- environs/cloudinit/cloudinit.go 2012-08-31 02:59:18 +0000
3+++ environs/cloudinit/cloudinit.go 2012-08-31 02:59:18 +0000
4@@ -7,7 +7,6 @@
5 "launchpad.net/juju-core/cloudinit"
6 "launchpad.net/juju-core/environs"
7 "launchpad.net/juju-core/environs/config"
8- "launchpad.net/juju-core/log"
9 "launchpad.net/juju-core/state"
10 "launchpad.net/juju-core/upstart"
11 "path"
12@@ -119,9 +118,7 @@
13 )
14
15 debugFlag := ""
16- if log.Debug {
17 debugFlag = " --debug"
18- }
19
20 if cfg.StateServer {
21 // zookeeper scripts
22
23=== modified file 'juju/conn.go'
24--- juju/conn.go 2012-08-30 13:21:00 +0000
25+++ juju/conn.go 2012-08-31 02:59:18 +0000
26@@ -82,11 +82,31 @@
27 // from the local configuration.
28 func (c *Conn) updateSecrets() error {
29 cfg := c.Environ.Config()
30+<<<<<<< TREE
31 // This is wrong. This will _always_ overwrite the secrets
32 // in the state with the local secrets. To fix this properly
33 // we need to ensure that the config, minus secrets, is always
34 // pushed on bootstrap, then we can fill in the secrets here.
35 return c.state.SetEnvironConfig(cfg)
36+=======
37+ env, err := c.state.EnvironConfig()
38+ if err != nil {
39+ return err
40+ }
41+ for k, v := range cfg.UnknownAttrs() {
42+ if _, exists := env.Get(k); !exists {
43+ env.Set(k, v)
44+ }
45+ }
46+ n, err := env.Write()
47+ if err != nil {
48+ return err
49+ }
50+ if len(n) > 0 {
51+ log.Debugf("Updating %d secret(s) in environment %q", len(n), c.Environ.Name())
52+ }
53+ return nil
54+>>>>>>> MERGE-SOURCE
55 }
56
57 // Close terminates the connection to the environment and releases
58
59=== modified file 'juju/conn_test.go'
60--- juju/conn_test.go 2012-08-30 13:21:00 +0000
61+++ juju/conn_test.go 2012-08-31 02:59:18 +0000
62@@ -92,7 +92,7 @@
63 c.Assert(err, ErrorMatches, "dummy environment not bootstrapped")
64 }
65
66-func (cs *ConnSuite) TestConnStateSecretsSideEffect(c *C) {
67+func (*ConnSuite) TestConnStateSecretsSideEffect(c *C) {
68 env, err := environs.NewFromAttrs(map[string]interface{}{
69 "name": "erewhemos",
70 "type": "dummy",
71@@ -129,6 +129,29 @@
72 c.Assert(cfg.UnknownAttrs()["secret"], Equals, "pork")
73 }
74
75+func (cs *ConnSuite) TestConnStateDoesNotUpdateExistingSecrets(c *C) {
76+ cs.TestConnStateSecretsSideEffect(c)
77+ conn, err := juju.NewConnFromAttrs(map[string]interface{}{
78+ "name": "erewhemos",
79+ "type": "dummy",
80+ "zookeeper": true,
81+ "authorized-keys": "i-am-a-key",
82+ "secret": "squirrel",
83+ })
84+ c.Assert(err, IsNil)
85+ defer conn.Close()
86+ st, err := conn.State()
87+ c.Assert(err, IsNil)
88+ cfg, err := st.EnvironConfig()
89+ c.Assert(err, IsNil)
90+ err = cfg.Read()
91+ c.Assert(err, IsNil)
92+ // check that the secret has not changed
93+ secret, ok := cfg.Get("secret")
94+ c.Assert(ok, Equals, true)
95+ c.Assert(secret, Equals, "pork")
96+}
97+
98 func (*ConnSuite) TestValidRegexps(c *C) {
99 assertService := func(s string, expect bool) {
100 c.Assert(juju.ValidService.MatchString(s), Equals, expect)
101
102=== added file 'testing/imports.go'
103--- testing/imports.go 1970-01-01 00:00:00 +0000
104+++ testing/imports.go 2012-08-31 02:59:18 +0000
105@@ -0,0 +1,9 @@
106+package testing
107+
108+import (
109+ // Import packages only needed for testing.
110+ // This ensures all the prereqs will be installed
111+ // correctly by go get.
112+ _ "launchpad.net/gocheck"
113+ _ "launchpad.net/lpad"
114+)

Subscribers

People subscribed via source and target branches