-
Notifications
You must be signed in to change notification settings - Fork 510
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
Add display type for network-get results #12853
Conversation
results to stdout. A conversion method copies params.NetworkInfoResult into the display type. We should never be writing raw DTOs as output - they should be restricted to use as API arguments/results.
results. The main fields now have YAML tags corresponding with those from the JSON.
a171966
to
ea78216
Compare
@@ -10,6 +10,7 @@ import ( | |||
"github.com/juju/errors" | |||
"github.com/juju/gnuflag" | |||
|
|||
"github.com/juju/juju/apiserver/params" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to avoid this import? Can we shove the params conversion bits into one of the api client packages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes me wrinkle my nose too, but we would have to move the display types to a third package and export them. A nice place wasn't jumping out at me - got any ideas?
We would also have to update various mocks and stubs if we change the signature of the method on context
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, the wire representation should only be used between the clients and the facades. The client should do the params -> model conversion. We should be working with core/network types in this package and map them to structs as you do here for display purposes (we use the same pattern for juju status).
If changing the code to use that pattern would be too much effort, I don't mind approving this PR but I am a bit worried that eventually all the client-side bits will have a dependency on the params package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this import doesn't change the types that we are actually dealing with (we always were working with a params.NetworkInfo, we just didn't have a local function that needed us to define a parameter to the function).
So in that, this isn't a regression of dependencies, it is more an explicit declaration of what we already used, and reworking the actual intermediate apis to do it differently feels out of scope for this work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the cleanup, Joe.
|
#12909 Merge 2.9 #12827 Unsubscribe from hub when closing state pool #12829 Correct default bootstrap-timeout value displayed in help. #12840 Constraint tags can be used for pod affinity #12842 Fix upgrade series agent version handling #12794 Add disk provisioning customization #12845 Restore space support for manual machines #12839 Support merging of netplan configs #12853 Add display type for network-get results #12854 Fix for LP1921557 sni in Juju login. #12850 Use Base in Charmhub packge and its response structures. #12858 Ensure assess-upgrade-series does not report started prematuremly #12860 Removed logging from core annotations. #12861 Fixes bug where empty error can happen in storage #12865 Update Pebble version to include new files API #12866 Workaround for k8s dashboard URL with k8s client proxy #12862 Fix/lp 1923051 #12867 Fix/lp 1923561 #12870 Use channel logic in charm library #12873 Add support for setting pod affinity topology key #12874 Use Patch instead of Update for ensuring ingress resources #12831 Integration fixes #12879 Ensure refresh uses version #12864 bug: fix for bootstrap fail on vsphere 7 + multi network #12883 Initial work to allow juju trust for sidecar charms #12884 Fix ssh with sidecar charms and containers. #12886 Charmhub bases #12881 Use charm pkg updates #12889 Ignore projected volume mounts when looking up juju storage #12890 Fix passing empty string container name to unit params #12893 Add CLA checker GH action and remove codecov push action #12897 Use production charmhub endpoint #12887 Resource validation error #12888 Ensure we validate the model target #12898 Remove usage of systems package from CAAS application provisioner #12899 CAAS bundle deployments #12900 Bump up Pebble version to include user/group in list-files #12901 charm Format helper #12902 charm Iskubernetes helper #12903 Display ... for really long k8s app versions in status #12904 Filter out more full registry paths for app version in status #12905 Fix k8s bundle deploys with v2 charms #12906 Register resource-get for containeragent binary Conflicts mostly due to charm v8 vs v9 imports. The other one was due to changes to dashboard CLI. ``` # Conflicts: # api/common/charms/common.go # api/common/charms/common_test.go # apiserver/facades/client/application/application.go # apiserver/facades/client/application/charmstore.go # apiserver/facades/client/application/update_series_mocks_test.go # apiserver/facades/client/charms/client.go # apiserver/facades/client/charms/convertions.go # apiserver/facades/client/machinemanager/types_mock_test.go # apiserver/facades/controller/caasoperatorprovisioner/provisioner.go # cmd/juju/application/deployer/bundlehandler_test.go # cmd/juju/application/refresh_test.go # cmd/juju/application/refresher/refresher_mock_test.go # cmd/juju/dashboard/dashboard.go # core/charm/strategies_mock_test.go # core/model/model.go # core/model/model_test.go # go.mod # go.sum # resource/resourceadapters/charmhub.go # scripts/win-installer/setup.iss # service/agentconf_test.go # snap/snapcraft.yaml # state/charm.go # state/migration_export.go # state/state.go # version/version.go # worker/caasfirewallerembedded/applicationworker.go # worker/caasfirewallerembedded/applicationworker_test.go ``` ## QA steps See PRs
#14037 This patch is a follow-up on #12853. There, we added a work-around for the fact that types used to display `network-get` results had tags for JSON, but not YAML. We added new display types with YAML tags, but also preserved the legacy field names in the event that charm logic still relied upon them. This does the same for the `interfaceAddressDisplay` type, where the `Address` field was either `value` (JSON) or `address` (YAML). ## QA steps - Bootstrap to LXD. - `juju deploy ubuntu` - `juju run --unit ubuntu/0 "network-get juju-info --format json"|jq .` should render as before: ```json { "bind-addresses": [ { "mac-address": "00:16:3e:95:00:2d", "interface-name": "eth0", "addresses": [ { "hostname": "", "value": "10.161.87.143", "cidr": "10.161.87.0/24" } ] } ], "egress-subnets": [ "10.161.87.143/32" ], "ingress-addresses": [ "10.161.87.143" ] } ``` - `juju run --unit ubuntu/0 "network-get juju-info --format yaml"` will include both `address` and `value`: ```yaml bind-addresses: - mac-address: 00:16:3e:95:00:2d interface-name: eth0 addresses: - hostname: "" value: 10.161.87.143 cidr: 10.161.87.0/24 address: 10.161.87.143 macaddress: 00:16:3e:95:00:2d interfacename: eth0 egress-subnets: - 10.161.87.143/32 ingress-addresses: - 10.161.87.143 ``` ## Documentation changes None. ## Bug reference N/A
To-date, the JSON and YAML representations of
params.NetworkInfo
have been inconsistent due to the omission of YAML serialisation tags.This wouldn't normally be an issue but for the fact that we use the wire type for display purposes, which we should never do.
Here, we add dedicated display types and a conversion method to produce them from
params.NetworkInfoResult
. YAML tags are added to make them consistent with the JSON, but we also include field copies with the legacy YAML tags so as not to break old agents.For the next major Juju version, the compatibility fields can be removed.
QA steps
juju deploy ubuntu
juju run --unit ubuntu/0 "network-get juju-info --format json"|jq .
should render as before:juju run --unit ubuntu/0 "network-get juju-info --format yaml
should include both old and new field names:Documentation changes
None.
Bug reference
https://bugs.launchpad.net/juju/+bug/1915418