Merge lp:~thumper/juju-core/make-syslog-port-configurable into lp:~go-bot/juju-core/trunk
- make-syslog-port-configurable
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Tim Penhey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2095 |
Proposed branch: | lp:~thumper/juju-core/make-syslog-port-configurable |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
906 lines (+217/-83) 25 files modified
container/lxc/lxc_test.go (+1/-0) environs/cloudinit.go (+5/-3) environs/cloudinit/cloudinit.go (+9/-2) environs/cloudinit/cloudinit_test.go (+10/-0) environs/cloudinit_test.go (+5/-1) environs/config/config.go (+15/-2) environs/config/config_test.go (+31/-0) environs/config_test.go (+19/-15) log/syslog/config.go (+19/-8) log/syslog/config_test.go (+6/-6) provider/azure/customdata_test.go (+1/-0) provider/dummy/environs.go (+1/-0) state/address.go (+24/-0) state/api/deployer/deployer.go (+7/-0) state/api/params/params.go (+9/-0) state/api/provisioner/provisioner_test.go (+1/-0) state/apiserver/deployer/deployer.go (+14/-0) state/apiserver/provisioner/provisioner.go (+1/-0) state/apiserver/provisioner/provisioner_test.go (+1/-0) worker/deployer/addresser.go (+0/-11) worker/deployer/export_test.go (+10/-9) worker/deployer/simple.go (+25/-24) worker/deployer/simple_test.go (+1/-1) worker/provisioner/lxc-broker.go (+1/-0) worker/provisioner/lxc-broker_test.go (+1/-1) |
To merge this branch: | bzr merge lp:~thumper/juju-core/make-syslog-port-configurable |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+196046@code.launchpad.net |
Commit message
Make the syslog udp port configurable.
Instead of having the syslog port hard-coded to 514 it makes
sense to make this configurable.
Any existing config that doesn't specify one will get the default,
which is 514.
This config port is passed through the cloud init machine config
structure so the syslog config that is written out forwards to the
correct port. This syslog port is needed, so a number of tests had
to be updated to make this work.
The (rather generic) 'suite' test in environs/
to use the LoggingSuite base to silence the logging that was leaked
out when running just the package tests.
The port number is now a template param in the rsyslog config.
The only other place where this was needed was with the deployer.
It was making multiple calls to get the state and api addresses.
Instead of adding another call, we now make one call to the api
to get the address information we need.
Description of the change
Make the syslog udp port configurable.
Instead of having the syslog port hard-coded to 514 it makes
sense to make this configurable.
Any existing config that doesn't specify one will get the default,
which is 514.
This config port is passed through the cloud init machine config
structure so the syslog config that is written out forwards to the
correct port. This syslog port is needed, so a number of tests had
to be updated to make this work.
The (rather generic) 'suite' test in environs/
to use the LoggingSuite base to silence the logging that was leaked
out when running just the package tests.
The port number is now a template param in the rsyslog config.
The only other place where this was needed was with the deployer.
It was making multiple calls to get the state and api addresses.
Instead of adding another call, we now make one call to the api
to get the address information we need.
Tim Penhey (thumper) wrote : | # |
Andrew Wilkins (axwalk) wrote : | # |
I see the value of a single round-trip to the API, but it seems a bit
ugly. I think someone with a better idea about the API design will have
to weigh in.
https:/
File log/syslog/
https:/
log/syslog/
fmt.Sprint(
https:/
File state/address.go (right):
https:/
state/address.
Difficult to parse, IMHO. I'd prefer
stateAddresses = appendPort(addrs, config.StatePort())
apiAddresses = appendPort(addrs, config.APIPort())
return stateAddresses, apiAddresses, config.
https:/
File state/api/
https:/
state/api/
I know I'm being pedantic, but a port isn't exactly an address. Multiple
API calls isn't great, though. It would be nice if we could make bulk
calls of an arbitrary sequence of API methods.
https:/
File worker/
https:/
worker/
This seems like the wrong place to be talking about the API. This should
just be about domain objects, I think.
Ian Booth (wallyworld) wrote : | # |
Big +1 to using bulk api calls which reflect the distributed workflow.
Out current api design is way too chatty since it seems to simply add a
remoting layer directly on the top of a domain api. So even though there
are quibbles about naming and packaging of results, this is great. The
main issue I have is that the api params structs should not be used
external to the api.
https:/
File state/address.go (right):
https:/
state/address.
I think it's worth making this function return a struct.
Since we are now returning a hodge podge of values, perhaps a better
method name is required
eg DeployerAddressInfo or DeployerConnect
I also think it may be worth naming this method to be the same as the
one on state, which is currently ServerAddresses().
https:/
File worker/
https:/
worker/
On 2013/11/21 05:17:42, axw wrote:
> This seems like the wrong place to be talking about the API. This
should just be
> about domain objects, I think.
+1
params.
structs should escape the api infrastructure
Tim Penhey (thumper) wrote : | # |
I'm not yet pushing up changes because I don't want to write more code
that is going to get argued over until we have a consensus on api/params
return types and the interface name.
https:/
File log/syslog/
https:/
log/syslog/
On 2013/11/21 05:17:42, axw wrote:
> fmt.Sprint(
Done.
https:/
File state/address.go (right):
https:/
state/address.
On 2013/11/22 00:46:52, wallyworld wrote:
> I think it's worth making this function return a struct.
> Since we are now returning a hodge podge of values, perhaps a better
method name
> is required
> eg DeployerAddressInfo or DeployerConnect
> I also think it may be worth naming this method to be the same as the
one on
> state, which is currently ServerAddresses().
Done.
https:/
state/address.
On 2013/11/21 05:17:42, axw wrote:
> Difficult to parse, IMHO. I'd prefer
> stateAddresses = appendPort(addrs, config.StatePort())
> apiAddresses = appendPort(addrs, config.APIPort())
> return stateAddresses, apiAddresses, config.
Now this returns a struct, it is more obvious.
https:/
File state/api/
https:/
state/api/
On 2013/11/21 05:17:42, axw wrote:
> I know I'm being pedantic, but a port isn't exactly an address.
Multiple API
> calls isn't great, though. It would be nice if we could make bulk
calls of an
> arbitrary sequence of API methods.
Changed struct name.
https:/
File worker/
https:/
worker/
On 2013/11/22 00:46:52, wallyworld wrote:
> On 2013/11/21 05:17:42, axw wrote:
> > This seems like the wrong place to be talking about the API. This
should just
> be
> > about domain objects, I think.
> +1
> params.
structs should
> escape the api infrastructure
OK, I disagree here on two fronts.
Firstly this interface should be renamed to have something to do with
the API. It defines the API methods that it calls.
Secondly there is already precedence for exporting api/params structures
as return parameters for client api method calls.
I don't see anything wrong with that as the api/params package is
defined to have no other dependencies, and is just a holding package for
structures. It seems stupid to redefine it just because.
This interface should be both renamed, and have the first two methods
removed, as they are no longer needed.
Ian Booth (wallyworld) wrote : | # |
https:/
> File worker/
https:/
> worker/
> On 2013/11/22 00:46:52, wallyworld wrote:
> > On 2013/11/21 05:17:42, axw wrote:
> > > This seems like the wrong place to be talking about the API. This
should
> just
> > be
> > > about domain objects, I think.
> >
> > +1
> > params.
structs
> should
> > escape the api infrastructure
> OK, I disagree here on two fronts.
> Firstly this interface should be renamed to have something to do with
the API.
> It defines the API methods that it calls.
> Secondly there is already precedence for exporting api/params
structures as
> return parameters for client api method calls.
> I don't see anything wrong with that as the api/params package is
defined to
> have no other dependencies, and is just a holding package for
structures. It
> seems stupid to redefine it just because.
> This interface should be both renamed, and have the first two methods
removed,
> as they are no longer needed.
Might be easier to discuss via a hangout. I have been tending to view
the params.* structs as internal, on-the-wire, representations of the
data to pass from client to server. And use of these outside of the api
becomes a layering violation. Perhaps I'm wrong
Ian Booth (wallyworld) wrote : | # |
https:/
> File worker/
https:/
> worker/
> On 2013/11/22 00:46:52, wallyworld wrote:
> > On 2013/11/21 05:17:42, axw wrote:
> > > This seems like the wrong place to be talking about the API. This
should
> just
> > be
> > > about domain objects, I think.
> >
> > +1
> > params.
structs
> should
> > escape the api infrastructure
> OK, I disagree here on two fronts.
> Firstly this interface should be renamed to have something to do with
the API.
> It defines the API methods that it calls.
> Secondly there is already precedence for exporting api/params
structures as
> return parameters for client api method calls.
> I don't see anything wrong with that as the api/params package is
defined to
> have no other dependencies, and is just a holding package for
structures. It
> seems stupid to redefine it just because.
> This interface should be both renamed, and have the first two methods
removed,
> as they are no longer needed.
Might be easier to discuss via a hangout. I have been tending to view
the params.* structs as internal, on-the-wire, representations of the
data to pass from client to server. And use of these outside of the api
becomes a layering violation. Perhaps I'm wrong
Tim Penhey (thumper) wrote : | # |
Please take a look.
Ian Booth (wallyworld) wrote : | # |
LGTM. As discussed, we can bikeshed later various issues with current
api implementation. The end result of this mp is few api round trips
which is a very good thing. So let's get this sucker landed.
Preview Diff
1 | === modified file 'container/lxc/lxc_test.go' |
2 | --- container/lxc/lxc_test.go 2013-11-11 21:38:30 +0000 |
3 | +++ container/lxc/lxc_test.go 2013-11-25 03:52:41 +0000 |
4 | @@ -70,6 +70,7 @@ |
5 | stateInfo := jujutesting.FakeStateInfo(machineId) |
6 | apiInfo := jujutesting.FakeAPIInfo(machineId) |
7 | machineConfig := environs.NewMachineConfig(machineId, "fake-nonce", stateInfo, apiInfo) |
8 | + machineConfig.SyslogPort = 2345 |
9 | machineConfig.Tools = &tools.Tools{ |
10 | Version: version.MustParseBinary("2.3.4-foo-bar"), |
11 | URL: "http://tools.testing.invalid/2.3.4-foo-bar.tgz", |
12 | |
13 | === modified file 'environs/cloudinit.go' |
14 | --- environs/cloudinit.go 2013-11-15 10:08:11 +0000 |
15 | +++ environs/cloudinit.go 2013-11-25 03:52:41 +0000 |
16 | @@ -53,8 +53,9 @@ |
17 | |
18 | func PopulateMachineConfig(mcfg *cloudinit.MachineConfig, |
19 | providerType, authorizedKeys string, |
20 | - sslHostnameVerification bool) error { |
21 | - |
22 | + sslHostnameVerification bool, |
23 | + syslogPort int, |
24 | +) error { |
25 | if authorizedKeys == "" { |
26 | return fmt.Errorf("environment configuration has no authorized-keys") |
27 | } |
28 | @@ -65,6 +66,7 @@ |
29 | mcfg.AgentEnvironment[agent.ProviderType] = providerType |
30 | mcfg.AgentEnvironment[agent.ContainerType] = string(mcfg.MachineContainerType) |
31 | mcfg.DisableSSLHostnameVerification = !sslHostnameVerification |
32 | + mcfg.SyslogPort = syslogPort |
33 | return nil |
34 | } |
35 | |
36 | @@ -81,7 +83,7 @@ |
37 | func FinishMachineConfig(mcfg *cloudinit.MachineConfig, cfg *config.Config, cons constraints.Value) (err error) { |
38 | defer utils.ErrorContextf(&err, "cannot complete machine configuration") |
39 | |
40 | - if err := PopulateMachineConfig(mcfg, cfg.Type(), cfg.AuthorizedKeys(), cfg.SSLHostnameVerification()); err != nil { |
41 | + if err := PopulateMachineConfig(mcfg, cfg.Type(), cfg.AuthorizedKeys(), cfg.SSLHostnameVerification(), cfg.SyslogPort()); err != nil { |
42 | return err |
43 | } |
44 | |
45 | |
46 | === modified file 'environs/cloudinit/cloudinit.go' |
47 | --- environs/cloudinit/cloudinit.go 2013-11-20 02:14:38 +0000 |
48 | +++ environs/cloudinit/cloudinit.go 2013-11-25 03:52:41 +0000 |
49 | @@ -58,6 +58,10 @@ |
50 | // if StateServer is true. |
51 | APIPort int |
52 | |
53 | + // SyslogPort specifies the port number that will be used when |
54 | + // sending the log messages using rsyslog. |
55 | + SyslogPort int |
56 | + |
57 | // StateInfo holds the means for the new instance to communicate with the |
58 | // juju state. Unless the new machine is running a state server (StateServer is |
59 | // set), there must be at least one state server address supplied. |
60 | @@ -246,10 +250,10 @@ |
61 | var configRenderer syslog.SyslogConfigRenderer |
62 | if cfg.StateServer { |
63 | configRenderer = syslog.NewAccumulateConfig( |
64 | - names.MachineTag(cfg.MachineId)) |
65 | + names.MachineTag(cfg.MachineId), cfg.SyslogPort) |
66 | } else { |
67 | configRenderer = syslog.NewForwardConfig( |
68 | - names.MachineTag(cfg.MachineId), cfg.stateHostAddrs()) |
69 | + names.MachineTag(cfg.MachineId), cfg.SyslogPort, cfg.stateHostAddrs()) |
70 | } |
71 | content, err := configRenderer.Render() |
72 | if err != nil { |
73 | @@ -500,6 +504,9 @@ |
74 | if cfg.APIInfo == nil { |
75 | return fmt.Errorf("missing API info") |
76 | } |
77 | + if cfg.SyslogPort == 0 { |
78 | + return fmt.Errorf("missing syslog port") |
79 | + } |
80 | if len(cfg.APIInfo.CACert) == 0 { |
81 | return fmt.Errorf("missing API CA certificate") |
82 | } |
83 | |
84 | === modified file 'environs/cloudinit/cloudinit_test.go' |
85 | --- environs/cloudinit/cloudinit_test.go 2013-11-20 02:14:38 +0000 |
86 | +++ environs/cloudinit/cloudinit_test.go 2013-11-25 03:52:41 +0000 |
87 | @@ -71,6 +71,7 @@ |
88 | StateServerKey: serverKey, |
89 | StatePort: 37017, |
90 | APIPort: 17070, |
91 | + SyslogPort: 514, |
92 | MachineNonce: "FAKE_NONCE", |
93 | StateInfo: &state.Info{ |
94 | Password: "arble", |
95 | @@ -140,6 +141,7 @@ |
96 | StateServerKey: serverKey, |
97 | StatePort: 37017, |
98 | APIPort: 17070, |
99 | + SyslogPort: 514, |
100 | MachineNonce: "FAKE_NONCE", |
101 | StateInfo: &state.Info{ |
102 | Password: "arble", |
103 | @@ -188,6 +190,7 @@ |
104 | Password: "bletch", |
105 | CACert: []byte("CA CERT\n" + testing.CACert), |
106 | }, |
107 | + SyslogPort: 514, |
108 | }, |
109 | expectScripts: ` |
110 | set -xe |
111 | @@ -236,6 +239,7 @@ |
112 | Password: "bletch", |
113 | CACert: []byte("CA CERT\n" + testing.CACert), |
114 | }, |
115 | + SyslogPort: 514, |
116 | }, |
117 | inexactMatch: true, |
118 | expectScripts: ` |
119 | @@ -272,6 +276,7 @@ |
120 | Password: "bletch", |
121 | CACert: []byte("CA CERT\n" + testing.CACert), |
122 | }, |
123 | + SyslogPort: 514, |
124 | DisableSSLHostnameVerification: true, |
125 | }, |
126 | inexactMatch: true, |
127 | @@ -291,6 +296,7 @@ |
128 | StateServerKey: serverKey, |
129 | StatePort: 37017, |
130 | APIPort: 17070, |
131 | + SyslogPort: 514, |
132 | MachineNonce: "FAKE_NONCE", |
133 | StateInfo: &state.Info{ |
134 | Password: "arble", |
135 | @@ -581,6 +587,9 @@ |
136 | {"missing API info", func(cfg *cloudinit.MachineConfig) { |
137 | cfg.APIInfo = nil |
138 | }}, |
139 | + {"missing syslog port", func(cfg *cloudinit.MachineConfig) { |
140 | + cfg.SyslogPort = 0 |
141 | + }}, |
142 | {"missing state hosts", func(cfg *cloudinit.MachineConfig) { |
143 | cfg.StateServer = false |
144 | cfg.StateInfo = &state.Info{ |
145 | @@ -684,6 +693,7 @@ |
146 | StateServerKey: serverKey, |
147 | StatePort: 1234, |
148 | APIPort: 1235, |
149 | + SyslogPort: 2345, |
150 | MachineId: "99", |
151 | Tools: newSimpleTools("9.9.9-linux-arble"), |
152 | AuthorizedKeys: "sshkey1", |
153 | |
154 | === modified file 'environs/cloudinit_test.go' |
155 | --- environs/cloudinit_test.go 2013-11-06 13:48:29 +0000 |
156 | +++ environs/cloudinit_test.go 2013-11-25 03:52:41 +0000 |
157 | @@ -62,13 +62,15 @@ |
158 | StateInfo: &state.Info{Tag: "not touched"}, |
159 | APIInfo: &api.Info{Tag: "not touched"}, |
160 | DisableSSLHostnameVerification: false, |
161 | + SyslogPort: 2345, |
162 | }) |
163 | } |
164 | |
165 | -func (s *CloudInitSuite) TestFinishMachineConfigNoSSLVerification(c *gc.C) { |
166 | +func (s *CloudInitSuite) TestFinishMachineConfigNonDefault(c *gc.C) { |
167 | attrs := dummySampleConfig().Merge(testing.Attrs{ |
168 | "authorized-keys": "we-are-the-keys", |
169 | "ssl-hostname-verification": false, |
170 | + "syslog-port": 8888, |
171 | }) |
172 | cfg, err := config.New(config.NoDefaults, attrs) |
173 | c.Assert(err, gc.IsNil) |
174 | @@ -87,6 +89,7 @@ |
175 | StateInfo: &state.Info{Tag: "not touched"}, |
176 | APIInfo: &api.Info{Tag: "not touched"}, |
177 | DisableSSLHostnameVerification: true, |
178 | + SyslogPort: 8888, |
179 | }) |
180 | } |
181 | |
182 | @@ -164,6 +167,7 @@ |
183 | Config: envConfig, |
184 | StatePort: envConfig.StatePort(), |
185 | APIPort: envConfig.APIPort(), |
186 | + SyslogPort: envConfig.SyslogPort(), |
187 | StateServer: true, |
188 | AgentEnvironment: map[string]string{agent.ProviderType: "dummy"}, |
189 | } |
190 | |
191 | === modified file 'environs/config/config.go' |
192 | --- environs/config/config.go 2013-11-14 10:59:22 +0000 |
193 | +++ environs/config/config.go 2013-11-25 03:52:41 +0000 |
194 | @@ -38,6 +38,10 @@ |
195 | |
196 | // DefaultApiPort is the default port the API server is listening on. |
197 | DefaultAPIPort int = 17070 |
198 | + |
199 | + // DefaultSyslogPort is the default port that the syslog UDP listener is |
200 | + // listening on. |
201 | + DefaultSyslogPort int = 514 |
202 | ) |
203 | |
204 | // Config holds an immutable environment configuration. |
205 | @@ -382,6 +386,11 @@ |
206 | return c.mustInt("api-port") |
207 | } |
208 | |
209 | +// SyslogPort returns the syslog port for the environment. |
210 | +func (c *Config) SyslogPort() int { |
211 | + return c.mustInt("syslog-port") |
212 | +} |
213 | + |
214 | // AuthorizedKeys returns the content for ssh's authorized_keys file. |
215 | func (c *Config) AuthorizedKeys() string { |
216 | return c.mustString("authorized-keys") |
217 | @@ -518,6 +527,7 @@ |
218 | "ssl-hostname-verification": schema.Bool(), |
219 | "state-port": schema.ForceInt(), |
220 | "api-port": schema.ForceInt(), |
221 | + "syslog-port": schema.ForceInt(), |
222 | "logging-config": schema.String(), |
223 | |
224 | // Deprecated fields, retain for backwards compatibility. |
225 | @@ -556,8 +566,9 @@ |
226 | |
227 | // For backward compatibility only - default ports were |
228 | // not filled out in previous versions of the configuration. |
229 | - "state-port": DefaultStatePort, |
230 | - "api-port": DefaultAPIPort, |
231 | + "state-port": DefaultStatePort, |
232 | + "api-port": DefaultAPIPort, |
233 | + "syslog-port": DefaultSyslogPort, |
234 | } |
235 | |
236 | func allowEmpty(attr string) bool { |
237 | @@ -574,6 +585,7 @@ |
238 | "ssl-hostname-verification": true, |
239 | "state-port": DefaultStatePort, |
240 | "api-port": DefaultAPIPort, |
241 | + "syslog-port": DefaultSyslogPort, |
242 | } |
243 | for attr, val := range alwaysOptional { |
244 | d[attr] = val |
245 | @@ -606,6 +618,7 @@ |
246 | "firewall-mode", |
247 | "state-port", |
248 | "api-port", |
249 | + "syslog-port", |
250 | } |
251 | |
252 | var ( |
253 | |
254 | === modified file 'environs/config/config_test.go' |
255 | --- environs/config/config_test.go 2013-11-14 10:59:22 +0000 |
256 | +++ environs/config/config_test.go 2013-11-25 03:52:41 +0000 |
257 | @@ -52,6 +52,7 @@ |
258 | "development": false, |
259 | "state-port": 1234, |
260 | "api-port": 4321, |
261 | + "syslog-port": 2345, |
262 | "default-series": "precise", |
263 | } |
264 | |
265 | @@ -453,6 +454,23 @@ |
266 | }, |
267 | err: `api-port: expected number, got string\("illegal"\)`, |
268 | }, { |
269 | + about: "Explicit syslog port", |
270 | + useDefaults: config.UseDefaults, |
271 | + attrs: testing.Attrs{ |
272 | + "type": "my-type", |
273 | + "name": "my-name", |
274 | + "syslog-port": 3456, |
275 | + }, |
276 | + }, { |
277 | + about: "Invalid syslog port", |
278 | + useDefaults: config.UseDefaults, |
279 | + attrs: testing.Attrs{ |
280 | + "type": "my-type", |
281 | + "name": "my-name", |
282 | + "syslog-port": "illegal", |
283 | + }, |
284 | + err: `syslog-port: expected number, got string\("illegal"\)`, |
285 | + }, { |
286 | about: "Invalid logging configuration", |
287 | useDefaults: config.UseDefaults, |
288 | attrs: testing.Attrs{ |
289 | @@ -684,6 +702,9 @@ |
290 | if apiPort, ok := test.attrs["api-port"]; ok { |
291 | c.Assert(cfg.APIPort(), gc.Equals, apiPort) |
292 | } |
293 | + if syslogPort, ok := test.attrs["syslog-port"]; ok { |
294 | + c.Assert(cfg.SyslogPort(), gc.Equals, syslogPort) |
295 | + } |
296 | |
297 | dev, _ := test.attrs["development"].(bool) |
298 | c.Assert(cfg.Development(), gc.Equals, dev) |
299 | @@ -798,6 +819,7 @@ |
300 | "development": false, |
301 | "state-port": 1234, |
302 | "api-port": 4321, |
303 | + "syslog-port": 2345, |
304 | "default-series": "precise", |
305 | } |
306 | cfg, err := config.New(config.NoDefaults, attrs) |
307 | @@ -869,6 +891,11 @@ |
308 | new: testing.Attrs{"api-port": 42}, |
309 | err: `cannot change api-port from 17070 to 42`, |
310 | }, { |
311 | + about: "Cannot change the syslog-port", |
312 | + old: testing.Attrs{"syslog-port": 345}, |
313 | + new: testing.Attrs{"syslog-port": 42}, |
314 | + err: `cannot change syslog-port from 345 to 42`, |
315 | +}, { |
316 | about: "Can change the state-port from explicit-default to implicit-default", |
317 | old: testing.Attrs{"state-port": config.DefaultStatePort}, |
318 | }, { |
319 | @@ -888,6 +915,10 @@ |
320 | about: "Cannot change the api-port from implicit-default to different value", |
321 | new: testing.Attrs{"api-port": 42}, |
322 | err: `cannot change api-port from 17070 to 42`, |
323 | +}, { |
324 | + about: "Cannot change the syslog-port from implicit-default to different value", |
325 | + new: testing.Attrs{"syslog-port": 42}, |
326 | + err: `cannot change syslog-port from 514 to 42`, |
327 | }} |
328 | |
329 | func (*ConfigSuite) TestValidateChange(c *gc.C) { |
330 | |
331 | === modified file 'environs/config_test.go' |
332 | --- environs/config_test.go 2013-11-13 08:15:10 +0000 |
333 | +++ environs/config_test.go 2013-11-25 03:52:41 +0000 |
334 | @@ -16,14 +16,18 @@ |
335 | "launchpad.net/juju-core/provider/dummy" |
336 | "launchpad.net/juju-core/testing" |
337 | jc "launchpad.net/juju-core/testing/checkers" |
338 | + "launchpad.net/juju-core/testing/testbase" |
339 | ) |
340 | |
341 | -type suite struct{} |
342 | - |
343 | -var _ = gc.Suite(suite{}) |
344 | - |
345 | -func (suite) TearDownTest(c *gc.C) { |
346 | +type suite struct { |
347 | + testbase.LoggingSuite |
348 | +} |
349 | + |
350 | +var _ = gc.Suite(&suite{}) |
351 | + |
352 | +func (s *suite) TearDownTest(c *gc.C) { |
353 | dummy.Reset() |
354 | + s.LoggingSuite.TearDownTest(c) |
355 | } |
356 | |
357 | var invalidConfigTests = []struct { |
358 | @@ -40,7 +44,7 @@ |
359 | }, |
360 | } |
361 | |
362 | -func (suite) TestInvalidConfig(c *gc.C) { |
363 | +func (*suite) TestInvalidConfig(c *gc.C) { |
364 | for i, t := range invalidConfigTests { |
365 | c.Logf("running test %v", i) |
366 | _, err := environs.ReadEnvironsBytes([]byte(t.env)) |
367 | @@ -72,7 +76,7 @@ |
368 | }, |
369 | } |
370 | |
371 | -func (suite) TestInvalidEnv(c *gc.C) { |
372 | +func (*suite) TestInvalidEnv(c *gc.C) { |
373 | defer testing.MakeFakeHomeNoEnvironments(c, "only").Restore() |
374 | for i, t := range invalidEnvTests { |
375 | c.Logf("running test %v", i) |
376 | @@ -84,7 +88,7 @@ |
377 | } |
378 | } |
379 | |
380 | -func (suite) TestNoWarningForDeprecatedButUnusedEnv(c *gc.C) { |
381 | +func (*suite) TestNoWarningForDeprecatedButUnusedEnv(c *gc.C) { |
382 | // This tests that a config that has a deprecated field doesn't |
383 | // generate a Warning if we don't actually ask for that environment. |
384 | // However, we can only really trigger that when we have a deprecated |
385 | @@ -124,7 +128,7 @@ |
386 | c.Check(tw.Log, gc.HasLen, 1) |
387 | } |
388 | |
389 | -func (suite) TestNoHomeBeforeConfig(c *gc.C) { |
390 | +func (*suite) TestNoHomeBeforeConfig(c *gc.C) { |
391 | // Test that we don't actually need HOME set until we call envs.Config() |
392 | // Because of this, we intentionally do *not* call testing.MakeFakeHomeNoEnvironments() |
393 | content := ` |
394 | @@ -138,7 +142,7 @@ |
395 | c.Check(err, gc.IsNil) |
396 | } |
397 | |
398 | -func (suite) TestNoEnv(c *gc.C) { |
399 | +func (*suite) TestNoEnv(c *gc.C) { |
400 | defer testing.MakeFakeHomeNoEnvironments(c).Restore() |
401 | es, err := environs.ReadEnvirons("") |
402 | c.Assert(es, gc.IsNil) |
403 | @@ -189,7 +193,7 @@ |
404 | }}, |
405 | } |
406 | |
407 | -func (suite) TestConfig(c *gc.C) { |
408 | +func (*suite) TestConfig(c *gc.C) { |
409 | defer testing.MakeFakeHomeNoEnvironments(c, "only", "valid", "one", "two").Restore() |
410 | for i, t := range configTests { |
411 | c.Logf("running test %v", i) |
412 | @@ -199,7 +203,7 @@ |
413 | } |
414 | } |
415 | |
416 | -func (suite) TestDefaultConfigFile(c *gc.C) { |
417 | +func (*suite) TestDefaultConfigFile(c *gc.C) { |
418 | defer testing.MakeEmptyFakeHome(c).Restore() |
419 | |
420 | env := ` |
421 | @@ -221,7 +225,7 @@ |
422 | c.Assert(cfg.Name(), gc.Equals, "only") |
423 | } |
424 | |
425 | -func (suite) TestConfigPerm(c *gc.C) { |
426 | +func (*suite) TestConfigPerm(c *gc.C) { |
427 | defer testing.MakeSampleHome(c).Restore() |
428 | |
429 | path := testing.HomePath(".juju") |
430 | @@ -248,7 +252,7 @@ |
431 | |
432 | } |
433 | |
434 | -func (suite) TestNamedConfigFile(c *gc.C) { |
435 | +func (*suite) TestNamedConfigFile(c *gc.C) { |
436 | defer testing.MakeFakeHomeNoEnvironments(c, "only").Restore() |
437 | |
438 | env := ` |
439 | @@ -275,7 +279,7 @@ |
440 | return ok |
441 | } |
442 | |
443 | -func (suite) TestBootstrapConfig(c *gc.C) { |
444 | +func (*suite) TestBootstrapConfig(c *gc.C) { |
445 | defer testing.MakeFakeHomeNoEnvironments(c, "bladaam").Restore() |
446 | attrs := dummySampleConfig().Merge(testing.Attrs{ |
447 | "agent-version": "1.2.3", |
448 | |
449 | === modified file 'log/syslog/config.go' |
450 | --- log/syslog/config.go 2013-08-19 03:03:46 +0000 |
451 | +++ log/syslog/config.go 2013-11-25 03:52:41 +0000 |
452 | @@ -26,7 +26,7 @@ |
453 | $InputRunFileMonitor |
454 | |
455 | $ModLoad imudp |
456 | -$UDPServerRun 514 |
457 | +$UDPServerRun {{portNumber}} |
458 | |
459 | # Messages received from remote rsyslog machines contain a leading space so we |
460 | # need to account for that. |
461 | @@ -52,7 +52,7 @@ |
462 | $InputFileStateFile {{logfileName}} |
463 | $InputRunFileMonitor |
464 | |
465 | -:syslogtag, startswith, "juju-" @{{bootstrapIP}}:514 |
466 | +:syslogtag, startswith, "juju-" @{{bootstrapIP}}:{{portNumber}} |
467 | & ~ |
468 | ` |
469 | |
470 | @@ -77,24 +77,28 @@ |
471 | LogFileName string |
472 | // the addresses of the state server to which messages should be forwarded. |
473 | StateServerAddresses []string |
474 | + // the port number for the udp listener |
475 | + Port int |
476 | } |
477 | |
478 | // NewForwardConfig creates a SyslogConfig instance used on unit nodes to forward log entries |
479 | // to the state server nodes. |
480 | -func NewForwardConfig(logFile string, stateServerAddresses []string) *SyslogConfig { |
481 | +func NewForwardConfig(logFile string, port int, stateServerAddresses []string) *SyslogConfig { |
482 | return &SyslogConfig{ |
483 | configTemplate: nodeRsyslogTemplate, |
484 | StateServerAddresses: stateServerAddresses, |
485 | LogFileName: logFile, |
486 | + Port: port, |
487 | } |
488 | } |
489 | |
490 | // NewAccumulateConfig creates a SyslogConfig instance used to accumulate log entries from the |
491 | // various unit nodes. |
492 | -func NewAccumulateConfig(logFile string) *SyslogConfig { |
493 | +func NewAccumulateConfig(logFile string, port int) *SyslogConfig { |
494 | return &SyslogConfig{ |
495 | configTemplate: stateServerRsyslogTemplate, |
496 | LogFileName: logFile, |
497 | + Port: port, |
498 | } |
499 | } |
500 | |
501 | @@ -127,11 +131,18 @@ |
502 | return fmt.Sprintf("/var/spool/rsyslog/juju-%s-state", slConfig.LogFileName) |
503 | } |
504 | |
505 | + var portNumber = func() string { |
506 | + return fmt.Sprint(slConfig.Port) |
507 | + } |
508 | + |
509 | t := template.New("") |
510 | - t.Funcs(template.FuncMap{"logfileName": logFileName}) |
511 | - t.Funcs(template.FuncMap{"bootstrapIP": bootstrapIP}) |
512 | - t.Funcs(template.FuncMap{"logfilePath": logFilePath}) |
513 | - t.Funcs(template.FuncMap{"statefilePath": stateFilePath}) |
514 | + t.Funcs(template.FuncMap{ |
515 | + "logfileName": logFileName, |
516 | + "bootstrapIP": bootstrapIP, |
517 | + "logfilePath": logFilePath, |
518 | + "statefilePath": stateFilePath, |
519 | + "portNumber": portNumber, |
520 | + }) |
521 | |
522 | // Process the rsyslog config template and echo to the conf file. |
523 | p, err := t.Parse(slConfig.configTemplate) |
524 | |
525 | === modified file 'log/syslog/config_test.go' |
526 | --- log/syslog/config_test.go 2013-09-13 14:48:13 +0000 |
527 | +++ log/syslog/config_test.go 2013-11-25 03:52:41 +0000 |
528 | @@ -52,7 +52,7 @@ |
529 | $InputRunFileMonitor |
530 | |
531 | $ModLoad imudp |
532 | -$UDPServerRun 514 |
533 | +$UDPServerRun 8888 |
534 | |
535 | # Messages received from remote rsyslog machines contain a leading space so we |
536 | # need to account for that. |
537 | @@ -66,12 +66,12 @@ |
538 | ` |
539 | |
540 | func (s *SyslogConfigSuite) TestAccumulateConfigRender(c *gc.C) { |
541 | - syslogConfigRenderer := syslog.NewAccumulateConfig("some-machine") |
542 | + syslogConfigRenderer := syslog.NewAccumulateConfig("some-machine", 8888) |
543 | s.assertRsyslogConfigContents(c, syslogConfigRenderer, expectedAccumulateSyslogConf) |
544 | } |
545 | |
546 | func (s *SyslogConfigSuite) TestAccumulateConfigWrite(c *gc.C) { |
547 | - syslogConfigRenderer := syslog.NewAccumulateConfig("some-machine") |
548 | + syslogConfigRenderer := syslog.NewAccumulateConfig("some-machine", 8888) |
549 | syslogConfigRenderer.ConfigDir = s.configDir |
550 | syslogConfigRenderer.ConfigFileName = "rsyslog.conf" |
551 | s.assertRsyslogConfigPath(c, syslogConfigRenderer) |
552 | @@ -93,17 +93,17 @@ |
553 | $InputFileStateFile some-machine |
554 | $InputRunFileMonitor |
555 | |
556 | -:syslogtag, startswith, "juju-" @server:514 |
557 | +:syslogtag, startswith, "juju-" @server:999 |
558 | & ~ |
559 | ` |
560 | |
561 | func (s *SyslogConfigSuite) TestForwardConfigRender(c *gc.C) { |
562 | - syslogConfigRenderer := syslog.NewForwardConfig("some-machine", []string{"server"}) |
563 | + syslogConfigRenderer := syslog.NewForwardConfig("some-machine", 999, []string{"server"}) |
564 | s.assertRsyslogConfigContents(c, syslogConfigRenderer, expectedForwardSyslogConf) |
565 | } |
566 | |
567 | func (s *SyslogConfigSuite) TestForwardConfigWrite(c *gc.C) { |
568 | - syslogConfigRenderer := syslog.NewForwardConfig("some-machine", []string{"server"}) |
569 | + syslogConfigRenderer := syslog.NewForwardConfig("some-machine", 999, []string{"server"}) |
570 | syslogConfigRenderer.ConfigDir = s.configDir |
571 | syslogConfigRenderer.ConfigFileName = "rsyslog.conf" |
572 | s.assertRsyslogConfigPath(c, syslogConfigRenderer) |
573 | |
574 | === modified file 'provider/azure/customdata_test.go' |
575 | --- provider/azure/customdata_test.go 2013-09-20 02:33:04 +0000 |
576 | +++ provider/azure/customdata_test.go 2013-11-25 03:52:41 +0000 |
577 | @@ -44,6 +44,7 @@ |
578 | Addrs: []string{"127.0.0.1:123"}, |
579 | Tag: names.MachineTag(machineID), |
580 | }, |
581 | + SyslogPort: 2345, |
582 | } |
583 | } |
584 | |
585 | |
586 | === modified file 'provider/dummy/environs.go' |
587 | --- provider/dummy/environs.go 2013-11-18 05:41:36 +0000 |
588 | +++ provider/dummy/environs.go 2013-11-25 03:52:41 +0000 |
589 | @@ -74,6 +74,7 @@ |
590 | "development": false, |
591 | "state-port": 1234, |
592 | "api-port": 4321, |
593 | + "syslog-port": 2345, |
594 | "default-series": "precise", |
595 | |
596 | "secret": "pork", |
597 | |
598 | === modified file 'state/address.go' |
599 | --- state/address.go 2013-10-14 17:44:23 +0000 |
600 | +++ state/address.go 2013-11-25 03:52:41 +0000 |
601 | @@ -110,3 +110,27 @@ |
602 | } |
603 | return appendPort(addrs, config.APIPort()), nil |
604 | } |
605 | + |
606 | +type DeployerConnectionValues struct { |
607 | + StateAddresses []string |
608 | + APIAddresses []string |
609 | + SyslogPort int |
610 | +} |
611 | + |
612 | +// DeployerConnectionInfo returns the address information necessary for the deployer. |
613 | +// The function does the expensive operations (getting stuff from mongo) just once. |
614 | +func (st *State) DeployerConnectionInfo() (*DeployerConnectionValues, error) { |
615 | + addrs, err := st.stateServerAddresses() |
616 | + if err != nil { |
617 | + return nil, err |
618 | + } |
619 | + config, err := st.EnvironConfig() |
620 | + if err != nil { |
621 | + return nil, err |
622 | + } |
623 | + return &DeployerConnectionValues{ |
624 | + StateAddresses: appendPort(addrs, config.StatePort()), |
625 | + APIAddresses: appendPort(addrs, config.APIPort()), |
626 | + SyslogPort: config.SyslogPort(), |
627 | + }, nil |
628 | +} |
629 | |
630 | === modified file 'state/api/deployer/deployer.go' |
631 | --- state/api/deployer/deployer.go 2013-07-24 13:15:52 +0000 |
632 | +++ state/api/deployer/deployer.go 2013-11-25 03:52:41 +0000 |
633 | @@ -90,3 +90,10 @@ |
634 | } |
635 | return result.Result, nil |
636 | } |
637 | + |
638 | +// ConnectionInfo returns all the address information that the deployer task |
639 | +// needs in one call. |
640 | +func (st *State) ConnectionInfo() (result params.DeployerConnectionValues, err error) { |
641 | + err = st.caller.Call("Deployer", "", "ConnectionInfo", nil, &result) |
642 | + return result, err |
643 | +} |
644 | |
645 | === modified file 'state/api/params/params.go' |
646 | --- state/api/params/params.go 2013-11-21 14:43:12 +0000 |
647 | +++ state/api/params/params.go 2013-11-25 03:52:41 +0000 |
648 | @@ -479,6 +479,7 @@ |
649 | ProviderType string |
650 | AuthorizedKeys string |
651 | SSLHostnameVerification bool |
652 | + SyslogPort int |
653 | } |
654 | |
655 | type MachineConfigParams struct { |
656 | @@ -517,3 +518,11 @@ |
657 | type SetEnvironAgentVersion struct { |
658 | Version version.Number |
659 | } |
660 | + |
661 | +// DeployerConnectionValues containers the result of deployer.ConnectionInfo |
662 | +// API call. |
663 | +type DeployerConnectionValues struct { |
664 | + StateAddresses []string |
665 | + APIAddresses []string |
666 | + SyslogPort int |
667 | +} |
668 | |
669 | === modified file 'state/api/provisioner/provisioner_test.go' |
670 | --- state/api/provisioner/provisioner_test.go 2013-11-19 02:14:38 +0000 |
671 | +++ state/api/provisioner/provisioner_test.go 2013-11-25 03:52:41 +0000 |
672 | @@ -377,6 +377,7 @@ |
673 | c.Assert(result.ProviderType, gc.Equals, "dummy") |
674 | c.Assert(result.AuthorizedKeys, gc.Equals, "my-keys") |
675 | c.Assert(result.SSLHostnameVerification, jc.IsTrue) |
676 | + c.Assert(result.SyslogPort, gc.Equals, 2345) |
677 | } |
678 | |
679 | func (s *provisionerSuite) TestCACert(c *gc.C) { |
680 | |
681 | === modified file 'state/apiserver/deployer/deployer.go' |
682 | --- state/apiserver/deployer/deployer.go 2013-11-01 21:06:12 +0000 |
683 | +++ state/apiserver/deployer/deployer.go 2013-11-25 03:52:41 +0000 |
684 | @@ -122,3 +122,17 @@ |
685 | } |
686 | return result, nil |
687 | } |
688 | + |
689 | +// ServerAddresses returns all the address information that the deployer task |
690 | +// needs in one call. |
691 | +func (d *DeployerAPI) ConnectionInfo() (result params.DeployerConnectionValues, err error) { |
692 | + info, err := d.st.DeployerConnectionInfo() |
693 | + if info != nil { |
694 | + result = params.DeployerConnectionValues{ |
695 | + StateAddresses: info.StateAddresses, |
696 | + APIAddresses: info.APIAddresses, |
697 | + SyslogPort: info.SyslogPort, |
698 | + } |
699 | + } |
700 | + return result, err |
701 | +} |
702 | |
703 | === modified file 'state/apiserver/provisioner/provisioner.go' |
704 | --- state/apiserver/provisioner/provisioner.go 2013-11-22 03:08:44 +0000 |
705 | +++ state/apiserver/provisioner/provisioner.go 2013-11-25 03:52:41 +0000 |
706 | @@ -224,6 +224,7 @@ |
707 | result.ProviderType = config.Type() |
708 | result.AuthorizedKeys = config.AuthorizedKeys() |
709 | result.SSLHostnameVerification = config.SSLHostnameVerification() |
710 | + result.SyslogPort = config.SyslogPort() |
711 | return result, nil |
712 | } |
713 | |
714 | |
715 | === modified file 'state/apiserver/provisioner/provisioner_test.go' |
716 | --- state/apiserver/provisioner/provisioner_test.go 2013-11-22 03:08:44 +0000 |
717 | +++ state/apiserver/provisioner/provisioner_test.go 2013-11-25 03:52:41 +0000 |
718 | @@ -698,6 +698,7 @@ |
719 | c.Check(results.ProviderType, gc.Equals, "dummy") |
720 | c.Check(results.AuthorizedKeys, gc.Equals, "my-keys") |
721 | c.Check(results.SSLHostnameVerification, jc.IsTrue) |
722 | + c.Check(results.SyslogPort, gc.Equals, 2345) |
723 | } |
724 | |
725 | func (s *provisionerSuite) TestToolsRefusesWrongAgent(c *gc.C) { |
726 | |
727 | === removed file 'worker/deployer/addresser.go' |
728 | --- worker/deployer/addresser.go 2013-07-25 11:03:16 +0000 |
729 | +++ worker/deployer/addresser.go 1970-01-01 00:00:00 +0000 |
730 | @@ -1,11 +0,0 @@ |
731 | -// Copyright 2013 Canonical Ltd. |
732 | -// Licensed under the AGPLv3, see LICENCE file for details. |
733 | - |
734 | -package deployer |
735 | - |
736 | -// Addresser implementations provide the capability to lookup a list |
737 | -// of server addresses. |
738 | -type Addresser interface { |
739 | - StateAddresses() ([]string, error) |
740 | - APIAddresses() ([]string, error) |
741 | -} |
742 | |
743 | === modified file 'worker/deployer/export_test.go' |
744 | --- worker/deployer/export_test.go 2013-09-02 06:03:14 +0000 |
745 | +++ worker/deployer/export_test.go 2013-11-25 03:52:41 +0000 |
746 | @@ -5,21 +5,22 @@ |
747 | |
748 | import ( |
749 | "launchpad.net/juju-core/agent" |
750 | + "launchpad.net/juju-core/state/api/params" |
751 | ) |
752 | |
753 | -type fakeAddresser struct{} |
754 | - |
755 | -func (*fakeAddresser) StateAddresses() ([]string, error) { |
756 | - return []string{"s1:123", "s2:123"}, nil |
757 | -} |
758 | - |
759 | -func (*fakeAddresser) APIAddresses() ([]string, error) { |
760 | - return []string{"a1:123", "a2:123"}, nil |
761 | +type fakeAPI struct{} |
762 | + |
763 | +func (*fakeAPI) ConnectionInfo() (params.DeployerConnectionValues, error) { |
764 | + return params.DeployerConnectionValues{ |
765 | + []string{"s1:123", "s2:123"}, |
766 | + []string{"a1:123", "a2:123"}, |
767 | + 2345, |
768 | + }, nil |
769 | } |
770 | |
771 | func NewTestSimpleContext(agentConfig agent.Config, initDir, logDir, syslogConfigDir string) *SimpleContext { |
772 | return &SimpleContext{ |
773 | - addresser: &fakeAddresser{}, |
774 | + api: &fakeAPI{}, |
775 | agentConfig: agentConfig, |
776 | initDir: initDir, |
777 | logDir: logDir, |
778 | |
779 | === modified file 'worker/deployer/simple.go' |
780 | --- worker/deployer/simple.go 2013-09-02 22:15:48 +0000 |
781 | +++ worker/deployer/simple.go 2013-11-25 03:52:41 +0000 |
782 | @@ -16,17 +16,23 @@ |
783 | "launchpad.net/juju-core/juju/osenv" |
784 | "launchpad.net/juju-core/log/syslog" |
785 | "launchpad.net/juju-core/names" |
786 | + "launchpad.net/juju-core/state/api/params" |
787 | "launchpad.net/juju-core/upstart" |
788 | "launchpad.net/juju-core/version" |
789 | ) |
790 | |
791 | +// APICalls defines the interface to the API that the simple context needs. |
792 | +type APICalls interface { |
793 | + ConnectionInfo() (params.DeployerConnectionValues, error) |
794 | +} |
795 | + |
796 | // SimpleContext is a Context that manages unit deployments via upstart |
797 | // jobs on the local system. |
798 | type SimpleContext struct { |
799 | |
800 | - // addresser is used to get the current state server addresses at the time |
801 | - // the given unit is deployed. |
802 | - addresser Addresser |
803 | + // api is used to get the current state server addresses at the time the |
804 | + // given unit is deployed. |
805 | + api APICalls |
806 | |
807 | // agentConfig returns the agent config for the machine agent that is |
808 | // running the deployer. |
809 | @@ -55,9 +61,9 @@ |
810 | // specified deployer, that deploys unit agents as upstart jobs in |
811 | // "/etc/init" logging to "/var/log/juju". Paths to which agents and tools |
812 | // are installed are relative to dataDir. |
813 | -func NewSimpleContext(agentConfig agent.Config, addresser Addresser) *SimpleContext { |
814 | +func NewSimpleContext(agentConfig agent.Config, api APICalls) *SimpleContext { |
815 | return &SimpleContext{ |
816 | - addresser: addresser, |
817 | + api: api, |
818 | agentConfig: agentConfig, |
819 | initDir: "/etc/init", |
820 | logDir: "/var/log/juju", |
821 | @@ -82,27 +88,22 @@ |
822 | toolsDir := tools.ToolsDir(dataDir, tag) |
823 | defer removeOnErr(&err, toolsDir) |
824 | |
825 | - // Retrieve the state addresses. |
826 | - // TODO: remove the state addresses when unit agent is API only. |
827 | - stateAddrs, err := ctx.addresser.StateAddresses() |
828 | - if err != nil { |
829 | - return err |
830 | - } |
831 | - logger.Debugf("state addresses: %q", stateAddrs) |
832 | - apiAddrs, err := ctx.addresser.APIAddresses() |
833 | - if err != nil { |
834 | - return err |
835 | - } |
836 | - logger.Debugf("API addresses: %q", apiAddrs) |
837 | + result, err := ctx.api.ConnectionInfo() |
838 | + if err != nil { |
839 | + return err |
840 | + } |
841 | + logger.Debugf("state addresses: %q", result.StateAddresses) |
842 | + logger.Debugf("API addresses: %q", result.APIAddresses) |
843 | containerType := ctx.agentConfig.Value(agent.ContainerType) |
844 | conf, err := agent.NewAgentConfig( |
845 | agent.AgentConfigParams{ |
846 | - DataDir: dataDir, |
847 | - Tag: tag, |
848 | - Password: initialPassword, |
849 | - Nonce: "unused", |
850 | - StateAddresses: stateAddrs, |
851 | - APIAddresses: apiAddrs, |
852 | + DataDir: dataDir, |
853 | + Tag: tag, |
854 | + Password: initialPassword, |
855 | + Nonce: "unused", |
856 | + // TODO: remove the state addresses here and test when api only. |
857 | + StateAddresses: result.StateAddresses, |
858 | + APIAddresses: result.APIAddresses, |
859 | CACert: ctx.agentConfig.CACert(), |
860 | Values: map[string]string{ |
861 | agent.ContainerType: containerType, |
862 | @@ -118,7 +119,7 @@ |
863 | |
864 | // Install an upstart job that runs the unit agent. |
865 | logPath := path.Join(ctx.logDir, tag+".log") |
866 | - syslogConfigRenderer := syslog.NewForwardConfig(tag, stateAddrs) |
867 | + syslogConfigRenderer := syslog.NewForwardConfig(tag, result.SyslogPort, result.StateAddresses) |
868 | syslogConfigRenderer.ConfigDir = ctx.syslogConfigDir |
869 | syslogConfigRenderer.ConfigFileName = fmt.Sprintf("26-juju-%s.conf", tag) |
870 | if err := syslogConfigRenderer.Write(); err != nil { |
871 | |
872 | === modified file 'worker/deployer/simple_test.go' |
873 | --- worker/deployer/simple_test.go 2013-10-21 21:49:04 +0000 |
874 | +++ worker/deployer/simple_test.go 2013-11-25 03:52:41 +0000 |
875 | @@ -218,7 +218,7 @@ |
876 | $InputFileStateFile %s |
877 | $InputRunFileMonitor |
878 | |
879 | -:syslogtag, startswith, "juju-" @s1:514 |
880 | +:syslogtag, startswith, "juju-" @s1:2345 |
881 | & ~ |
882 | ` |
883 | |
884 | |
885 | === modified file 'worker/provisioner/lxc-broker.go' |
886 | --- worker/provisioner/lxc-broker.go 2013-11-11 21:38:30 +0000 |
887 | +++ worker/provisioner/lxc-broker.go 2013-11-25 03:52:41 +0000 |
888 | @@ -74,6 +74,7 @@ |
889 | config.ProviderType, |
890 | config.AuthorizedKeys, |
891 | config.SSLHostnameVerification, |
892 | + config.SyslogPort, |
893 | ); err != nil { |
894 | lxcLogger.Errorf("failed to populate machine config: %v", err) |
895 | return nil, nil, err |
896 | |
897 | === modified file 'worker/provisioner/lxc-broker_test.go' |
898 | --- worker/provisioner/lxc-broker_test.go 2013-11-20 04:49:01 +0000 |
899 | +++ worker/provisioner/lxc-broker_test.go 2013-11-25 03:52:41 +0000 |
900 | @@ -284,5 +284,5 @@ |
901 | type fakeAPI struct{} |
902 | |
903 | func (*fakeAPI) ContainerConfig() (params.ContainerConfig, error) { |
904 | - return params.ContainerConfig{"fake", "my-keys", true}, nil |
905 | + return params.ContainerConfig{"fake", "my-keys", true, 2345}, nil |
906 | } |
Reviewers: mp+196046_ code.launchpad. net,
Message:
Please take a look.
Description:
Make the syslog udp port configurable.
Instead of having the syslog port hard-coded to 514 it makes
sense to make this configurable.
Any existing config that doesn't specify one will get the default,
which is 514.
This config port is passed through the cloud init machine config
structure so the syslog config that is written out forwards to the
correct port. This syslog port is needed, so a number of tests had
to be updated to make this work.
The (rather generic) 'suite' test in environs/ config_ test was updated
to use the LoggingSuite base to silence the logging that was leaked
out when running just the package tests.
The port number is now a template param in the rsyslog config.
The only other place where this was needed was with the deployer.
It was making multiple calls to get the state and api addresses.
Instead of adding another call, we now make one call to the api
to get the address information we need.
https:/ /code.launchpad .net/~thumper/ juju-core/ make-syslog- port-configurab le/+merge/ 196046
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/29990045/