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

Use OpenAPI to set the default ProviderConfig #252

Merged
merged 1 commit into from
Mar 14, 2021

Conversation

negz
Copy link
Member

@negz negz commented Mar 11, 2021

Description of your changes

This allows us to avoid an extra update call to the API server when new managed resources are created.

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

I've tested this by building provider-gcp against this commit, and ensuring that spec.providerConfigRef.name is defaulted even when the provider is not running.

This allows us to avoid an extra update call to the API server when new managed
resources are created.

Signed-off-by: Nic Cope <negz@rk0n.org>
@negz negz requested review from muvaf and hasheddan March 11, 2021 08:04
@@ -367,11 +367,8 @@ func defaultMRManaged(m manager.Manager) mrManaged {
return mrManaged{
ConnectionPublisher: NewAPISecretPublisher(m.GetClient(), m.GetScheme()),
Finalizer: resource.NewAPIFinalizer(m.GetClient(), managedFinalizerName),
Initializer: InitializerChain{
NewDefaultProviderConfig(m.GetClient()),
Copy link
Member Author

Choose a reason for hiding this comment

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

I considered leaving this out of an abundance of caution, because:

  • It's a no-op when the ProviderConfigReference is already set.
  • Many providers assume the ProviderConfigReference will never be nil
  • It's possible that a provider will be built against this library, but forget to generate/apply new CRDs.

I decided to just remove it, given that it's very unlikely anyone using the package manager and our standard build tooling would ever end up accidentally deploying new provider code without also updating their CRDs.

Copy link
Member

@muvaf muvaf left a comment

Choose a reason for hiding this comment

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

LGTM! Note that many managed resources that opt out of NewNameAsExternalName manually set NewDefaultProviderConfig as initializer. Though I don't think it's necessary to address that now.

@@ -139,6 +139,7 @@ type ResourceSpec struct {
// ProviderConfigReference specifies how the provider that will be used to
// create, observe, update, and delete this managed resource should be
// configured.
// +kubebuilder:default={"name": "default"}
Copy link
Member

Choose a reason for hiding this comment

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

I didn't know you could give an object here, nice.

@negz
Copy link
Member Author

negz commented Mar 14, 2021

Note that many managed resources that opt out of NewNameAsExternalName manually set NewDefaultProviderConfig as initializer. Though I don't think it's necessary to address that now.

I agree. I'm pretty sure for those managed resources the NewDefaultProviderConfig logic will just become a no-op because spec.providerConfigRef.name will never be unset, so I think we should just surface this deprecation in the release notes then let providers update at their leisure. I think our linter config complains when folks try to use a function with a // Deprecated comment, which will help bug folks to update.

@negz negz merged commit c0539b3 into crossplane:master Mar 14, 2021
@negz negz deleted the thetwosweetestwords branch March 14, 2021 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants