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

Issue 635 #638

Closed
wants to merge 4 commits into from
Closed

Issue 635 #638

wants to merge 4 commits into from

Conversation

krisiye
Copy link
Contributor

@krisiye krisiye commented Sep 18, 2020

Fixes #635

  1. Makes Autowired dependencies under ConfigReloadAutoConfiguration and ConfigReloadDefaultAutoConfiguration optional. That way it is consistent with conditionals on BootstrapConfiguration. The ConfigurationChangeDetector/watcher downstream honors configs for configMap or secret and registers a watcher as expected.
  2. Adds tests for use-cases where either config and/or secret is enabled or vice-versa

…m optional dependencies for reload auto config as they could be enabled/disabled through config independent of each other. Fixes spring-cloud#635
Copy link
Contributor

@ryanjbaxter ryanjbaxter left a comment

Choose a reason for hiding this comment

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

Could you submit this against the 1.1.x branch?

@@ -71,10 +71,10 @@
@Autowired
private KubernetesClient kubernetesClient;

@Autowired
@Autowired(required = false)
private ConfigMapPropertySourceLocator configMapPropertySourceLocator;
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like we can just make the bean ConfigurationChangeDetector bean condition on the presence of these PropertySourceLocators and then add them to the method signature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ryanjbaxter - Thanks for the review! The ConfigurationChangeDetector implementation takes care of the conditions and does appropriate checking before the watchers (polling/event) are registered. I believe we should be okay with that? Also I can resubmit this against 1.1.x. Do you want me to close this in favor of that? Just FYI - this issue also exists on the master branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Submitted #639 against 1.1.x

Copy link
Contributor

Choose a reason for hiding this comment

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

@krisiye are you talking about here?

https://github.com/spring-cloud/spring-cloud-kubernetes/blob/master/spring-cloud-kubernetes-config/src/main/java/org/springframework/cloud/kubernetes/config/reload/ConfigurationChangeDetector.java#L180

There is no null check...

Besides the preferred pattern here would to not autowire them and just inject them into the method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@krisiye that is why I am saying to create it conditionally

Copy link
Contributor Author

@krisiye krisiye Sep 21, 2020

Choose a reason for hiding this comment

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

@ryanjbaxter - correct me if i am wrong, you are suggesting we create ConfigurationChangeDetector beans conditionally based on either properties configMap/secrets are enabled (maybe use @ConditionalOnExpression) and in addition we would add null checks under the polling/event change detectors. Right? pushed a commit to this effect. should help with any NPE's.

Copy link
Contributor

Choose a reason for hiding this comment

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

@krisiye No what I am thinking is adding @ConditionalOnBean({ ConfigMapPropertySourceLocator.class, SecretsPropertySourceLocator.class }) on propertyChangeWatcher

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ryanjbaxter okay to close this PR and make these updates on #639 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ryanjbaxter - Updated #639 with review comments. thanks!

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.

spring-cloud-kubernetes-config options and autoconfigure not working with reload.
3 participants