forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request juju#17519 from barrettj12/caasmodeloperator-model…
…service juju#17519 <!-- Why this change is needed and what it does. --> Refactor the caasmodeloperator facade to use a model config service instead of state. The facade uses the new `ModelConfig` and `Watch` methods instead of the state methods. Unit tests have been changed accordingly, with the ModelConfigService mocked out by a gomock-generated mock. As a result, many of the methods/interfaces/structs in `state.go` were able to be removed. ## 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 - ~[ ] [Integration tests](https://github.com/juju/juju/tree/main/tests), with comments saying what you're testing~ - ~[ ] [doc.go](https://discourse.charmhub.io/t/readme-in-packages/451) added or updated in changed packages~ ## QA steps We are going to force a controller upgrade and check that the model operator pod is updated. First, make sure you have an account on [Docker Hub](https://hub.docker.com/) and that you have `docker login`-ed on your local machine. Build Juju and set up the image repository: ```bash export JUJU_BUILD_NUMBER=0 export DOCKER_USERNAME=docker.io/<your-docker-username> make seed-repository make install # or go-build make simplestreams push-release-operator-image ``` In a new terminal window, start the simplestreams server. ``` $ cd _build/simplestreams/tools $ python3 -m http.server Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... ``` Back in the original terminal, we can bootstrap Juju with the right simplestreams & repository (providing your computer's IP address as the `agent-metadata-url`): ``` $ juju bootstrap minikube --config agent-metadata-url=http://192.168.1.25:8000/ --config caas-image-repo=$DOCKER_USERNAME $ juju switch controller $ juju status Model Controller Cloud/Region Version Timestamp controller minikube minikube 4.0-beta4 14:03:34+10:00 ``` Go to `version/version.go` and increment the version to `4.0-beta5`. Now rebuild Juju and update the simplestreams/image repo: ``` make install # or go-build make simplestreams push-release-operator-image ``` Now we should be able to upgrade the controller. ``` $ juju upgrade-controller best version: 4.0-beta5 started upgrade to 4.0-beta5 $ juju status Model Controller Cloud/Region Version Timestamp controller minikube minikube 4.0-beta5 14:06:12+10:00 $ kubectl -ncontroller-minikube describe deployment modeloperator | grep jujud-operator: Image: docker.io/hpidcock/jujud-operator:4.0-beta5 ``` ## Links **Jira card:** JUJU-6100
- Loading branch information
Showing
8 changed files
with
192 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2024 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package caasmodeloperator | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/juju/juju/controller" | ||
"github.com/juju/juju/core/watcher" | ||
"github.com/juju/juju/environs/config" | ||
) | ||
|
||
// ControllerConfigService provides access to the controller configuration. | ||
type ControllerConfigService interface { | ||
// ControllerConfig returns the config values for the controller. | ||
ControllerConfig(context.Context) (controller.Config, error) | ||
// WatchControllerConfig returns a watcher that returns keys for any | ||
// changes to controller config. | ||
WatchControllerConfig() (watcher.StringsWatcher, error) | ||
} | ||
|
||
// ModelConfigService provides access to the model's configuration. | ||
type ModelConfigService interface { | ||
// ModelConfig returns the current config for the model. | ||
ModelConfig(context.Context) (*config.Config, error) | ||
// Watch returns a watcher that returns keys for any changes to model | ||
// config. | ||
Watch() (watcher.StringsWatcher, error) | ||
} |
Oops, something went wrong.