-
Notifications
You must be signed in to change notification settings - Fork 507
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
refactor(caasapplicationprovisioner): cut over to DQLite #18571
refactor(caasapplicationprovisioner): cut over to DQLite #18571
Conversation
The caasapplicationprovisioner facade relied on legacy Mongo-backed state for it's charm calls. However, we no longer store charms in Mongo, only DQLite. This was causing failures. Particularly, the state application methods .Charm & .CharmPendingToBeDownloaded were affected. Use domain methods for these calls instead. Drop these methods from the state interface. --- In this facade, we retrieved charms from state for the purpose of retrieving parts of their metadata. Specifically, their resources and storage specifications. This means it would be wasteful to retrieve the entire metadata. To remedy this, I have written some new domain service methods to retrieve only the data required. --- Remove unused state methods
5ea42bf
to
d2a4e0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, approved conditional on changes
@@ -200,9 +200,9 @@ func (s *State) IsCharmAvailable(ctx context.Context, id corecharm.ID) (bool, er | |||
ident := charmID{UUID: id.String()} | |||
|
|||
query := ` | |||
SELECT charm.available AS &charmAvailable.available | |||
SELECT &charmAvailable.* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that important, but for these queries I prefer SELECT &charmAvailale.available
because it makes it clear that thats all you're selecting there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simon and I prefer this
return expected | ||
}) | ||
|
||
storage, err := st.GetCharmMetadataStorage(context.Background(), id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these be put into seperate functions for testing? The preamble for this could just be put into a function that all the individual tests call. That'd give a clearer signal if any test starts failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could do, but that would lead to a lot of code duplication in the tests. I'd rather keep them like this tbh
@@ -3490,24 +3490,6 @@ func (a *Application) UnitNames() ([]string, error) { | |||
return u, errors.Trace(err) | |||
} | |||
|
|||
// CharmPendingToBeDownloaded returns true if the charm referenced by this | |||
// application is pending to be downloaded. | |||
func (a *Application) CharmPendingToBeDownloaded() bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funny that these just didn't have any tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because we recently removed all tests for state
/merge |
The caasapplicationprovisioner facade relied on legacy Mongo-backed state for it's charm calls.
However, we no longer store charms in Mongo, only DQLite. This was causing failures.
Particularly, the state application methods .Charm & .CharmPendingToBeDownloaded were affected.
Use domain methods for these calls instead. Drop these methods from the state interface.
In this facade, we retrieved charms from state for the purpose of retrieving parts of their metadata. Specifically, their resources and storage specifications.
This means it would be wasteful to retrieve the entire metadata. To remedy this, I have written some new domain service methods to retrieve only the data required.
Remove unused state methods
QA steps
Unfortunately, deploy on k8s is broken for reasons independent of this PR. So we can only rely on unit tests