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

refactor(caasapplicationprovisioner): cut over to DQLite #18571

Merged

Conversation

jack-w-shaw
Copy link
Member

@jack-w-shaw jack-w-shaw commented Dec 20, 2024

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

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
@jack-w-shaw jack-w-shaw force-pushed the JUJU-7155_cutover_caasapplicationprovisioner branch from 5ea42bf to d2a4e0e Compare December 20, 2024 12:05
Copy link
Contributor

@Aflynn50 Aflynn50 left a 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.*
Copy link
Contributor

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.

Copy link
Member Author

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)
Copy link
Contributor

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.

Copy link
Member Author

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 {
Copy link
Contributor

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.

Copy link
Member Author

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

@jack-w-shaw
Copy link
Member Author

/merge

@jujubot jujubot merged commit 4f3f676 into juju:main Dec 20, 2024
18 of 20 checks passed
@jack-w-shaw jack-w-shaw deleted the JUJU-7155_cutover_caasapplicationprovisioner branch December 20, 2024 13:03
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.

5 participants