-
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
Embed a context.Context in the environ ProviderCallContext #12953
Conversation
85933a7
to
99aeb3c
Compare
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.
Looks good. MAAS and EC2 seem fine.
@@ -14,7 +16,8 @@ type ModelCredentialInvalidator interface { | |||
// CallContext creates a CloudCallContext for use when calling environ methods | |||
// that may require invalidate a cloud credential. | |||
func CallContext(ctx ModelCredentialInvalidator) *CloudCallContext { | |||
callCtx := NewCloudCallContext() | |||
// TODO(wallyworld) - pass in the stdcontext |
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.
You're passing it now right?
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.
Not yet. This is called from various facade methods, just once in the method. It would be a lot more churn to pass in a context and unlike the workers where we were setting up a static context and reusing it, it's ok to leave this for now and follow up later to tidy up.
99aeb3c
to
fddd976
Compare
|
#13000 Merge from 2.9 to bring forward: - #12998 from wallyworld/merge-2.8-20210520 - #12996 from wallyworld/caas-remove-storage - #12991 from ycliuhw/fix/lp-1927721 - #12995 from jnsgruk/2.9 - #12994 from SimonRichardson/upgrade-series-containers-regression - #12992 from manadart/2.9-upgrades - #12982 from manadart/2.9-net-get-sort - #12990 from jujubot/increment-to-2.9.3 - #12988 from tlm/lp1928486-proxy-vars - #12989 from wallyworld/ss-service-name - #12987 from wallyworld/embeddedcli-macaroon-error - #12985 from wallyworld/export-bundle-defaults - #12984 from wallyworld/operator-charm-upgrade - #12981 from wallyworld/remove-unit-panic - #12979 from wallyworld/k8s-lxd-cloud - #12978 from wallyworld/sidecar-charm-storage-fix - #12980 from tlm/2.8-to-2.9-merge - #12972 from SimonRichardson/add-relation-error - #12970 from manadart/2.9-address-refactoring - #12976 from jujubot/increment-to-2.9.2 - #12975 from wallyworld/merge-2.8-20210513 - #12968 from ycliuhw/fix/lp-1927311 - #12973 from achilleasa/2.9-fix-misc-refresh-with-switch-issues - #12961 from manadart/2.9-store-is-secondary - #12969 from SimonRichardson/fix-static-analysis - #12964 from tlm/k8s-proxy-ssh - #12951 from ycliuhw/fix/lp-1925734 - #12962 from tlm/k8s-proxying-python-rbac - #12959 from SimonRichardson/bundle-scale-overlays - #12960 from SimonRichardson/users-cli-help-directive - #12954 from manadart/2.9-machine-config-per-nic - #12958 from wallyworld/improve-add-relation-message - #12956 from tlm/lp-1926595-libjuju - #12955 from wallyworld/destroy-model-timeout - #12957 from tlm/lp-1892255-env-vars - #12953 from wallyworld/provider-context-refactor - #12952 from manadart/2.9-transport-address-config - #12944 from wallyworld/extra-destroymodel-info Conficts: - apiserver/facades/client/action/operation.go - apiserver/facades/client/application/application.go - apiserver/facades/client/application/application_unit_test.go - apiserver/facades/controller/caasoperatorprovisioner/provisioner.go - apiserver/params/network.go - caas/kubernetes/provider/application/application_test.go - cmd/juju/application/refresher/refresher_mock_test.go - cmd/juju/application/utils/utils.go - feature/flags.go - go.mod - go.sum - provider/azure/environ.go - provider/azure/storage.go - scripts/win-installer/setup.iss - snap/snapcraft.yaml - version/version.go
We use a
environs/context.ProviderCallContext
to pass to API calls in the Environ interface. This context instance provides a callback which can be used to report invalid credentials.This PR embeds a
context.Context
in the above context. This is immediately useful for the Azure provider where the Azure SDK takes acontext.Context
and we were having to create a separate one of those ourselves. Now, we can just use a single context instance.Most of the churn here is mechanical - a common helper method used by tests was renamed.
NewCloudCallContext -> NewEmptyCloudCallContext
Also, the workers which use a context got some refactoring to create the context on demand for each API call instead of creating one up front and using that same instance each time.
A followup PR will use this work to provide a context with deadline to the environ.Destroy() call to allow model destroy operations to timeout cleanly.
QA steps
This is just a refactor. QA can be to bootstrap on a few substrates (including Azure) and deploy a few charms.