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

Fix 1323 part 1 #1327

Merged
merged 59 commits into from
Apr 28, 2023
Merged

Fix 1323 part 1 #1327

merged 59 commits into from
Apr 28, 2023

Conversation

wind57
Copy link
Contributor

@wind57 wind57 commented Apr 27, 2023

No description provided.

wind57 and others added 30 commits December 4, 2021 07:59
/**
* Strategy that does nothing.
*/
public static final ConfigurationUpdateStrategy NOOP = new ConfigurationUpdateStrategy("no-op", () -> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is needed for configuration watcher, when reload is disabled. In that case, we do not care about a ConfigurationUpdateStrategy. The only reason we need it, is because we extend various classes that need it via the calls to super, but in the configuration watcher itself, we make no use of it.

I can go into the details here, if needed, just let me know.

envVars.add(watcherDebug);

if (disableReload) {
V1EnvVar disableReloadEnvVar = new V1EnvVar().name("SPRING_CLOUD_KUBERNETES_RELOAD_ENABLED").value("FALSE");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

disable reload: SPRING_CLOUD_KUBERNETES_RELOAD_ENABLED - app still works. This test fails, without the fix that we did here.

I've also "tested" a build with disabling reload everywhere - that is, in the configuration watcher application.yaml and it passed all the integration tests.

@wind57 wind57 marked this pull request as ready for review April 27, 2023 11:23
@wind57
Copy link
Contributor Author

wind57 commented Apr 27, 2023

@ryanjbaxter part-1 of the recent issue we discussed recently. I've separated these in two PRs (one coming later), because it is easier to review and debate if needed. Thank you for looking into it.

* @author wind57
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(value = "spring.cloud.kubernetes.reload.enabled", havingValue = "false", matchIfMissing = true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

when reload is disabled, bring in this dependency, otherwise the context does not start

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really want matchIfMissing=true? ConfigReloadAutoConfiguration will be enabled in this case and we will end up with that auto configuration creating a ConfigurationUpdateStrategy. I guess this bean would not be created because there already by one, but we really only need this bean in the case where spring.cloud.kubernetes.reload.enabled=false so to me I would remove the matchIfMissing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's consider the case when spring.cloud.kubernetes.reload.enabled is simply not defined. We will have:

...
@ConditionalOnKubernetesReloadEnabled
....
public class ConfigReloadAutoConfiguration {

because ConditionalOnKubernetesReloadEnabled is defined as:

@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@ConditionalOnProperty(name = "spring.cloud.kubernetes.reload.enabled", havingValue = "true")
public @interface ConditionalOnKubernetesReloadEnabled {

}

it will resolve to not match this conditional, as such it will not pick up this auto-configuration.

If we do not have matchIfMissing=true, it will not pick up the new auto-configuration either. no?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes, sorry I was asumming ConditionalOnKubernetesReloadEnabled had matchIfMissing=true.

@ryanjbaxter
Copy link
Contributor

Is the second pr dependent on this one?

@wind57
Copy link
Contributor Author

wind57 commented Apr 27, 2023

no.

the other issue is the fact that we react and schedule a reload event even if nothing changed in the config maps/secrets. They are totally independent, to me.

@ryanjbaxter
Copy link
Contributor

OK let me know when the other PR is ready and we can merge these both together

@ryanjbaxter ryanjbaxter merged commit cd24fda into spring-cloud:main Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Watcher refreshes the application even if the ConfigMap hasn't changed
3 participants