Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wire up EnvironConfigGetter to use model config service #18028

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

hmlanigan
Copy link
Member

@hmlanigan hmlanigan commented Sep 4, 2024

For Environs, ensure that Config is provided by the ModelConfigService rather than state. This is a stop gap on the way to reducing dependence on Environs and replacing with appropriate calls into the different domain services where possible.

The above changed required that NewCAASBrokerFunc and NewEnvironFunc were also updated to allow in a ModelConfigService.

In the process of this work, it became clear it should be done in conjunction with removing the NewInstancePrechecker to avoid unnecessary work when it was removed next. The InstancePrechecker will be replaced in the machine service.

Checklist

  • Code style: imports ordered, good names, simple structure, etc
  • Comments saying why design decisions were made
  • [ ] Go unit tests, with comments saying what you're testing
  • [ ] Integration tests, with comments saying what you're testing
  • [ ] doc.go added or updated in changed packages

QA steps

This change touches many pieces of juju around deploy and providers. Test by using bootstrap, deploy, model config, refresh, status and destroy in different ways. Unfortunately the bash tests do not run easily for unrelated reasons.

Model migration is tested via the GitHub Actions.

Test updating model config

$ juju bootstrap lxd test
$ juju add-model testmodel
$ juju model-config update-status-hook-interval=3m

Links

Jira card: JUJU-6674
Jira card: JUJU-6687

@hmlanigan hmlanigan added the 4.0 label Sep 9, 2024
@hmlanigan hmlanigan force-pushed the model-config-service-into-ecg branch 6 times, most recently from 979d7cc to 22aa7e0 Compare September 13, 2024 13:57
@hmlanigan
Copy link
Member Author

/build

@hmlanigan hmlanigan force-pushed the model-config-service-into-ecg branch 2 times, most recently from 68fc108 to 4a067fe Compare September 16, 2024 20:28
@hmlanigan hmlanigan force-pushed the model-config-service-into-ecg branch 6 times, most recently from 60c5f8c to f856fc1 Compare September 18, 2024 19:30
@hmlanigan hmlanigan marked this pull request as ready for review September 18, 2024 21:06
This allows for facade tests which double write data to share a model
UUID between state and the service factory setup. Needed to start with
getting ModelConfig, if the requested model state does not exist in a
service factory, the environ config getters will fail during test.
This is a stop gap on the way to reducing dependence on Environs and
replacing with appropriate calls into the different domain services
where possible. That work was started in PR 18013.

GetNewPolicyFunc needs a model config service getter. Callers do not
have a model at the setup time of GetNewPolicyFunc. Use a model
config service getter instead.

Special case the model config service getter with the environStatePolicy
structure to limit use and not require everywhere, using a model config
service is preferable.

A short term solution one the way to removing the Policy's all together.

Delete stateenvirons NewInstancePrechecker and associated code. The
functionality has been replace and no longer required here.

Remove configvalidator_test.go. These are model config tests which are
failing in state after changes to the EnvironConfigGetter. We're near
the end of the work to move model config from state to a domain. Thus
they can be removed now rather than fixing.
Copy link
Member

@SimonRichardson SimonRichardson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done a first pass. I agree that removing the precheck instance elevates a lot of issues, but we must be sure to make the epics with links back to the PR to reinstate them when we implement them.

@@ -368,18 +360,14 @@ func (s *bootstrapSuite) TestInitializeStateFailsSecondTime(c *gc.C) {
AdminUser: adminUser,
StateInitializationParams: args,
MongoDialOpts: mongotest.DialOpts(),
StateNewPolicy: state.NewPolicyFunc(nil),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprised this can go as well.

apiserver/facades/schema.json Show resolved Hide resolved
Comment on lines -397 to -404
StateNewPolicy: stateenvirons.GetNewPolicyFunc(
cloudGetter{cloud: &args.ControllerCloud},
credentialGetter{cred: args.ControllerCloudCredential},
// We don't need the storage service at bootstrap.
func(modelUUID model.UUID, registry storage.ProviderRegistry) state.StoragePoolGetter {
return noopStoragePoolGetter{}
},
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to work out if we're at liberty to do this. The policy func is also required for config and constraints validation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it due to a comment in agent/agentbootstrap/bootstrap.go:

	// Deprecated: use InstancePrechecker
 	StateNewPolicy           state.NewPolicyFunc
 	InstancePrecheckerGetter func(*state.State) (environs.InstancePrechecker, error)

internal/provider/ec2/local_test.go Outdated Show resolved Hide resolved
internal/provider/openstack/local_test.go Outdated Show resolved Hide resolved
state/state.go Show resolved Hide resolved
state/state.go Show resolved Hide resolved
state/stateenvirons/config.go Show resolved Hide resolved
state/stateenvirons/policy.go Show resolved Hide resolved
state/stateenvirons/policy.go Show resolved Hide resolved
In the process of removing model config from state, there is
functionality which needs to be skipped for now until it can be
re-implemented in a domain. In this case skip validation model
constraints for now. The model domain will be completed after model
config.

Skip 2 tests which fail due to above change. Remove once they have been
handled in the model epic.
Over zealous with instance prechecker removal from stateenviron. These
tests will work and the instance prechecker will be reimplmented in the
machine domain.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants