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

[JUJU-3505] AllWatcher additional attrs #15529

Merged
merged 1 commit into from Apr 25, 2023

Conversation

SimonRichardson
Copy link
Member

@SimonRichardson SimonRichardson commented Apr 24, 2023

In order to help with the dashboard UI and to remove redundant subsequent calls to the API server for the same data, we just expose more information from the AllWatcher.

The code turned out to be relatively simple, we just weren't exposing it. Although, I'm starting to believe the AllWatcher is an anti-pattern, by sending data with the changes, rather than just what's changed leading to a better query API. The downside with the AllWatcher is that the data being sent has to accommodate all the data and it very much feels like we're passing data via a back channel. The API itself would be better served with a better query API.

Checklist

  • Code style: imports ordered, good names, simple structure, etc
  • Comments saying why design decisions were made
  • Go unit tests, with comments saying what you're testing

QA steps

Apply the following diff:

diff --git a/cmd/juju/waitfor/model.go b/cmd/juju/waitfor/model.go
index b495e3ff63..9c52bc8516 100644
--- a/cmd/juju/waitfor/model.go
+++ b/cmd/juju/waitfor/model.go
@@ -7,6 +7,7 @@ import (
        "io"
        "time"

+       "github.com/davecgh/go-spew/spew"
        "github.com/juju/cmd/v3"
        "github.com/juju/errors"
        "github.com/juju/gnuflag"
@@ -142,7 +143,7 @@ func (c *modelCommand) primeCache() {
 func (c *modelCommand) waitFor(ctx ScopeContext) func(string, []params.Delta, query.Query) (bool, error) {
        return func(name string, deltas []params.Delta, q query.Query) (bool, error) {
                for _, delta := range deltas {
-                       logger.Tracef("delta %T: %v", delta.Entity, delta.Entity)
+                       logger.Criticalf("delta %T: %v", delta.Entity, spew.Sdump(delta.Entity))

                        switch entityInfo := delta.Entity.(type) {
                        case *params.ApplicationInfo:
$ juju bootstrap lxd test --build-agent
$ juju add-model default
$ juju wait-for model default

You should now see the new changes in the log from the model.

Bug reference

https://bugs.launchpad.net/juju/+bug/1939341

In order to help with the dashboard UI and to remove redundant subsequent
calls to the API server for the same data, we just expose more information
from the all watcher.

The code turned out to be relatively simple, we just weren't exposing it.
Although, I'm starting to believe the all watcher is anti-pattern, by
sending data with the changes, rather than just what's changed leading to
a better query API. The downsides with the all watcher is that the data
being sent has to accomindate all the data and it very much feels like
we're passing data via a back channel. The API itself would be better
served with a better API.
@SimonRichardson SimonRichardson added bug The PR addresses a bug 3.2 labels Apr 24, 2023
@SimonRichardson SimonRichardson self-assigned this Apr 24, 2023
Copy link
Member

@hmlanigan hmlanigan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, works as expected.

@SimonRichardson
Copy link
Member Author

/merge

@jujubot jujubot merged commit 16b16a4 into juju:3.2 Apr 25, 2023
18 of 19 checks passed
@barrettj12 barrettj12 mentioned this pull request May 9, 2023
jujubot added a commit that referenced this pull request May 9, 2023
@barrettj12 barrettj12 mentioned this pull request May 10, 2023
jujubot added a commit that referenced this pull request May 10, 2023
@SimonRichardson SimonRichardson deleted the all-watcher-attrs branch September 20, 2023 15:31
@anvial anvial mentioned this pull request Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The PR addresses a bug
Projects
None yet
3 participants