-
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#18466 from SimonRichardson/include-charm-down…
…load-info juju#18466 Store the charm download information on the very first call when either setting a charm or creating an application. The driver behind this change is to allow the async charm downloader to retrieve the download URL from the application service without renegotiating the charm download URL again. Before this change, the deployment code was reliant on the charmhub store being up, even though the charm was resolved with the essential metadata (metadata, config). This also removes any chance of accidentally getting the wrong charm blob for the request. Lastly, it was possible to deploy an application and then change the charmhub URL in the model config to a proxy, which would then prevent the download of the charm. This scenario then becomes obsolete, the charm download URL is stored and we've just have direct access. ---- In order to push this through, we only store the download information for charmhub charms. It's in a new table called `charm_download_info`. We're introducing a new concept called a `charm_provenance` (I'm not wedded to that name though). It should indicate at what stage in the apiserver/service acquisition did we get the download information. The async charm downloader should only care about the `download` provenance. We won't have the download information for every iteration of the provenance, only `download` currently. Both `migration` and `upload` require changes to 3.6 to ensure that we have all that information and I'm loathed to do that at this time. At bootstrap, the `bootstrap` download information will be plumbed in at a later date. ---- This pull request introduces several changes aimed at enhancing the handling of charm download information within the application deployment process. The primary modifications include adding a new `DownloadInfo` structure, updating various functions to utilize this new structure, and adjusting mock services accordingly. Key changes include: ### Enhancements to Charm Download Information Handling: * Added `DownloadInfo` structure to store details necessary for downloading charms from CharmHub, including provenance, identifier, URL, and size (`core/charm/repository.go`, `domain/application/charm/types.go`). [[1]](diffhunk://#diff-5ae9a3927c9b2dc399e7a5f3ec6eed25fd35797095619ae9a9024754de846645R117-R130) [[2]](diffhunk://#diff-fc00f97e772cd00ee380e1996104a5ca579a356a9a07028d1d75f28161df0bbfR156-R207) * Updated `DeployApplication` and `DeployFromRepository` functions to handle `DownloadInfo` when deploying charms (`apiserver/facades/client/application/deploy.go`, `apiserver/facades/client/application/deployrepository.go`). [[1]](diffhunk://#diff-1939e2205f5e423b58928b9628a4023f3d526a88e846da6ef2c5b0d14a7148edR169-R189) [[2]](diffhunk://#diff-fec6df289495bdefe1c76addc3c69be52ed4cfffccd124b83e06f9dc3abba18cR173-R179) * Modified `GetCharmDownloadInfo` method in `ApplicationService` interface to retrieve charm download information using charm ID (`apiserver/facades/client/application/service.go`). ### Adjustments to Validation and Resource Resolution: * Refined the `validate` function in `deployrepository.go` to incorporate `DownloadInfo` during charm validation and resource resolution (`apiserver/facades/client/application/deployrepository.go`). [[1]](diffhunk://#diff-fec6df289495bdefe1c76addc3c69be52ed4cfffccd124b83e06f9dc3abba18cL399-R423) [[2]](diffhunk://#diff-fec6df289495bdefe1c76addc3c69be52ed4cfffccd124b83e06f9dc3abba18cL427-R443) * Introduced `charmResult` struct to encapsulate charm-related data, including `DownloadInfo`, in the `getCharm` function (`apiserver/facades/client/application/deployrepository.go`). [[1]](diffhunk://#diff-fec6df289495bdefe1c76addc3c69be52ed4cfffccd124b83e06f9dc3abba18cR901-R913) [[2]](diffhunk://#diff-fec6df289495bdefe1c76addc3c69be52ed4cfffccd124b83e06f9dc3abba18cL906-R933) ### Updates to Mock Services: * Added mock implementations for `GetCharmDownloadInfo` in `MockApplicationService` to support unit testing (`apiserver/facades/client/application/services_mock_test.go`). These changes collectively enhance the robustness and flexibility of the charm deployment process by ensuring that detailed download information is consistently handled and validated across various components of the application. ## QA steps Bundles are currently toast, so we'll need to sweep back around and fix them at some point. ```sh $ juju bootstrap lxd test $ juju add-model default $ juju deploy ubuntu $ make repl-install $ make repl dqlite> SELECT prdesc FROM namespace_list $ DB_NAME="<select the last one in the list>" make repl dqlite> SELECT prdesc FROM charm dqlite> SELECT prdesc FROM charm_download_info ``` Testing migration should also be done. ## Links https://warthogs.atlassian.net/browse/JUJU-7166
- Loading branch information
Showing
47 changed files
with
1,802 additions
and
522 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
39 changes: 39 additions & 0 deletions
39
apiserver/facades/client/application/services_mock_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.