Skip to content

Commit 3620f9e

Browse files
authored
Merge pull request juju#17761 from barrettj12/new-controller-facade
juju#17761 v12 has removed the ModelConfig method. This is in preparation for 4.0 where we will change this facade to a multi-model facade. Calls to this facade method were already removed in juju#17732. ## 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 Bootstrap Juju, run `show-controller`, and check that the controller model version displays correctly: ``` $ juju show-controller | grep controller-model-version controller-model-version: 3.6-beta2.1 ``` Run `upgrade-model` on the controller model, and check that it raises an error: ``` $ juju switch controller $ juju upgrade-model ERROR use upgrade-controller to upgrade the controller model ``` Run `destroy-controller` and check that the controller is successfully destroyed. Bootstrap Juju again, and add the 3.6 controller to a 3.5 client: ``` juju3.6:~$ juju add-user juju35 User "juju35" added Please send this command to juju35: juju register ... juju3.6:~$ juju grant juju35 superuser juju3.6:~$ juju grant juju35 admin controller ``` ``` juju3.5:~$ juju register ... ``` Now do all the above steps again with the 3.5 client, to ensure compatibility between 3.5 and 3.6. ## Links **Jira card:** JUJU-6351
2 parents a2edfd0 + 062228b commit 3620f9e

File tree

7 files changed

+41
-53
lines changed

7 files changed

+41
-53
lines changed

