-
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#18497 from Aflynn50/wire-up-uniter-applicatio…
…n-watcher juju#18497 This PR includes juju#18448. Before this change, the uniter API embedded the AgentEntityWatcher. This provided the Watch method on the api and would look up the entity in state and return a notify watcher. The attach-resource command increments the CharmModifiedField in state and therefor triggers the watcher. With resources being moved to DQLite, and the charm_modified_version integer now being in the application table in domain, this watcher needs to be watching this table instead. Not all application functionality has yet been moved over to DQLite. This could pose an issue, as the uniter checks the CharmModifiedVersion and the CharmURL when the watcher is triggered. The charm URL should work as expected as this is currently written in DQLite. The CharmModifiedVersion is incremented in state in two places. I found this via the incCharmModifiedVersionOps method and couldn't find any other places it was set. They are: - When a resource is set - this will be take care of in the upcoming resources work. - When a charm is changed with SetCharm (there are two callsites in this method to incCharmModifiedVersionOps) - The only call remaining for this method is doulbe written to DQLite. Watching the application table in DQLite instead of these should be safe for the reasons above. The change made is to remove the AgentEntityWatcher from the UniterAPI and implement a Watch and WatchApplication on the UniterAPI directly. The Watch method is kept only so that the uniter API can work with 3.x clients. The ApplicationWatcher uses the watcher from the application service, and the Watch method checks if the tag is an application, if it is, the Watcher used is from the application service. If it is a unit watcher, it still watches mongo state. <!-- The PR title should match: <type>(optional <scope>): <description>. Please also ensure all commits in this PR comply with our conventional commits specification: https://github.com/juju/juju/blob/main/doc/conventional-commits.md --> <!-- 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 - [ ] [Integration tests](https://github.com/juju/juju/tree/main/tests), with comments saying what you're testing - [x] [doc.go](https://discourse.charmhub.io/t/readme-in-packages/451) added or updated in changed packages ## QA steps Using [`juju sql`](https://discourse.charmhub.io/t/juju-4-0-shortcut-to-get-the-dqlite-repl-from-the-command-line/15394) ``` juju bootstrap lxd test-watcher juju add-model m juju model-config logging-config="<root>=DEBUG" juju deploy juju-qa-test # Get the model UUID juju show-model # Go to DQLite repl on the model database juju sql 0 <model-uuid> # Verify that the application is there and get its UUID dqlite> SELECT prdesc FROM application dqlite> UPDATE application SET charm_modified_version=1 WHERE uuid="<application-uuid>" # ssh into the unit lxc exec <unit-machine> bash cd /var/log/juju vim unit-juju-qa-test-0.log ``` You should find the follow lines from just after when you did the update: ``` 2024-12-05 11:24:38 DEBUG juju.worker.uniter.remotestate loggo.go:44 got application change for juju-qa-test/0 ... 2024-12-05 11:24:38 DEBUG juju.worker.uniter resolver.go:333 upgrade from CharmModifiedVersion 0 to 1 ``` I tried to trigger the only remote state debug messages with ` juju model-config -m controller logging-config="juju.worker.uniter.remotestate=DEBUG"`, just doing `<root>=DEBUG` gives you quite a lot of output if anyone knows why that isn't working for me let me know! ### Migration test Test that a 3.6 agent can communicate with a 4.0 controller. This QA caught that the watch unit method also used the generic watch, and we should also add a WatchUnit method to the v20 facade and use that. ``` snap refresh juju --channel=3.6/stable /snap/bin/juju bootstrap lxd source /snap/bin/juju add-model mig /snap/bin/juju deploy juju-qa-test juju bootstrap lxd target juju migrate source:mig target juju status # Check debug logs for errors juju debug-log juju debug-log -m controller ``` Adding a unit does not work because the charm cannot be fetched from model storage, this is an unrelated breakage. ### K8s resource test ``` sudo make microk8s-operator-update juju bootstrap microk8s test-k8s juju add-model m juju deploy hello-kubecon watch juju status ``` Check that the app is up and running with no issues. ## Links <!-- Link to all relevant specification, documentation, bug, issue or JIRA card. --> **Jira card:** [JUJU-7106](https://warthogs.atlassian.net/browse/JUJU-7106) [JUJU-7106]: https://warthogs.atlassian.net/browse/JUJU-7106?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
- Loading branch information
Showing
14 changed files
with
384 additions
and
94 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
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
Oops, something went wrong.