-
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#17635 from SimonRichardson/charm-state
juju#17635 The change set adds simple getter and setter methods, along with getting the charm metadata. Getting the charm metadata from the database is quite involved. We have to select from a lot of tables to populate the metadata. This is really wasteful if the code only wants the relations. It is also not time efficient to get all the metadata as row based type. If a charm metadata is fully populated it could result in thousands of rows to populate. Having spoken with others, it was then decided to not use row-based requests for getting metadata. Instead, we'll fallback to multiple selects. The advantage of doing it this way is that we can reuse the individual methods to expose calls to get just relations or storage. There is a potential problem with arrays. Duplicates of values are possible in the charm metadata and we don't prevent that in any part of the library. Also, tables are sets of rows, not ordered rows based on insertion time. The solution was to keep a tracking index column that ensures that we preserve the insertion order and that we use that as the unique key. Unfortunately, I ran into a sqlair bug[1], so had to change tack and ensure that we could get the right information out that we wanted. This meant that we stuck to the error conditions. If the charm doesn't exist we return NotFound, rather than the default case. Actions, config, manifest, and LXD profiles will be added in a future PR, as this is already getting difficult to review in one patch. 1. canonical/sqlair#154 <!-- Why this change is needed and what it does. --> ## 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 ## QA steps The schema should apply nicely. Regression tests around bootstrap and deployment should be done. ```sh $ juju bootstrap lxd test --build-agent $ juju add-model default $ juju deploy ubuntu ``` ## Links **Jira card:** [JUJU-6015](https://warthogs.atlassian.net/browse/JUJU-6015) [JUJU-6015]: https://warthogs.atlassian.net/browse/JUJU-6015?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
- Loading branch information
Showing
18 changed files
with
2,923 additions
and
104 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
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
Oops, something went wrong.