Merge lp:~thumper/juju-core/make-syslog-port-configurable into lp:~go-bot/juju-core/trunk

Proposed by Tim Penhey
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
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/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://codereview.appspot.com/29990045/

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/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://codereview.appspot.com/29990045/

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

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-configurable/+merge/196046

(do not edit description out of merge proposal)

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

Revision history for this message
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://codereview.appspot.com/29990045/diff/1/log/syslog/config.go
File log/syslog/config.go (right):

https://codereview.appspot.com/29990045/diff/1/log/syslog/config.go#newcode135
log/syslog/config.go:135:
fmt.Sprint(slConfig.Port)

https://codereview.appspot.com/29990045/diff/1/state/address.go
File state/address.go (right):

https://codereview.appspot.com/29990045/diff/1/state/address.go#newcode125
state/address.go:125:
Difficult to parse, IMHO. I'd prefer
     stateAddresses = appendPort(addrs, config.StatePort())
     apiAddresses = appendPort(addrs, config.APIPort())
     return stateAddresses, apiAddresses, config.SyslogPort(), nil

https://codereview.appspot.com/29990045/diff/1/state/api/params/params.go
File state/api/params/params.go (right):

https://codereview.appspot.com/29990045/diff/1/state/api/params/params.go#newcode526
state/api/params/params.go:526:
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://codereview.appspot.com/29990045/diff/1/worker/deployer/addresser.go
File worker/deployer/addresser.go (right):

https://codereview.appspot.com/29990045/diff/1/worker/deployer/addresser.go#newcode15
worker/deployer/addresser.go:15:
This seems like the wrong place to be talking about the API. This should
just be about domain objects, I think.

https://codereview.appspot.com/29990045/

Revision history for this message
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://codereview.appspot.com/29990045/diff/1/state/address.go
File state/address.go (right):

https://codereview.appspot.com/29990045/diff/1/state/address.go#newcode116
state/address.go:116:
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 DeployerConnectionInfo

I also think it may be worth naming this method to be the same as the
one on state, which is currently ServerAddresses().

https://codereview.appspot.com/29990045/diff/1/worker/deployer/addresser.go
File worker/deployer/addresser.go (right):

https://codereview.appspot.com/29990045/diff/1/worker/deployer/addresser.go#newcode15
worker/deployer/addresser.go:15:
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.ServerAddressesResults does not belong here. No api params
structs should escape the api infrastructure

https://codereview.appspot.com/29990045/

Revision history for this message
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://codereview.appspot.com/29990045/diff/1/log/syslog/config.go
File log/syslog/config.go (right):

https://codereview.appspot.com/29990045/diff/1/log/syslog/config.go#newcode135
log/syslog/config.go:135:
On 2013/11/21 05:17:42, axw wrote:
> fmt.Sprint(slConfig.Port)

Done.

https://codereview.appspot.com/29990045/diff/1/state/address.go
File state/address.go (right):

https://codereview.appspot.com/29990045/diff/1/state/address.go#newcode116
state/address.go:116:
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 DeployerConnectionInfo

> 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://codereview.appspot.com/29990045/diff/1/state/address.go#newcode125
state/address.go:125:
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.SyslogPort(), nil

Now this returns a struct, it is more obvious.

https://codereview.appspot.com/29990045/diff/1/state/api/params/params.go
File state/api/params/params.go (right):

https://codereview.appspot.com/29990045/diff/1/state/api/params/params.go#newcode526
state/api/params/params.go:526:
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://codereview.appspot.com/29990045/diff/1/worker/deployer/addresser.go
File worker/deployer/addresser.go (right):

https://codereview.appspot.com/29990045/diff/1/worker/deployer/addresser.go#newcode15
worker/deployer/addresser.go:15:
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.ServerAddressesResults does not belong here. No api 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.

https://codereview.appspot.com/29990045/

Revision history for this message
Ian Booth (wallyworld) wrote :

https://codereview.appspot.com/29990045/diff/1/worker/deployer/addresser.go
> File worker/deployer/addresser.go (right):

https://codereview.appspot.com/29990045/diff/1/worker/deployer/addresser.go#newcode15
> worker/deployer/addresser.go:15:
> 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.ServerAddressesResults does not belong here. No api 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

https://codereview.appspot.com/29990045/

Revision history for this message
Ian Booth (wallyworld) wrote :

https://codereview.appspot.com/29990045/diff/1/worker/deployer/addresser.go
> File worker/deployer/addresser.go (right):

https://codereview.appspot.com/29990045/diff/1/worker/deployer/addresser.go#newcode15
> worker/deployer/addresser.go:15:
> 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.ServerAddressesResults does not belong here. No api 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

https://codereview.appspot.com/29990045/

Revision history for this message
Tim Penhey (thumper) wrote :
Revision history for this message
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.

