Skip to content

Commit 673adb1

Browse files
authored
Merge pull request juju#16694 from SimonRichardson/bootstrap-controller-charm-infra
juju#16694 ~~Requires juju#16689 to land first.~~ ---- This is another peeled-off piece from the bootstrap worker controller charm deployment. This infrastructure will define how we can deploy a controller charm with better test coverage than in the `cmd/jujud/agent` package. The premise of this change is to provide two deployers; IAAS and CAAS. Depending on the dependency engine configuration the deployer will selected based on the appropriate manifold. Work to integrate it into the bootstrap worker will be done once this has landed. Each deployer has a common set of tasks called by the `PopulateControllerCharm` function. This takes a `ControllerCharmDeployer` as a dependency, accumulates all the dependencies that can't be calculated up front, and then feeds them to either the local or charmhub deploy methods. The code is based upon the `controller.go` found in the `cmd/jujud/agent` package, with a lot of additional tests. To improve coverage, some of the dependencies are swapped out for interface variations. --- I've tried to reduce the changes as much as possible by breaking off the changes required to land this (see: juju#16689). Most if not all the code is the mock files required for testing. ## Checklist <!-- If an item is not applicable, use `~strikethrough~`. --> - [x] Code style: imports ordered, good names, simple structure, etc - [x] Comments saying why design decisions were made - [x] Go unit tests, with comments saying what you're testing ## QA steps As this is infrastructural work, there currently isn't a manual test. ```sh $ go test -v ./internal/bootstrap -v ``` ## Links **Jira card:** JUJU-5137
2 parents b36a2b7 + 7aebace commit 673adb1

23 files changed

+3059
-58
lines changed

apiserver/facades/client/charms/services/repofactory.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ type LoggerFactory interface {
2727

2828
// Logger is the interface that is used to log messages.
2929
type Logger interface {
30-
Errorf(message string, args ...any)
31-
Tracef(message string, args ...any)
30+
Errorf(string, ...interface{})
31+
Warningf(string, ...interface{})
32+
Debugf(string, ...interface{})
33+
Tracef(string, ...interface{})
3234
}
3335

3436
// CharmRepoFactoryConfig encapsulates the information required for creating a

cmd/jujud/agent/machine/manifolds.go

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -838,14 +838,16 @@ func IAASManifolds(config ManifoldsConfig) dependency.Manifolds {
838838
manifolds := dependency.Manifolds{
839839
// Bootstrap worker is responsible for setting up the initial machine.
840840
bootstrapName: ifDatabaseUpgradeComplete(bootstrap.Manifold(bootstrap.ManifoldConfig{
841-
AgentName: agentName,
842-
StateName: stateName,
843-
ObjectStoreName: objectStoreName,
844-
ServiceFactoryName: serviceFactoryName,
845-
BootstrapGateName: isBootstrapGateName,
846-
AgentBinaryUploader: bootstrap.IAASAgentBinaryUploader,
847-
RequiresBootstrap: bootstrap.RequiresBootstrap,
848-
Logger: loggo.GetLogger("juju.worker.bootstrap"),
841+
AgentName: agentName,
842+
StateName: stateName,
843+
ObjectStoreName: objectStoreName,
844+
ServiceFactoryName: serviceFactoryName,
845+
BootstrapGateName: isBootstrapGateName,
846+
CharmhubHTTPClientName: charmhubHTTPClientName,
847+
AgentBinaryUploader: bootstrap.IAASAgentBinaryUploader,
848+
ControllerCharmUploader: bootstrap.ControllerCharmUploader,
849+
RequiresBootstrap: bootstrap.RequiresBootstrap,
850+
Logger: loggo.GetLogger("juju.worker.bootstrap"),
849851
})),
850852

851853
toolsVersionCheckerName: ifNotMigrating(toolsversionchecker.Manifold(toolsversionchecker.ManifoldConfig{
@@ -1055,14 +1057,16 @@ func CAASManifolds(config ManifoldsConfig) dependency.Manifolds {
10551057
return mergeManifolds(config, dependency.Manifolds{
10561058
// Bootstrap worker is responsible for setting up the initial machine.
10571059
bootstrapName: ifDatabaseUpgradeComplete(bootstrap.Manifold(bootstrap.ManifoldConfig{
1058-
AgentName: agentName,
1059-
StateName: stateName,
1060-
ObjectStoreName: objectStoreName,
1061-
ServiceFactoryName: serviceFactoryName,
1062-
BootstrapGateName: isBootstrapGateName,
1063-
AgentBinaryUploader: bootstrap.CAASAgentBinaryUploader,
1064-
RequiresBootstrap: bootstrap.RequiresBootstrap,
1065-
Logger: loggo.GetLogger("juju.worker.bootstrap"),
1060+
AgentName: agentName,
1061+
StateName: stateName,
1062+
ObjectStoreName: objectStoreName,
1063+
ServiceFactoryName: serviceFactoryName,
1064+
BootstrapGateName: isBootstrapGateName,
1065+
CharmhubHTTPClientName: charmhubHTTPClientName,
1066+
AgentBinaryUploader: bootstrap.CAASAgentBinaryUploader,
1067+
ControllerCharmUploader: bootstrap.ControllerCharmUploader,
1068+
RequiresBootstrap: bootstrap.RequiresBootstrap,
1069+
Logger: loggo.GetLogger("juju.worker.bootstrap"),
10661070
})),
10671071

10681072
// TODO(caas) - when we support HA, only want this on primary

cmd/jujud/agent/machine/manifolds_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ var expectedMachineManifoldsWithDependenciesIAAS = map[string][]string{
546546
"bootstrap": {
547547
"agent",
548548
"change-stream",
549+
"charmhub-http-client",
549550
"db-accessor",
550551
"file-notify-watcher",
551552
"is-bootstrap-gate",
@@ -1263,6 +1264,7 @@ var expectedMachineManifoldsWithDependenciesCAAS = map[string][]string{
12631264
"bootstrap": {
12641265
"agent",
12651266
"change-stream",
1267+
"charmhub-http-client",
12661268
"db-accessor",
12671269
"file-notify-watcher",
12681270
"is-bootstrap-gate",

internal/bootstrap/agentbinary.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ import (
2323

2424
// Logger represents the logging methods called.
2525
type Logger interface {
26-
Errorf(message string, args ...any)
2726
Warningf(message string, args ...any)
28-
Infof(message string, args ...any)
2927
Debugf(message string, args ...any)
3028
}
3129

0 commit comments

Comments
 (0)