api/facadeversions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var facadeVersions = facades.FacadeVersions{
5353
"Cleaner": {2},
5454
"Client": {6, 7},
5555
"Cloud": {7},
56-
"Controller": {11},
56+
"Controller": {11, 12},
5757
"CredentialManager": {1},
5858
"CredentialValidator": {2},
5959
"CrossController": {1},

apiserver/facades/client/controller/controller.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ type ControllerAPI struct {
6464
multiwatcherFactory multiwatcher.Factory
6565
}
6666

67+
type ControllerAPIv11 struct {
68+
*ControllerAPI
69+
}
70+
6771
// LatestAPI is used for testing purposes to create the latest
6872
// controller API.
69-
var LatestAPI = newControllerAPIv11
73+
var LatestAPI = makeControllerAPI
7074

7175
// TestingAPI is an escape hatch for requesting a controller API that won't
7276
// allow auth to correctly happen for ModelStatus. I'm not convicned this
@@ -435,7 +439,7 @@ func (c *ControllerAPI) ListBlockedModels() (params.ModelBlockInfoList, error) {
435439
// converted to a multi-model facade. Please use the ModelConfig facade's
436440
// ModelGet method instead:
437441
// [github.com/juju/juju/apiserver/facades/client/modelconfig.ModelConfigAPI.ModelGet]
438-
func (c *ControllerAPI) ModelConfig() (params.ModelConfigResults, error) {
442+
func (c *ControllerAPIv11) ModelConfig() (params.ModelConfigResults, error) {
439443
result := params.ModelConfigResults{}
440444
if err := c.checkIsSuperUser(); err != nil {
441445
return result, errors.Trace(err)

apiserver/facades/client/controller/controller_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,10 @@ func (s *controllerSuite) TestListBlockedModelsNoBlocks(c *gc.C) {
305305
}
306306

307307
func (s *controllerSuite) TestModelConfig(c *gc.C) {
308-
cfg, err := s.controller.ModelConfig()
308+
controller, err := controller.NewControllerAPIv11(s.context)
309+
c.Assert(err, jc.ErrorIsNil)
310+
311+
cfg, err := controller.ModelConfig()
309312
c.Assert(err, jc.ErrorIsNil)
310313
c.Assert(cfg.Config["name"], jc.DeepEquals, params.ConfigValue{Value: "controller"})
311314
}

apiserver/facades/client/controller/destroy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (s *destroyControllerSuite) SetUpTest(c *gc.C) {
5858
s.authorizer = apiservertesting.FakeAuthorizer{
5959
Tag: s.AdminUserTag(c),
6060
}
61-
testController, err := controller.NewControllerAPIv11(
61+
testController, err := controller.LatestAPI(
6262
facadetest.Context{
6363
State_: s.State,
6464
StatePool_: s.StatePool,

apiserver/facades/client/controller/export_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ func NewControllerAPIForTest(backend Backend) *ControllerAPI {
2424
}
2525

2626
var (
27-
NewControllerAPIv11 = newControllerAPIv11
27+
NewControllerAPIv11 = makeControllerAPIv11
2828
)

apiserver/facades/client/controller/register.go

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package controller
55

66
import (
7+
"fmt"
78
"reflect"
89

910
"github.com/juju/errors"
@@ -14,12 +15,23 @@ import (
1415
// Register is called to expose a package of facades onto a given registry.
1516
func Register(registry facade.FacadeRegistry) {
1617
registry.MustRegister("Controller", 11, func(ctx facade.Context) (facade.Facade, error) {
17-
return newControllerAPIv11(ctx)
18+
api, err := makeControllerAPIv11(ctx)
19+
if err != nil {
20+
return nil, fmt.Errorf("creating Controller facade v11: %w", err)
21+
}
22+
return api, nil
23+
}, reflect.TypeOf((*ControllerAPIv11)(nil)))
24+
25+
registry.MustRegister("Controller", 12, func(ctx facade.Context) (facade.Facade, error) {
26+
api, err := makeControllerAPI(ctx)
27+
if err != nil {
28+
return nil, fmt.Errorf("creating Controller facade v12: %w", err)
29+
}
30+
return api, nil
1831
}, reflect.TypeOf((*ControllerAPI)(nil)))
1932
}
2033

21-
// newControllerAPIv11 creates a new ControllerAPIv11
22-
func newControllerAPIv11(ctx facade.Context) (*ControllerAPI, error) {
34+
func makeControllerAPI(ctx facade.Context) (*ControllerAPI, error) {
2335
st := ctx.State()
2436
authorizer := ctx.Auth()
2537
pool := ctx.StatePool()
@@ -46,3 +58,15 @@ func newControllerAPIv11(ctx facade.Context) (*ControllerAPI, error) {
4658
leadership,
4759
)
4860
}
61+
62+
// makeControllerAPIv11 creates a new ControllerAPIv11
63+
func makeControllerAPIv11(ctx facade.Context) (*ControllerAPIv11, error) {
64+
controllerAPI, err := makeControllerAPI(ctx)
65+
if err != nil {
66+
return nil, err
67+
}
68+
69+
return &ControllerAPIv11{
70+
ControllerAPI: controllerAPI,
71+
}, nil
72+
}

apiserver/facades/schema.json

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18742,7 +18742,7 @@
1874218742
{
1874318743
"Name": "Controller",
1874418744
"Description": "ControllerAPI provides the Controller API.",
18745-
"Version": 11,
18745+
"Version": 12,
1874618746
"AvailableTo": [
1874718747
"controller-machine-agent",
1874818748
"machine-agent",
@@ -18893,15 +18893,6 @@
1889318893
},
1889418894
"description": "ListBlockedModels returns a list of all models on the controller\nwhich have a block in place. The resulting slice is sorted by model\nname, then owner. Callers must be controller administrators to retrieve the\nlist."
1889518895
},
18896-
"ModelConfig": {
18897-
"type": "object",
18898-
"properties": {
18899-
"Result": {
18900-
"$ref": "#/definitions/ModelConfigResults"
18901-
}
18902-
},
18903-
"description": "ModelConfig returns the model config for the controller model.\n\nDeprecated: this facade method will be removed in 4.0 when this facade is\nconverted to a multi-model facade. Please use the ModelConfig facade's\nModelGet method instead:\n[github.com/juju/juju/apiserver/facades/client/modelconfig.ModelConfigAPI.ModelGet]"
18904-
},
1890518896
"ModelStatus": {
1890618897
"type": "object",
1890718898
"properties": {
@@ -19090,23 +19081,6 @@
1909019081
},
1909119082
"additionalProperties": false
1909219083
},
19093-
"ConfigValue": {
19094-
"type": "object",
19095-
"properties": {
19096-
"source": {
19097-
"type": "string"
19098-
},
19099-
"value": {
19100-
"type": "object",
19101-
"additionalProperties": true
19102-
}
19103-
},
19104-
"additionalProperties": false,
19105-
"required": [
19106-
"value",
19107-
"source"
19108-
]
19109-
},
1911019084
"ControllerAPIInfoResult": {
1911119085
"type": "object",
1911219086
"properties": {
@@ -19592,23 +19566,6 @@
1959219566
},
1959319567
"additionalProperties": false
1959419568
},
19595-
"ModelConfigResults": {
19596-
"type": "object",
19597-
"properties": {
19598-
"config": {
19599-
"type": "object",
19600-
"patternProperties": {
19601-
".*": {
19602-
"$ref": "#/definitions/ConfigValue"
19603-
}
19604-
}
19605-
}
19606-
},
19607-
"additionalProperties": false,
19608-
"required": [
19609-
"config"
19610-
]
19611-
},
1961219569
"ModelFilesystemInfo": {
1961319570
"type": "object",
1961419571
"properties": {

0 commit comments

Comments
 (0)