https://codereview.appspot.com/29990045/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'container/lxc/lxc_test.go'
--- container/lxc/lxc_test.go 2013-11-11 21:38:30 +0000
+++ container/lxc/lxc_test.go 2013-11-25 03:52:41 +0000
@@ -70,6 +70,7 @@
70 stateInfo := jujutesting.FakeStateInfo(machineId)70 stateInfo := jujutesting.FakeStateInfo(machineId)
71 apiInfo := jujutesting.FakeAPIInfo(machineId)71 apiInfo := jujutesting.FakeAPIInfo(machineId)
72 machineConfig := environs.NewMachineConfig(machineId, "fake-nonce", stateInfo, apiInfo)72 machineConfig := environs.NewMachineConfig(machineId, "fake-nonce", stateInfo, apiInfo)
73 machineConfig.SyslogPort = 2345
73 machineConfig.Tools = &tools.Tools{74 machineConfig.Tools = &tools.Tools{
74 Version: version.MustParseBinary("2.3.4-foo-bar"),75 Version: version.MustParseBinary("2.3.4-foo-bar"),
75 URL: "http://tools.testing.invalid/2.3.4-foo-bar.tgz",76 URL: "http://tools.testing.invalid/2.3.4-foo-bar.tgz",
7677
=== modified file 'environs/cloudinit.go'
--- environs/cloudinit.go 2013-11-15 10:08:11 +0000
+++ environs/cloudinit.go 2013-11-25 03:52:41 +0000
@@ -53,8 +53,9 @@
5353
54func PopulateMachineConfig(mcfg *cloudinit.MachineConfig,54func PopulateMachineConfig(mcfg *cloudinit.MachineConfig,
55 providerType, authorizedKeys string,55 providerType, authorizedKeys string,
56 sslHostnameVerification bool) error {56 sslHostnameVerification bool,
5757 syslogPort int,
58) error {
58 if authorizedKeys == "" {59 if authorizedKeys == "" {
59 return fmt.Errorf("environment configuration has no authorized-keys")60 return fmt.Errorf("environment configuration has no authorized-keys")
60 }61 }
@@ -65,6 +66,7 @@
65 mcfg.AgentEnvironment[agent.ProviderType] = providerType66 mcfg.AgentEnvironment[agent.ProviderType] = providerType
66 mcfg.AgentEnvironment[agent.ContainerType] = string(mcfg.MachineContainerType)67 mcfg.AgentEnvironment[agent.ContainerType] = string(mcfg.MachineContainerType)
67 mcfg.DisableSSLHostnameVerification = !sslHostnameVerification68 mcfg.DisableSSLHostnameVerification = !sslHostnameVerification
69 mcfg.SyslogPort = syslogPort
68 return nil70 return nil
69}71}
7072
@@ -81,7 +83,7 @@
81func FinishMachineConfig(mcfg *cloudinit.MachineConfig, cfg *config.Config, cons constraints.Value) (err error) {83func FinishMachineConfig(mcfg *cloudinit.MachineConfig, cfg *config.Config, cons constraints.Value) (err error) {
82 defer utils.ErrorContextf(&err, "cannot complete machine configuration")84 defer utils.ErrorContextf(&err, "cannot complete machine configuration")
8385
84 if err := PopulateMachineConfig(mcfg, cfg.Type(), cfg.AuthorizedKeys(), cfg.SSLHostnameVerification()); err != nil {86 if err := PopulateMachineConfig(mcfg, cfg.Type(), cfg.AuthorizedKeys(), cfg.SSLHostnameVerification(), cfg.SyslogPort()); err != nil {
85 return err87 return err
86 }88 }
8789
8890
=== modified file 'environs/cloudinit/cloudinit.go'
--- environs/cloudinit/cloudinit.go 2013-11-20 02:14:38 +0000
+++ environs/cloudinit/cloudinit.go 2013-11-25 03:52:41 +0000
@@ -58,6 +58,10 @@
58 // if StateServer is true.58 // if StateServer is true.
59 APIPort int59 APIPort int
6060
61 // SyslogPort specifies the port number that will be used when
62 // sending the log messages using rsyslog.
63 SyslogPort int
64
61 // StateInfo holds the means for the new instance to communicate with the65 // StateInfo holds the means for the new instance to communicate with the
62 // juju state. Unless the new machine is running a state server (StateServer is66 // juju state. Unless the new machine is running a state server (StateServer is
63 // set), there must be at least one state server address supplied.67 // set), there must be at least one state server address supplied.
@@ -246,10 +250,10 @@
246 var configRenderer syslog.SyslogConfigRenderer250 var configRenderer syslog.SyslogConfigRenderer
247 if cfg.StateServer {251 if cfg.StateServer {
248 configRenderer = syslog.NewAccumulateConfig(252 configRenderer = syslog.NewAccumulateConfig(
249 names.MachineTag(cfg.MachineId))253 names.MachineTag(cfg.MachineId), cfg.SyslogPort)
250 } else {254 } else {
251 configRenderer = syslog.NewForwardConfig(255 configRenderer = syslog.NewForwardConfig(
252 names.MachineTag(cfg.MachineId), cfg.stateHostAddrs())256 names.MachineTag(cfg.MachineId), cfg.SyslogPort, cfg.stateHostAddrs())
253 }257 }
254 content, err := configRenderer.Render()258 content, err := configRenderer.Render()
255 if err != nil {259 if err != nil {
@@ -500,6 +504,9 @@
500 if cfg.APIInfo == nil {504 if cfg.APIInfo == nil {
501 return fmt.Errorf("missing API info")505 return fmt.Errorf("missing API info")
502 }506 }
507 if cfg.SyslogPort == 0 {
508 return fmt.Errorf("missing syslog port")
509 }
503 if len(cfg.APIInfo.CACert) == 0 {510 if len(cfg.APIInfo.CACert) == 0 {
504 return fmt.Errorf("missing API CA certificate")511 return fmt.Errorf("missing API CA certificate")
505 }512 }
506513
=== modified file 'environs/cloudinit/cloudinit_test.go'
--- environs/cloudinit/cloudinit_test.go 2013-11-20 02:14:38 +0000
+++ environs/cloudinit/cloudinit_test.go 2013-11-25 03:52:41 +0000
@@ -71,6 +71,7 @@
71 StateServerKey: serverKey,71 StateServerKey: serverKey,
72 StatePort: 37017,72 StatePort: 37017,
73 APIPort: 17070,73 APIPort: 17070,
74 SyslogPort: 514,
74 MachineNonce: "FAKE_NONCE",75 MachineNonce: "FAKE_NONCE",
75 StateInfo: &state.Info{76 StateInfo: &state.Info{
76 Password: "arble",77 Password: "arble",
@@ -140,6 +141,7 @@
140 StateServerKey: serverKey,141 StateServerKey: serverKey,
141 StatePort: 37017,142 StatePort: 37017,
142 APIPort: 17070,143 APIPort: 17070,
144 SyslogPort: 514,
143 MachineNonce: "FAKE_NONCE",145 MachineNonce: "FAKE_NONCE",
144 StateInfo: &state.Info{146 StateInfo: &state.Info{
145 Password: "arble",147 Password: "arble",
@@ -188,6 +190,7 @@
188 Password: "bletch",190 Password: "bletch",
189 CACert: []byte("CA CERT\n" + testing.CACert),191 CACert: []byte("CA CERT\n" + testing.CACert),
190 },192 },
193 SyslogPort: 514,
191 },194 },
192 expectScripts: `195 expectScripts: `
193set -xe196set -xe
@@ -236,6 +239,7 @@
236 Password: "bletch",239 Password: "bletch",
237 CACert: []byte("CA CERT\n" + testing.CACert),240 CACert: []byte("CA CERT\n" + testing.CACert),
238 },241 },
242 SyslogPort: 514,
239 },243 },
240 inexactMatch: true,244 inexactMatch: true,
241 expectScripts: `245 expectScripts: `
@@ -272,6 +276,7 @@
272 Password: "bletch",276 Password: "bletch",
273 CACert: []byte("CA CERT\n" + testing.CACert),277 CACert: []byte("CA CERT\n" + testing.CACert),
274 },278 },
279 SyslogPort: 514,
275 DisableSSLHostnameVerification: true,280 DisableSSLHostnameVerification: true,
276 },281 },
277 inexactMatch: true,282 inexactMatch: true,
@@ -291,6 +296,7 @@
291 StateServerKey: serverKey,296 StateServerKey: serverKey,
292 StatePort: 37017,297 StatePort: 37017,
293 APIPort: 17070,298 APIPort: 17070,
299 SyslogPort: 514,
294 MachineNonce: "FAKE_NONCE",300 MachineNonce: "FAKE_NONCE",
295 StateInfo: &state.Info{301 StateInfo: &state.Info{
296 Password: "arble",302 Password: "arble",
@@ -581,6 +587,9 @@
581 {"missing API info", func(cfg *cloudinit.MachineConfig) {587 {"missing API info", func(cfg *cloudinit.MachineConfig) {
582 cfg.APIInfo = nil588 cfg.APIInfo = nil
583 }},589 }},
590 {"missing syslog port", func(cfg *cloudinit.MachineConfig) {
591 cfg.SyslogPort = 0
592 }},
584 {"missing state hosts", func(cfg *cloudinit.MachineConfig) {593 {"missing state hosts", func(cfg *cloudinit.MachineConfig) {
585 cfg.StateServer = false594 cfg.StateServer = false
586 cfg.StateInfo = &state.Info{595 cfg.StateInfo = &state.Info{
@@ -684,6 +693,7 @@
684 StateServerKey: serverKey,693 StateServerKey: serverKey,
685 StatePort: 1234,694 StatePort: 1234,
686 APIPort: 1235,695 APIPort: 1235,
696 SyslogPort: 2345,
687 MachineId: "99",697 MachineId: "99",
688 Tools: newSimpleTools("9.9.9-linux-arble"),698 Tools: newSimpleTools("9.9.9-linux-arble"),
689 AuthorizedKeys: "sshkey1",699 AuthorizedKeys: "sshkey1",
690700
=== modified file 'environs/cloudinit_test.go'
--- environs/cloudinit_test.go 2013-11-06 13:48:29 +0000
+++ environs/cloudinit_test.go 2013-11-25 03:52:41 +0000
@@ -62,13 +62,15 @@
62 StateInfo: &state.Info{Tag: "not touched"},62 StateInfo: &state.Info{Tag: "not touched"},
63 APIInfo: &api.Info{Tag: "not touched"},63 APIInfo: &api.Info{Tag: "not touched"},
64 DisableSSLHostnameVerification: false,64 DisableSSLHostnameVerification: false,
65 SyslogPort: 2345,
65 })66 })
66}67}
6768
68func (s *CloudInitSuite) TestFinishMachineConfigNoSSLVerification(c *gc.C) {69func (s *CloudInitSuite) TestFinishMachineConfigNonDefault(c *gc.C) {
69 attrs := dummySampleConfig().Merge(testing.Attrs{70 attrs := dummySampleConfig().Merge(testing.Attrs{
70 "authorized-keys": "we-are-the-keys",71 "authorized-keys": "we-are-the-keys",
71 "ssl-hostname-verification": false,72 "ssl-hostname-verification": false,
73 "syslog-port": 8888,
72 })74 })
73 cfg, err := config.New(config.NoDefaults, attrs)75 cfg, err := config.New(config.NoDefaults, attrs)
74 c.Assert(err, gc.IsNil)76 c.Assert(err, gc.IsNil)
@@ -87,6 +89,7 @@
87 StateInfo: &state.Info{Tag: "not touched"},89 StateInfo: &state.Info{Tag: "not touched"},
88 APIInfo: &api.Info{Tag: "not touched"},90 APIInfo: &api.Info{Tag: "not touched"},
89 DisableSSLHostnameVerification: true,91 DisableSSLHostnameVerification: true,
92 SyslogPort: 8888,
90 })93 })
91}94}
9295
@@ -164,6 +167,7 @@
164 Config: envConfig,167 Config: envConfig,
165 StatePort: envConfig.StatePort(),168 StatePort: envConfig.StatePort(),
166 APIPort: envConfig.APIPort(),169 APIPort: envConfig.APIPort(),
170 SyslogPort: envConfig.SyslogPort(),
167 StateServer: true,171 StateServer: true,
168 AgentEnvironment: map[string]string{agent.ProviderType: "dummy"},172 AgentEnvironment: map[string]string{agent.ProviderType: "dummy"},
169 }173 }
170174
=== modified file 'environs/config/config.go'
--- environs/config/config.go 2013-11-14 10:59:22 +0000
+++ environs/config/config.go 2013-11-25 03:52:41 +0000
@@ -38,6 +38,10 @@
3838
39 // DefaultApiPort is the default port the API server is listening on.39 // DefaultApiPort is the default port the API server is listening on.
40 DefaultAPIPort int = 1707040 DefaultAPIPort int = 17070
41
42 // DefaultSyslogPort is the default port that the syslog UDP listener is
43 // listening on.
44 DefaultSyslogPort int = 514
41)45)
4246
43// Config holds an immutable environment configuration.47// Config holds an immutable environment configuration.
@@ -382,6 +386,11 @@
382 return c.mustInt("api-port")386 return c.mustInt("api-port")
383}387}
384388
389// SyslogPort returns the syslog port for the environment.
390func (c *Config) SyslogPort() int {
391 return c.mustInt("syslog-port")
392}
393
385// AuthorizedKeys returns the content for ssh's authorized_keys file.394// AuthorizedKeys returns the content for ssh's authorized_keys file.
386func (c *Config) AuthorizedKeys() string {395func (c *Config) AuthorizedKeys() string {
387 return c.mustString("authorized-keys")396 return c.mustString("authorized-keys")
@@ -518,6 +527,7 @@
518 "ssl-hostname-verification": schema.Bool(),527 "ssl-hostname-verification": schema.Bool(),
519 "state-port": schema.ForceInt(),528 "state-port": schema.ForceInt(),
520 "api-port": schema.ForceInt(),529 "api-port": schema.ForceInt(),
530 "syslog-port": schema.ForceInt(),
521 "logging-config": schema.String(),531 "logging-config": schema.String(),
522532
523 // Deprecated fields, retain for backwards compatibility.533 // Deprecated fields, retain for backwards compatibility.
@@ -556,8 +566,9 @@
556566
557 // For backward compatibility only - default ports were567 // For backward compatibility only - default ports were
558 // not filled out in previous versions of the configuration.568 // not filled out in previous versions of the configuration.
559 "state-port": DefaultStatePort,569 "state-port": DefaultStatePort,
560 "api-port": DefaultAPIPort,570 "api-port": DefaultAPIPort,
571 "syslog-port": DefaultSyslogPort,
561}572}
562573
563func allowEmpty(attr string) bool {574func allowEmpty(attr string) bool {
@@ -574,6 +585,7 @@
574 "ssl-hostname-verification": true,585 "ssl-hostname-verification": true,
575 "state-port": DefaultStatePort,586 "state-port": DefaultStatePort,
576 "api-port": DefaultAPIPort,587 "api-port": DefaultAPIPort,
588 "syslog-port": DefaultSyslogPort,
577 }589 }
578 for attr, val := range alwaysOptional {590 for attr, val := range alwaysOptional {
579 d[attr] = val591 d[attr] = val
@@ -606,6 +618,7 @@
606 "firewall-mode",618 "firewall-mode",
607 "state-port",619 "state-port",
608 "api-port",620 "api-port",
621 "syslog-port",
609}622}
610623
611var (624var (
612625
=== modified file 'environs/config/config_test.go'
--- environs/config/config_test.go 2013-11-14 10:59:22 +0000
+++ environs/config/config_test.go 2013-11-25 03:52:41 +0000
@@ -52,6 +52,7 @@
52 "development": false,52 "development": false,
53 "state-port": 1234,53 "state-port": 1234,
54 "api-port": 4321,54 "api-port": 4321,
55 "syslog-port": 2345,
55 "default-series": "precise",56 "default-series": "precise",
56}57}
5758
@@ -453,6 +454,23 @@
453 },454 },
454 err: `api-port: expected number, got string\("illegal"\)`,455 err: `api-port: expected number, got string\("illegal"\)`,
455 }, {456 }, {
457 about: "Explicit syslog port",
458 useDefaults: config.UseDefaults,
459 attrs: testing.Attrs{
460 "type": "my-type",
461 "name": "my-name",
462 "syslog-port": 3456,
463 },
464 }, {
465 about: "Invalid syslog port",
466 useDefaults: config.UseDefaults,
467 attrs: testing.Attrs{
468 "type": "my-type",
469 "name": "my-name",
470 "syslog-port": "illegal",
471 },
472 err: `syslog-port: expected number, got string\("illegal"\)`,
473 }, {
456 about: "Invalid logging configuration",474 about: "Invalid logging configuration",
457 useDefaults: config.UseDefaults,475 useDefaults: config.UseDefaults,
458 attrs: testing.Attrs{476 attrs: testing.Attrs{
@@ -684,6 +702,9 @@
684 if apiPort, ok := test.attrs["api-port"]; ok {702 if apiPort, ok := test.attrs["api-port"]; ok {
685 c.Assert(cfg.APIPort(), gc.Equals, apiPort)703 c.Assert(cfg.APIPort(), gc.Equals, apiPort)
686 }704 }
705 if syslogPort, ok := test.attrs["syslog-port"]; ok {
706 c.Assert(cfg.SyslogPort(), gc.Equals, syslogPort)
707 }
687708
688 dev, _ := test.attrs["development"].(bool)709 dev, _ := test.attrs["development"].(bool)
689 c.Assert(cfg.Development(), gc.Equals, dev)710 c.Assert(cfg.Development(), gc.Equals, dev)
@@ -798,6 +819,7 @@
798 "development": false,819 "development": false,
799 "state-port": 1234,820 "state-port": 1234,
800 "api-port": 4321,821 "api-port": 4321,
822 "syslog-port": 2345,
801 "default-series": "precise",823 "default-series": "precise",
802 }824 }
803 cfg, err := config.New(config.NoDefaults, attrs)825 cfg, err := config.New(config.NoDefaults, attrs)
@@ -869,6 +891,11 @@
869 new: testing.Attrs{"api-port": 42},891 new: testing.Attrs{"api-port": 42},
870 err: `cannot change api-port from 17070 to 42`,892 err: `cannot change api-port from 17070 to 42`,
871}, {893}, {
894 about: "Cannot change the syslog-port",
895 old: testing.Attrs{"syslog-port": 345},
896 new: testing.Attrs{"syslog-port": 42},
897 err: `cannot change syslog-port from 345 to 42`,
898}, {
872 about: "Can change the state-port from explicit-default to implicit-default",899 about: "Can change the state-port from explicit-default to implicit-default",
873 old: testing.Attrs{"state-port": config.DefaultStatePort},900 old: testing.Attrs{"state-port": config.DefaultStatePort},
874}, {901}, {
@@ -888,6 +915,10 @@
888 about: "Cannot change the api-port from implicit-default to different value",915 about: "Cannot change the api-port from implicit-default to different value",
889 new: testing.Attrs{"api-port": 42},916 new: testing.Attrs{"api-port": 42},
890 err: `cannot change api-port from 17070 to 42`,917 err: `cannot change api-port from 17070 to 42`,
918}, {
919 about: "Cannot change the syslog-port from implicit-default to different value",
920 new: testing.Attrs{"syslog-port": 42},
921 err: `cannot change syslog-port from 514 to 42`,
891}}922}}
892923
893func (*ConfigSuite) TestValidateChange(c *gc.C) {924func (*ConfigSuite) TestValidateChange(c *gc.C) {
894925
=== modified file 'environs/config_test.go'
--- environs/config_test.go 2013-11-13 08:15:10 +0000
+++ environs/config_test.go 2013-11-25 03:52:41 +0000
@@ -16,14 +16,18 @@
16 "launchpad.net/juju-core/provider/dummy"16 "launchpad.net/juju-core/provider/dummy"
17 "launchpad.net/juju-core/testing"17 "launchpad.net/juju-core/testing"
18 jc "launchpad.net/juju-core/testing/checkers"18 jc "launchpad.net/juju-core/testing/checkers"
19 "launchpad.net/juju-core/testing/testbase"
19)20)
2021
21type suite struct{}22type suite struct {
2223 testbase.LoggingSuite
23var _ = gc.Suite(suite{})24}
2425
25func (suite) TearDownTest(c *gc.C) {26var _ = gc.Suite(&suite{})
27
28func (s *suite) TearDownTest(c *gc.C) {
26 dummy.Reset()29 dummy.Reset()
30 s.LoggingSuite.TearDownTest(c)
27}31}
2832
29var invalidConfigTests = []struct {33var invalidConfigTests = []struct {
@@ -40,7 +44,7 @@
40 },44 },
41}45}
4246
43func (suite) TestInvalidConfig(c *gc.C) {47func (*suite) TestInvalidConfig(c *gc.C) {
44 for i, t := range invalidConfigTests {48 for i, t := range invalidConfigTests {
45 c.Logf("running test %v", i)49 c.Logf("running test %v", i)
46 _, err := environs.ReadEnvironsBytes([]byte(t.env))50 _, err := environs.ReadEnvironsBytes([]byte(t.env))
@@ -72,7 +76,7 @@
72 },76 },
73}77}
7478
75func (suite) TestInvalidEnv(c *gc.C) {79func (*suite) TestInvalidEnv(c *gc.C) {
76 defer testing.MakeFakeHomeNoEnvironments(c, "only").Restore()80 defer testing.MakeFakeHomeNoEnvironments(c, "only").Restore()
77 for i, t := range invalidEnvTests {81 for i, t := range invalidEnvTests {
78 c.Logf("running test %v", i)82 c.Logf("running test %v", i)
@@ -84,7 +88,7 @@
84 }88 }
85}89}
8690
87func (suite) TestNoWarningForDeprecatedButUnusedEnv(c *gc.C) {91func (*suite) TestNoWarningForDeprecatedButUnusedEnv(c *gc.C) {
88 // This tests that a config that has a deprecated field doesn't92 // This tests that a config that has a deprecated field doesn't
89 // generate a Warning if we don't actually ask for that environment.93 // generate a Warning if we don't actually ask for that environment.
90 // However, we can only really trigger that when we have a deprecated94 // However, we can only really trigger that when we have a deprecated
@@ -124,7 +128,7 @@
124 c.Check(tw.Log, gc.HasLen, 1)128 c.Check(tw.Log, gc.HasLen, 1)
125}129}
126130
127func (suite) TestNoHomeBeforeConfig(c *gc.C) {131func (*suite) TestNoHomeBeforeConfig(c *gc.C) {
128 // Test that we don't actually need HOME set until we call envs.Config()132 // Test that we don't actually need HOME set until we call envs.Config()
129 // Because of this, we intentionally do *not* call testing.MakeFakeHomeNoEnvironments()133 // Because of this, we intentionally do *not* call testing.MakeFakeHomeNoEnvironments()
130 content := `134 content := `
@@ -138,7 +142,7 @@
138 c.Check(err, gc.IsNil)142 c.Check(err, gc.IsNil)
139}143}
140144
141func (suite) TestNoEnv(c *gc.C) {145func (*suite) TestNoEnv(c *gc.C) {
142 defer testing.MakeFakeHomeNoEnvironments(c).Restore()146 defer testing.MakeFakeHomeNoEnvironments(c).Restore()
143 es, err := environs.ReadEnvirons("")147 es, err := environs.ReadEnvirons("")
144 c.Assert(es, gc.IsNil)148 c.Assert(es, gc.IsNil)
@@ -189,7 +193,7 @@
189 }},193 }},
190}194}
191195
192func (suite) TestConfig(c *gc.C) {196func (*suite) TestConfig(c *gc.C) {
193 defer testing.MakeFakeHomeNoEnvironments(c, "only", "valid", "one", "two").Restore()197 defer testing.MakeFakeHomeNoEnvironments(c, "only", "valid", "one", "two").Restore()
194 for i, t := range configTests {198 for i, t := range configTests {
195 c.Logf("running test %v", i)199 c.Logf("running test %v", i)
@@ -199,7 +203,7 @@
199 }203 }
200}204}
201205
202func (suite) TestDefaultConfigFile(c *gc.C) {206func (*suite) TestDefaultConfigFile(c *gc.C) {
203 defer testing.MakeEmptyFakeHome(c).Restore()207 defer testing.MakeEmptyFakeHome(c).Restore()
204208
205 env := `209 env := `
@@ -221,7 +225,7 @@
221 c.Assert(cfg.Name(), gc.Equals, "only")225 c.Assert(cfg.Name(), gc.Equals, "only")
222}226}
223227
224func (suite) TestConfigPerm(c *gc.C) {228func (*suite) TestConfigPerm(c *gc.C) {
225 defer testing.MakeSampleHome(c).Restore()229 defer testing.MakeSampleHome(c).Restore()
226230
227 path := testing.HomePath(".juju")231 path := testing.HomePath(".juju")
@@ -248,7 +252,7 @@
248252
249}253}
250254
251func (suite) TestNamedConfigFile(c *gc.C) {255func (*suite) TestNamedConfigFile(c *gc.C) {
252 defer testing.MakeFakeHomeNoEnvironments(c, "only").Restore()256 defer testing.MakeFakeHomeNoEnvironments(c, "only").Restore()
253257
254 env := `258 env := `
@@ -275,7 +279,7 @@
275 return ok279 return ok
276}280}
277281
278func (suite) TestBootstrapConfig(c *gc.C) {282func (*suite) TestBootstrapConfig(c *gc.C) {
279 defer testing.MakeFakeHomeNoEnvironments(c, "bladaam").Restore()283 defer testing.MakeFakeHomeNoEnvironments(c, "bladaam").Restore()
280 attrs := dummySampleConfig().Merge(testing.Attrs{284 attrs := dummySampleConfig().Merge(testing.Attrs{
281 "agent-version": "1.2.3",285 "agent-version": "1.2.3",
282286
=== modified file 'log/syslog/config.go'
--- log/syslog/config.go 2013-08-19 03:03:46 +0000
+++ log/syslog/config.go 2013-11-25 03:52:41 +0000
@@ -26,7 +26,7 @@
26$InputRunFileMonitor26$InputRunFileMonitor
2727
28$ModLoad imudp28$ModLoad imudp
29$UDPServerRun 51429$UDPServerRun {{portNumber}}
3030
31# Messages received from remote rsyslog machines contain a leading space so we31# Messages received from remote rsyslog machines contain a leading space so we
32# need to account for that.32# need to account for that.
@@ -52,7 +52,7 @@
52$InputFileStateFile {{logfileName}}52$InputFileStateFile {{logfileName}}
53$InputRunFileMonitor53$InputRunFileMonitor
5454
55:syslogtag, startswith, "juju-" @{{bootstrapIP}}:51455:syslogtag, startswith, "juju-" @{{bootstrapIP}}:{{portNumber}}
56& ~56& ~
57`57`
5858
@@ -77,24 +77,28 @@
77 LogFileName string77 LogFileName string
78 // the addresses of the state server to which messages should be forwarded.78 // the addresses of the state server to which messages should be forwarded.
79 StateServerAddresses []string79 StateServerAddresses []string
80 // the port number for the udp listener
81 Port int
80}82}
8183
82// NewForwardConfig creates a SyslogConfig instance used on unit nodes to forward log entries84// NewForwardConfig creates a SyslogConfig instance used on unit nodes to forward log entries
83// to the state server nodes.85// to the state server nodes.
84func NewForwardConfig(logFile string, stateServerAddresses []string) *SyslogConfig {86func NewForwardConfig(logFile string, port int, stateServerAddresses []string) *SyslogConfig {
85 return &SyslogConfig{87 return &SyslogConfig{
86 configTemplate: nodeRsyslogTemplate,88 configTemplate: nodeRsyslogTemplate,
87 StateServerAddresses: stateServerAddresses,89 StateServerAddresses: stateServerAddresses,
88 LogFileName: logFile,90 LogFileName: logFile,
91 Port: port,
89 }92 }
90}93}
9194
92// NewAccumulateConfig creates a SyslogConfig instance used to accumulate log entries from the95// NewAccumulateConfig creates a SyslogConfig instance used to accumulate log entries from the
93// various unit nodes.96// various unit nodes.
94func NewAccumulateConfig(logFile string) *SyslogConfig {97func NewAccumulateConfig(logFile string, port int) *SyslogConfig {
95 return &SyslogConfig{98 return &SyslogConfig{
96 configTemplate: stateServerRsyslogTemplate,99 configTemplate: stateServerRsyslogTemplate,
97 LogFileName: logFile,100 LogFileName: logFile,
101 Port: port,
98 }102 }
99}103}
100104
@@ -127,11 +131,18 @@
127 return fmt.Sprintf("/var/spool/rsyslog/juju-%s-state", slConfig.LogFileName)131 return fmt.Sprintf("/var/spool/rsyslog/juju-%s-state", slConfig.LogFileName)
128 }132 }
129133
134 var portNumber = func() string {
135 return fmt.Sprint(slConfig.Port)
136 }
137
130 t := template.New("")138 t := template.New("")
131 t.Funcs(template.FuncMap{"logfileName": logFileName})139 t.Funcs(template.FuncMap{
132 t.Funcs(template.FuncMap{"bootstrapIP": bootstrapIP})140 "logfileName": logFileName,
133 t.Funcs(template.FuncMap{"logfilePath": logFilePath})141 "bootstrapIP": bootstrapIP,
134 t.Funcs(template.FuncMap{"statefilePath": stateFilePath})142 "logfilePath": logFilePath,
143 "statefilePath": stateFilePath,
144 "portNumber": portNumber,
145 })
135146
136 // Process the rsyslog config template and echo to the conf file.147 // Process the rsyslog config template and echo to the conf file.
137 p, err := t.Parse(slConfig.configTemplate)148 p, err := t.Parse(slConfig.configTemplate)
138149
=== modified file 'log/syslog/config_test.go'
--- log/syslog/config_test.go 2013-09-13 14:48:13 +0000
+++ log/syslog/config_test.go 2013-11-25 03:52:41 +0000
@@ -52,7 +52,7 @@
52$InputRunFileMonitor52$InputRunFileMonitor
5353
54$ModLoad imudp54$ModLoad imudp
55$UDPServerRun 51455$UDPServerRun 8888
5656
57# Messages received from remote rsyslog machines contain a leading space so we57# Messages received from remote rsyslog machines contain a leading space so we
58# need to account for that.58# need to account for that.
@@ -66,12 +66,12 @@
66`66`
6767
68func (s *SyslogConfigSuite) TestAccumulateConfigRender(c *gc.C) {68func (s *SyslogConfigSuite) TestAccumulateConfigRender(c *gc.C) {
69 syslogConfigRenderer := syslog.NewAccumulateConfig("some-machine")69 syslogConfigRenderer := syslog.NewAccumulateConfig("some-machine", 8888)
70 s.assertRsyslogConfigContents(c, syslogConfigRenderer, expectedAccumulateSyslogConf)70 s.assertRsyslogConfigContents(c, syslogConfigRenderer, expectedAccumulateSyslogConf)
71}71}
7272
73func (s *SyslogConfigSuite) TestAccumulateConfigWrite(c *gc.C) {73func (s *SyslogConfigSuite) TestAccumulateConfigWrite(c *gc.C) {
74 syslogConfigRenderer := syslog.NewAccumulateConfig("some-machine")74 syslogConfigRenderer := syslog.NewAccumulateConfig("some-machine", 8888)
75 syslogConfigRenderer.ConfigDir = s.configDir75 syslogConfigRenderer.ConfigDir = s.configDir
76 syslogConfigRenderer.ConfigFileName = "rsyslog.conf"76 syslogConfigRenderer.ConfigFileName = "rsyslog.conf"
77 s.assertRsyslogConfigPath(c, syslogConfigRenderer)77 s.assertRsyslogConfigPath(c, syslogConfigRenderer)
@@ -93,17 +93,17 @@
93$InputFileStateFile some-machine93$InputFileStateFile some-machine
94$InputRunFileMonitor94$InputRunFileMonitor
9595
96:syslogtag, startswith, "juju-" @server:51496:syslogtag, startswith, "juju-" @server:999
97& ~97& ~
98`98`
9999
100func (s *SyslogConfigSuite) TestForwardConfigRender(c *gc.C) {100func (s *SyslogConfigSuite) TestForwardConfigRender(c *gc.C) {
101 syslogConfigRenderer := syslog.NewForwardConfig("some-machine", []string{"server"})101 syslogConfigRenderer := syslog.NewForwardConfig("some-machine", 999, []string{"server"})
102 s.assertRsyslogConfigContents(c, syslogConfigRenderer, expectedForwardSyslogConf)102 s.assertRsyslogConfigContents(c, syslogConfigRenderer, expectedForwardSyslogConf)
103}103}
104104
105func (s *SyslogConfigSuite) TestForwardConfigWrite(c *gc.C) {105func (s *SyslogConfigSuite) TestForwardConfigWrite(c *gc.C) {
106 syslogConfigRenderer := syslog.NewForwardConfig("some-machine", []string{"server"})106 syslogConfigRenderer := syslog.NewForwardConfig("some-machine", 999, []string{"server"})
107 syslogConfigRenderer.ConfigDir = s.configDir107 syslogConfigRenderer.ConfigDir = s.configDir
108 syslogConfigRenderer.ConfigFileName = "rsyslog.conf"108 syslogConfigRenderer.ConfigFileName = "rsyslog.conf"
109 s.assertRsyslogConfigPath(c, syslogConfigRenderer)109 s.assertRsyslogConfigPath(c, syslogConfigRenderer)
110110
=== modified file 'provider/azure/customdata_test.go'
--- provider/azure/customdata_test.go 2013-09-20 02:33:04 +0000
+++ provider/azure/customdata_test.go 2013-11-25 03:52:41 +0000
@@ -44,6 +44,7 @@
44 Addrs: []string{"127.0.0.1:123"},44 Addrs: []string{"127.0.0.1:123"},
45 Tag: names.MachineTag(machineID),45 Tag: names.MachineTag(machineID),
46 },46 },
47 SyslogPort: 2345,
47 }48 }
48}49}
4950
5051
=== modified file 'provider/dummy/environs.go'
--- provider/dummy/environs.go 2013-11-18 05:41:36 +0000
+++ provider/dummy/environs.go 2013-11-25 03:52:41 +0000
@@ -74,6 +74,7 @@
74 "development": false,74 "development": false,
75 "state-port": 1234,75 "state-port": 1234,
76 "api-port": 4321,76 "api-port": 4321,
77 "syslog-port": 2345,
77 "default-series": "precise",78 "default-series": "precise",
7879
79 "secret": "pork",80 "secret": "pork",
8081
=== modified file 'state/address.go'
--- state/address.go 2013-10-14 17:44:23 +0000
+++ state/address.go 2013-11-25 03:52:41 +0000
@@ -110,3 +110,27 @@
110 }110 }
111 return appendPort(addrs, config.APIPort()), nil111 return appendPort(addrs, config.APIPort()), nil
112}112}
113
114type DeployerConnectionValues struct {
115 StateAddresses []string
116 APIAddresses []string
117 SyslogPort int
118}
119
120// DeployerConnectionInfo returns the address information necessary for the deployer.
121// The function does the expensive operations (getting stuff from mongo) just once.
122func (st *State) DeployerConnectionInfo() (*DeployerConnectionValues, error) {
123 addrs, err := st.stateServerAddresses()
124 if err != nil {
125 return nil, err
126 }
127 config, err := st.EnvironConfig()
128 if err != nil {
129 return nil, err
130 }
131 return &DeployerConnectionValues{
132 StateAddresses: appendPort(addrs, config.StatePort()),
133 APIAddresses: appendPort(addrs, config.APIPort()),
134 SyslogPort: config.SyslogPort(),
135 }, nil
136}
113137
=== modified file 'state/api/deployer/deployer.go'
--- state/api/deployer/deployer.go 2013-07-24 13:15:52 +0000
+++ state/api/deployer/deployer.go 2013-11-25 03:52:41 +0000
@@ -90,3 +90,10 @@
90 }90 }
91 return result.Result, nil91 return result.Result, nil
92}92}
93
94// ConnectionInfo returns all the address information that the deployer task
95// needs in one call.
96func (st *State) ConnectionInfo() (result params.DeployerConnectionValues, err error) {
97 err = st.caller.Call("Deployer", "", "ConnectionInfo", nil, &result)
98 return result, err
99}
93100
=== modified file 'state/api/params/params.go'
--- state/api/params/params.go 2013-11-21 14:43:12 +0000
+++ state/api/params/params.go 2013-11-25 03:52:41 +0000
@@ -479,6 +479,7 @@
479 ProviderType string479 ProviderType string
480 AuthorizedKeys string480 AuthorizedKeys string
481 SSLHostnameVerification bool481 SSLHostnameVerification bool
482 SyslogPort int
482}483}
483484
484type MachineConfigParams struct {485type MachineConfigParams struct {
@@ -517,3 +518,11 @@
517type SetEnvironAgentVersion struct {518type SetEnvironAgentVersion struct {
518 Version version.Number519 Version version.Number
519}520}
521
522// DeployerConnectionValues containers the result of deployer.ConnectionInfo
523// API call.
524type DeployerConnectionValues struct {
525 StateAddresses []string
526 APIAddresses []string
527 SyslogPort int
528}
520529
=== modified file 'state/api/provisioner/provisioner_test.go'
--- state/api/provisioner/provisioner_test.go 2013-11-19 02:14:38 +0000
+++ state/api/provisioner/provisioner_test.go 2013-11-25 03:52:41 +0000
@@ -377,6 +377,7 @@
377 c.Assert(result.ProviderType, gc.Equals, "dummy")377 c.Assert(result.ProviderType, gc.Equals, "dummy")
378 c.Assert(result.AuthorizedKeys, gc.Equals, "my-keys")378 c.Assert(result.AuthorizedKeys, gc.Equals, "my-keys")
379 c.Assert(result.SSLHostnameVerification, jc.IsTrue)379 c.Assert(result.SSLHostnameVerification, jc.IsTrue)
380 c.Assert(result.SyslogPort, gc.Equals, 2345)
380}381}
381382
382func (s *provisionerSuite) TestCACert(c *gc.C) {383func (s *provisionerSuite) TestCACert(c *gc.C) {
383384
=== modified file 'state/apiserver/deployer/deployer.go'
--- state/apiserver/deployer/deployer.go 2013-11-01 21:06:12 +0000
+++ state/apiserver/deployer/deployer.go 2013-11-25 03:52:41 +0000
@@ -122,3 +122,17 @@
122 }122 }
123 return result, nil123 return result, nil
124}124}
125
126// ServerAddresses returns all the address information that the deployer task
127// needs in one call.
128func (d *DeployerAPI) ConnectionInfo() (result params.DeployerConnectionValues, err error) {
129 info, err := d.st.DeployerConnectionInfo()
130 if info != nil {
131 result = params.DeployerConnectionValues{
132 StateAddresses: info.StateAddresses,
133 APIAddresses: info.APIAddresses,
134 SyslogPort: info.SyslogPort,
135 }
136 }
137 return result, err
138}
125139
=== modified file 'state/apiserver/provisioner/provisioner.go'
--- state/apiserver/provisioner/provisioner.go 2013-11-22 03:08:44 +0000
+++ state/apiserver/provisioner/provisioner.go 2013-11-25 03:52:41 +0000
@@ -224,6 +224,7 @@
224 result.ProviderType = config.Type()224 result.ProviderType = config.Type()
225 result.AuthorizedKeys = config.AuthorizedKeys()225 result.AuthorizedKeys = config.AuthorizedKeys()
226 result.SSLHostnameVerification = config.SSLHostnameVerification()226 result.SSLHostnameVerification = config.SSLHostnameVerification()
227 result.SyslogPort = config.SyslogPort()
227 return result, nil228 return result, nil
228}229}
229230
230231
=== modified file 'state/apiserver/provisioner/provisioner_test.go'
--- state/apiserver/provisioner/provisioner_test.go 2013-11-22 03:08:44 +0000
+++ state/apiserver/provisioner/provisioner_test.go 2013-11-25 03:52:41 +0000
@@ -698,6 +698,7 @@
698 c.Check(results.ProviderType, gc.Equals, "dummy")698 c.Check(results.ProviderType, gc.Equals, "dummy")
699 c.Check(results.AuthorizedKeys, gc.Equals, "my-keys")699 c.Check(results.AuthorizedKeys, gc.Equals, "my-keys")
700 c.Check(results.SSLHostnameVerification, jc.IsTrue)700 c.Check(results.SSLHostnameVerification, jc.IsTrue)
701 c.Check(results.SyslogPort, gc.Equals, 2345)
701}702}
702703
703func (s *provisionerSuite) TestToolsRefusesWrongAgent(c *gc.C) {704func (s *provisionerSuite) TestToolsRefusesWrongAgent(c *gc.C) {
704705
=== removed file 'worker/deployer/addresser.go'
--- worker/deployer/addresser.go 2013-07-25 11:03:16 +0000
+++ worker/deployer/addresser.go 1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
1// Copyright 2013 Canonical Ltd.
2// Licensed under the AGPLv3, see LICENCE file for details.
3
4package deployer
5
6// Addresser implementations provide the capability to lookup a list
7// of server addresses.
8type Addresser interface {
9 StateAddresses() ([]string, error)
10 APIAddresses() ([]string, error)
11}
120
=== modified file 'worker/deployer/export_test.go'
--- worker/deployer/export_test.go 2013-09-02 06:03:14 +0000
+++ worker/deployer/export_test.go 2013-11-25 03:52:41 +0000
@@ -5,21 +5,22 @@
55
6import (6import (
7 "launchpad.net/juju-core/agent"7 "launchpad.net/juju-core/agent"
8 "launchpad.net/juju-core/state/api/params"
8)9)
910
10type fakeAddresser struct{}11type fakeAPI struct{}
1112
12func (*fakeAddresser) StateAddresses() ([]string, error) {13func (*fakeAPI) ConnectionInfo() (params.DeployerConnectionValues, error) {
13 return []string{"s1:123", "s2:123"}, nil14 return params.DeployerConnectionValues{
14}15 []string{"s1:123", "s2:123"},
1516 []string{"a1:123", "a2:123"},
16func (*fakeAddresser) APIAddresses() ([]string, error) {17 2345,
17 return []string{"a1:123", "a2:123"}, nil18 }, nil
18}19}
1920
20func NewTestSimpleContext(agentConfig agent.Config, initDir, logDir, syslogConfigDir string) *SimpleContext {21func NewTestSimpleContext(agentConfig agent.Config, initDir, logDir, syslogConfigDir string) *SimpleContext {
21 return &SimpleContext{22 return &SimpleContext{
22 addresser: &fakeAddresser{},23 api: &fakeAPI{},
23 agentConfig: agentConfig,24 agentConfig: agentConfig,
24 initDir: initDir,25 initDir: initDir,
25 logDir: logDir,26 logDir: logDir,
2627
=== modified file 'worker/deployer/simple.go'
--- worker/deployer/simple.go 2013-09-02 22:15:48 +0000
+++ worker/deployer/simple.go 2013-11-25 03:52:41 +0000
@@ -16,17 +16,23 @@
16 "launchpad.net/juju-core/juju/osenv"16 "launchpad.net/juju-core/juju/osenv"
17 "launchpad.net/juju-core/log/syslog"17 "launchpad.net/juju-core/log/syslog"
18 "launchpad.net/juju-core/names"18 "launchpad.net/juju-core/names"
19 "launchpad.net/juju-core/state/api/params"
19 "launchpad.net/juju-core/upstart"20 "launchpad.net/juju-core/upstart"
20 "launchpad.net/juju-core/version"21 "launchpad.net/juju-core/version"
21)22)
2223
24// APICalls defines the interface to the API that the simple context needs.
25type APICalls interface {
26 ConnectionInfo() (params.DeployerConnectionValues, error)
27}
28
23// SimpleContext is a Context that manages unit deployments via upstart29// SimpleContext is a Context that manages unit deployments via upstart
24// jobs on the local system.30// jobs on the local system.
25type SimpleContext struct {31type SimpleContext struct {
2632
27 // addresser is used to get the current state server addresses at the time33 // api is used to get the current state server addresses at the time the
28 // the given unit is deployed.34 // given unit is deployed.
29 addresser Addresser35 api APICalls
3036
31 // agentConfig returns the agent config for the machine agent that is37 // agentConfig returns the agent config for the machine agent that is
32 // running the deployer.38 // running the deployer.
@@ -55,9 +61,9 @@
55// specified deployer, that deploys unit agents as upstart jobs in61// specified deployer, that deploys unit agents as upstart jobs in
56// "/etc/init" logging to "/var/log/juju". Paths to which agents and tools62// "/etc/init" logging to "/var/log/juju". Paths to which agents and tools
57// are installed are relative to dataDir.63// are installed are relative to dataDir.
58func NewSimpleContext(agentConfig agent.Config, addresser Addresser) *SimpleContext {64func NewSimpleContext(agentConfig agent.Config, api APICalls) *SimpleContext {
59 return &SimpleContext{65 return &SimpleContext{
60 addresser: addresser,66 api: api,
61 agentConfig: agentConfig,67 agentConfig: agentConfig,
62 initDir: "/etc/init",68 initDir: "/etc/init",
63 logDir: "/var/log/juju",69 logDir: "/var/log/juju",
@@ -82,27 +88,22 @@
82 toolsDir := tools.ToolsDir(dataDir, tag)88 toolsDir := tools.ToolsDir(dataDir, tag)
83 defer removeOnErr(&err, toolsDir)89 defer removeOnErr(&err, toolsDir)
8490
85 // Retrieve the state addresses.91 result, err := ctx.api.ConnectionInfo()
86 // TODO: remove the state addresses when unit agent is API only.92 if err != nil {
87 stateAddrs, err := ctx.addresser.StateAddresses()93 return err
88 if err != nil {94 }
89 return err95 logger.Debugf("state addresses: %q", result.StateAddresses)
90 }96 logger.Debugf("API addresses: %q", result.APIAddresses)
91 logger.Debugf("state addresses: %q", stateAddrs)
92 apiAddrs, err := ctx.addresser.APIAddresses()
93 if err != nil {
94 return err
95 }
96 logger.Debugf("API addresses: %q", apiAddrs)
97 containerType := ctx.agentConfig.Value(agent.ContainerType)97 containerType := ctx.agentConfig.Value(agent.ContainerType)
98 conf, err := agent.NewAgentConfig(98 conf, err := agent.NewAgentConfig(
99 agent.AgentConfigParams{99 agent.AgentConfigParams{
100 DataDir: dataDir,100 DataDir: dataDir,
101 Tag: tag,101 Tag: tag,
102 Password: initialPassword,102 Password: initialPassword,
103 Nonce: "unused",103 Nonce: "unused",
104 StateAddresses: stateAddrs,104 // TODO: remove the state addresses here and test when api only.
105 APIAddresses: apiAddrs,105 StateAddresses: result.StateAddresses,
106 APIAddresses: result.APIAddresses,
106 CACert: ctx.agentConfig.CACert(),107 CACert: ctx.agentConfig.CACert(),
107 Values: map[string]string{108 Values: map[string]string{
108 agent.ContainerType: containerType,109 agent.ContainerType: containerType,
@@ -118,7 +119,7 @@
118119
119 // Install an upstart job that runs the unit agent.120 // Install an upstart job that runs the unit agent.
120 logPath := path.Join(ctx.logDir, tag+".log")121 logPath := path.Join(ctx.logDir, tag+".log")
121 syslogConfigRenderer := syslog.NewForwardConfig(tag, stateAddrs)122 syslogConfigRenderer := syslog.NewForwardConfig(tag, result.SyslogPort, result.StateAddresses)
122 syslogConfigRenderer.ConfigDir = ctx.syslogConfigDir123 syslogConfigRenderer.ConfigDir = ctx.syslogConfigDir
123 syslogConfigRenderer.ConfigFileName = fmt.Sprintf("26-juju-%s.conf", tag)124 syslogConfigRenderer.ConfigFileName = fmt.Sprintf("26-juju-%s.conf", tag)
124 if err := syslogConfigRenderer.Write(); err != nil {125 if err := syslogConfigRenderer.Write(); err != nil {
125126
=== modified file 'worker/deployer/simple_test.go'
--- worker/deployer/simple_test.go 2013-10-21 21:49:04 +0000
+++ worker/deployer/simple_test.go 2013-11-25 03:52:41 +0000
@@ -218,7 +218,7 @@
218$InputFileStateFile %s218$InputFileStateFile %s
219$InputRunFileMonitor219$InputRunFileMonitor
220220
221:syslogtag, startswith, "juju-" @s1:514221:syslogtag, startswith, "juju-" @s1:2345
222& ~222& ~
223`223`
224224
225225
=== modified file 'worker/provisioner/lxc-broker.go'
--- worker/provisioner/lxc-broker.go 2013-11-11 21:38:30 +0000
+++ worker/provisioner/lxc-broker.go 2013-11-25 03:52:41 +0000
@@ -74,6 +74,7 @@
74 config.ProviderType,74 config.ProviderType,
75 config.AuthorizedKeys,75 config.AuthorizedKeys,
76 config.SSLHostnameVerification,76 config.SSLHostnameVerification,
77 config.SyslogPort,
77 ); err != nil {78 ); err != nil {
78 lxcLogger.Errorf("failed to populate machine config: %v", err)79 lxcLogger.Errorf("failed to populate machine config: %v", err)
79 return nil, nil, err80 return nil, nil, err
8081
=== modified file 'worker/provisioner/lxc-broker_test.go'
--- worker/provisioner/lxc-broker_test.go 2013-11-20 04:49:01 +0000
+++ worker/provisioner/lxc-broker_test.go 2013-11-25 03:52:41 +0000
@@ -284,5 +284,5 @@
284type fakeAPI struct{}284type fakeAPI struct{}
285285
286func (*fakeAPI) ContainerConfig() (params.ContainerConfig, error) {286func (*fakeAPI) ContainerConfig() (params.ContainerConfig, error) {
287 return params.ContainerConfig{"fake", "my-keys", true}, nil287 return params.ContainerConfig{"fake", "my-keys", true, 2345}, nil
288}288}

Subscribers

People subscribed via source and target branches

to status/vote changes: