Skip to content

Commit aba81e2

Browse files
committed
The provisioner worker does not need state addresses
1 parent 8db80d2 commit aba81e2

File tree

21 files changed

+33
-348
lines changed

21 files changed

+33
-348
lines changed

api/provisioner/provisioner.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,6 @@ func (st *State) WatchMachineErrorRetry() (watcher.NotifyWatcher, error) {
137137
return w, nil
138138
}
139139

140-
// StateAddresses returns the list of addresses used to connect to the state.
141-
func (st *State) StateAddresses() ([]string, error) {
142-
var result params.StringsResult
143-
err := st.facade.FacadeCall("StateAddresses", nil, &result)
144-
if err != nil {
145-
return nil, err
146-
}
147-
return result.Result, nil
148-
}
149-
150140
// ContainerManagerConfig returns information from the model config that is
151141
// needed for configuring the container manager.
152142
func (st *State) ContainerManagerConfig(args params.ContainerManagerConfigParams) (result params.ContainerManagerConfig, err error) {

api/provisioner/provisioner_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -672,18 +672,6 @@ func (s *provisionerSuite) TestWatchModelMachines(c *gc.C) {
672672
wc.AssertNoChange()
673673
}
674674

675-
func (s *provisionerSuite) TestStateAddresses(c *gc.C) {
676-
err := s.machine.SetProviderAddresses(corenetwork.NewSpaceAddress("0.1.2.3"))
677-
c.Assert(err, jc.ErrorIsNil)
678-
679-
stateAddresses, err := s.State.Addresses()
680-
c.Assert(err, jc.ErrorIsNil)
681-
682-
addresses, err := s.provisioner.StateAddresses()
683-
c.Assert(err, jc.ErrorIsNil)
684-
c.Assert(addresses, gc.DeepEquals, stateAddresses)
685-
}
686-
687675
func (s *provisionerSuite) getManagerConfig(c *gc.C, typ instance.ContainerType) map[string]string {
688676
args := params.ContainerManagerConfigParams{Type: typ}
689677
result, err := s.provisioner.ContainerManagerConfig(args)

apiserver/common/addresses.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,3 @@ func apiAddresses(getter APIHostPortsForAgentsGetter) ([]string, error) {
9393
}
9494
return addrs, nil
9595
}
96-
97-
// StateAddresser implements a common set of methods for getting state
98-
// server addresses, and the CA certificate used to authenticate them.
99-
type StateAddresser struct {
100-
getter APIAddressAccessor
101-
}
102-
103-
// NewStateAddresser returns a new StateAddresser that uses the given
104-
// st value to fetch its addresses.
105-
func NewStateAddresser(getter APIAddressAccessor) *StateAddresser {
106-
return &StateAddresser{getter}
107-
}
108-
109-
// StateAddresses returns the list of addresses used to connect to the state.
110-
func (a *StateAddresser) StateAddresses() (params.StringsResult, error) {
111-
addrs, err := a.getter.Addresses()
112-
if err != nil {
113-
return params.StringsResult{}, err
114-
}
115-
return params.StringsResult{
116-
Result: addrs,
117-
}, nil
118-
}

apiserver/common/addresses_test.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,16 @@ import (
1414
coretesting "github.com/juju/juju/testing"
1515
)
1616

17-
type stateAddresserSuite struct {
18-
addresser *common.StateAddresser
19-
}
20-
2117
type apiAddresserSuite struct {
2218
addresser *common.APIAddresser
2319
fake *fakeAddresses
2420
}
2521

26-
var _ = gc.Suite(&stateAddresserSuite{})
2722
var _ = gc.Suite(&apiAddresserSuite{})
2823

29-
func (s *stateAddresserSuite) SetUpTest(c *gc.C) {
30-
s.addresser = common.NewStateAddresser(fakeAddresses{
31-
hostPorts: []network.SpaceHostPorts{
32-
network.NewSpaceHostPorts(1, "apiaddresses"),
33-
network.NewSpaceHostPorts(2, "apiaddresses"),
34-
},
35-
})
36-
}
37-
3824
// Verify that APIAddressAccessor is satisfied by *state.State.
3925
var _ common.APIAddressAccessor = (*state.State)(nil)
4026

41-
func (s *stateAddresserSuite) TestStateAddresses(c *gc.C) {
42-
result, err := s.addresser.StateAddresses()
43-
c.Assert(err, jc.ErrorIsNil)
44-
c.Assert(result.Result, gc.DeepEquals, []string{"addresses:1", "addresses:2"})
45-
}
46-
4727
func (s *apiAddresserSuite) SetUpTest(c *gc.C) {
4828
s.fake = &fakeAddresses{
4929
hostPorts: []network.SpaceHostPorts{

apiserver/facades/agent/provisioner/provisioner.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ type ProvisionerAPI struct {
4646
*common.DeadEnsurer
4747
*common.PasswordChanger
4848
*common.LifeGetter
49-
*common.StateAddresser
5049
*common.APIAddresser
5150
*common.ModelWatcher
5251
*common.ModelMachinesWatcher
@@ -144,7 +143,6 @@ func NewProvisionerAPI(ctx facade.Context) (*ProvisionerAPI, error) {
144143
DeadEnsurer: common.NewDeadEnsurer(st, nil, getAuthFunc),
145144
PasswordChanger: common.NewPasswordChanger(st, getAuthFunc),
146145
LifeGetter: common.NewLifeGetter(st, getAuthFunc),
147-
StateAddresser: common.NewStateAddresser(st),
148146
APIAddresser: common.NewAPIAddresser(ctx.StatePool().SystemState(), resources),
149147
ModelWatcher: common.NewModelWatcher(model, resources, authorizer),
150148
ModelMachinesWatcher: common.NewModelMachinesWatcher(st, resources, authorizer),

apiserver/facades/agent/provisioner/provisioner_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,17 +1860,6 @@ func (s *withControllerSuite) TestAPIAddresses(c *gc.C) {
18601860
})
18611861
}
18621862

1863-
func (s *withControllerSuite) TestStateAddresses(c *gc.C) {
1864-
addresses, err := s.State.Addresses()
1865-
c.Assert(err, jc.ErrorIsNil)
1866-
1867-
result, err := s.provisioner.StateAddresses()
1868-
c.Assert(err, jc.ErrorIsNil)
1869-
c.Assert(result, gc.DeepEquals, params.StringsResult{
1870-
Result: addresses,
1871-
})
1872-
}
1873-
18741863
func (s *withControllerSuite) TestCACert(c *gc.C) {
18751864
result, err := s.provisioner.CACert()
18761865
c.Assert(err, jc.ErrorIsNil)

apiserver/facades/client/client/instanceconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func InstanceConfig(ctrlSt *state.State, st *state.State, machineId, nonce, data
9898
ModelTag: model.ModelTag(),
9999
}
100100

101-
_, apiInfo, err = authentication.SetupAuthentication(machine, nil, apiInfo)
101+
apiInfo, err = authentication.SetupAuthentication(machine, apiInfo)
102102
if err != nil {
103103
return nil, errors.Annotate(err, "setting up machine authentication")
104104
}

apiserver/facades/schema.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32322,15 +32322,6 @@
3232232322
},
3232332323
"description": "SetSupportedContainers updates the list of containers supported by the machines passed in args."
3232432324
},
32325-
"StateAddresses": {
32326-
"type": "object",
32327-
"properties": {
32328-
"Result": {
32329-
"$ref": "#/definitions/StringsResult"
32330-
}
32331-
},
32332-
"description": "StateAddresses returns the list of addresses used to connect to the state."
32333-
},
3233432325
"Status": {
3233532326
"type": "object",
3233632327
"properties": {

caas/kubernetes/provider/bootstrap_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"github.com/juju/juju/core/constraints"
3333
"github.com/juju/juju/environs/config"
3434
envtesting "github.com/juju/juju/environs/testing"
35-
"github.com/juju/juju/mongo"
3635
"github.com/juju/juju/testing"
3736
"github.com/juju/juju/tools"
3837
jujuversion "github.com/juju/juju/version"
@@ -75,9 +74,6 @@ func (s *bootstrapSuite) SetUpTest(c *gc.C) {
7574
CACert: testing.CACert,
7675
ModelTag: testing.ModelTag,
7776
}
78-
pcfg.Controller.MongoInfo = &mongo.MongoInfo{
79-
Password: "password", Info: mongo.Info{CACert: testing.CACert},
80-
}
8177
pcfg.Bootstrap.ControllerModelConfig = s.cfg
8278
pcfg.Bootstrap.BootstrapMachineInstanceId = "instance-id"
8379
pcfg.Bootstrap.HostedModelConfig = map[string]interface{}{

cloudconfig/cloudinit/renderscript_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"github.com/juju/juju/environs"
2222
"github.com/juju/juju/environs/config"
2323
"github.com/juju/juju/environs/imagemetadata"
24-
"github.com/juju/juju/mongo"
2524
coretesting "github.com/juju/juju/testing"
2625
"github.com/juju/juju/tools"
2726
)
@@ -70,9 +69,6 @@ func (s *configureSuite) getCloudConfig(c *gc.C, controller bool, vers version.B
7069
CACert: coretesting.CACert,
7170
ModelTag: coretesting.ModelTag,
7271
}
73-
icfg.Controller.MongoInfo = &mongo.MongoInfo{
74-
Password: "password", Info: mongo.Info{CACert: coretesting.CACert},
75-
}
7672
icfg.Bootstrap.ControllerModelConfig = modelConfig
7773
icfg.Bootstrap.BootstrapMachineInstanceId = "instance-id"
7874
icfg.Bootstrap.HostedModelConfig = map[string]interface{}{

cloudconfig/instancecfg/instancecfg.go

Lines changed: 3 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"github.com/juju/juju/environs/config"
3636
"github.com/juju/juju/environs/imagemetadata"
3737
"github.com/juju/juju/environs/tags"
38-
"github.com/juju/juju/mongo"
3938
"github.com/juju/juju/service"
4039
"github.com/juju/juju/service/common"
4140
"github.com/juju/juju/storage"
@@ -197,13 +196,6 @@ type InstanceConfig struct {
197196
// ControllerConfig represents controller-specific initialization information
198197
// for a new juju instance. This is only relevant for controller machines.
199198
type ControllerConfig struct {
200-
// MongoInfo holds the means for the new instance to communicate with the
201-
// juju state database. Unless the new instance is running a controller
202-
// (Controller is set), there must be at least one controller address supplied.
203-
// The entity name must match that of the instance being started,
204-
// or be empty when starting a controller.
205-
MongoInfo *mongo.MongoInfo
206-
207199
// Config contains controller config attributes.
208200
Config controller.Config
209201

@@ -464,14 +456,6 @@ func (cfg *InstanceConfig) AgentConfig(
464456
tag names.Tag,
465457
toolsVersion version.Number,
466458
) (agent.ConfigSetter, error) {
467-
var password, cacert string
468-
if cfg.Controller == nil {
469-
password = cfg.APIInfo.Password
470-
cacert = cfg.APIInfo.CACert
471-
} else {
472-
password = cfg.Controller.MongoInfo.Password
473-
cacert = cfg.Controller.MongoInfo.CACert
474-
}
475459
configParams := agent.AgentConfigParams{
476460
Paths: agent.Paths{
477461
DataDir: cfg.DataDir,
@@ -482,10 +466,10 @@ func (cfg *InstanceConfig) AgentConfig(
482466
Jobs: cfg.Jobs,
483467
Tag: tag,
484468
UpgradedToVersion: toolsVersion,
485-
Password: password,
469+
Password: cfg.APIInfo.Password,
486470
Nonce: cfg.MachineNonce,
487471
APIAddresses: cfg.APIHostAddrs(),
488-
CACert: cacert,
472+
CACert: cfg.APIInfo.CACert,
489473
Values: cfg.AgentEnvironment,
490474
Controller: cfg.ControllerTag,
491475
Model: cfg.APIInfo.ModelTag,
@@ -511,19 +495,6 @@ func (cfg *InstanceConfig) GUITools() string {
511495
return agenttools.SharedGUIDir(cfg.DataDir)
512496
}
513497

514-
func (cfg *InstanceConfig) stateHostAddrs() []string {
515-
var hosts []string
516-
if cfg.Bootstrap != nil {
517-
hosts = append(hosts, net.JoinHostPort(
518-
"localhost", strconv.Itoa(cfg.Bootstrap.StateServingInfo.StatePort)),
519-
)
520-
}
521-
if cfg.Controller != nil {
522-
hosts = append(hosts, cfg.Controller.MongoInfo.Addrs...)
523-
}
524-
return hosts
525-
}
526-
527498
func (cfg *InstanceConfig) APIHostAddrs() []string {
528499
var hosts []string
529500
if cfg.Bootstrap != nil {
@@ -684,11 +655,6 @@ func (cfg *InstanceConfig) VerifyConfig() (err error) {
684655
if cfg.MachineNonce == "" {
685656
return errors.New("missing machine nonce")
686657
}
687-
if cfg.Controller != nil {
688-
if err := cfg.verifyControllerConfig(); err != nil {
689-
return errors.Trace(err)
690-
}
691-
}
692658
if cfg.Bootstrap != nil {
693659
if err := cfg.verifyBootstrapConfig(); err != nil {
694660
return errors.Trace(err)
@@ -712,28 +678,12 @@ func (cfg *InstanceConfig) verifyBootstrapConfig() (err error) {
712678
if err := cfg.Bootstrap.VerifyConfig(); err != nil {
713679
return errors.Trace(err)
714680
}
715-
if cfg.APIInfo.Tag != nil || cfg.Controller.MongoInfo.Tag != nil {
681+
if cfg.APIInfo.Tag != nil {
716682
return errors.New("entity tag must be nil when bootstrapping")
717683
}
718684
return nil
719685
}
720686

721-
func (cfg *InstanceConfig) verifyControllerConfig() (err error) {
722-
defer errors.DeferredAnnotatef(&err, "invalid controller configuration")
723-
if err := cfg.Controller.VerifyConfig(); err != nil {
724-
return errors.Trace(err)
725-
}
726-
if cfg.Bootstrap == nil {
727-
if len(cfg.Controller.MongoInfo.Addrs) == 0 {
728-
return errors.New("missing state hosts")
729-
}
730-
if cfg.Controller.MongoInfo.Tag != names.NewMachineTag(cfg.MachineId) {
731-
return errors.New("entity tag must match started machine")
732-
}
733-
}
734-
return nil
735-
}
736-
737687
// VerifyConfig verifies that the BootstrapConfig is valid.
738688
func (cfg *BootstrapConfig) VerifyConfig() (err error) {
739689
if cfg.ControllerModelConfig == nil {
@@ -760,17 +710,6 @@ func (cfg *BootstrapConfig) VerifyConfig() (err error) {
760710
return nil
761711
}
762712

763-
// VerifyConfig verifies that the ControllerConfig is valid.
764-
func (cfg *ControllerConfig) VerifyConfig() error {
765-
if cfg.MongoInfo == nil {
766-
return errors.New("missing state info")
767-
}
768-
if len(cfg.MongoInfo.CACert) == 0 {
769-
return errors.New("missing CA certificate")
770-
}
771-
return nil
772-
}
773-
774713
// DefaultBridgeName is the network bridge device name used for LXC and KVM
775714
// containers
776715
const DefaultBridgeName = "br-eth0"

0 commit comments

Comments
 (0)