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

Feature/retry policy configmap property source #446

Conversation

anavidad3
Copy link

@anavidad3 anavidad3 commented Aug 8, 2019

What changes were proposed in this pull request?

About issue #441. This pull request offers the possibility of defining a retry policy to read kubernetes configmaps to avoid some ephemeral network problems.

This closes #441

}

public ConfigMapPropertySource(KubernetesClient client, String name, String namespace,
String[] profiles) {
this(client, name, namespace, createEnvironmentWithActiveProfiles(profiles));
RetryPolicy retryPolicy, String[] profiles) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer we not change the public constructor and instead create a new one (mark these two as deprecated)

Copy link
Author

Choose a reason for hiding this comment

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

Perfect!

+ configMapMessage);
throw kce;
}
Thread.sleep(normRetryPolicy.getDelay());
Copy link
Contributor

Choose a reason for hiding this comment

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

@geoand @iocanel @spencergibb thoughts on this? Is there any other way we could do this?

Copy link
Author

Choose a reason for hiding this comment

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

My first thought was to include spring-retry but I rejected it for the simple reason that not to include a new dependency. What do you think about it?

Copy link
Contributor

@geoand geoand Aug 17, 2019

Choose a reason for hiding this comment

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

If we don't mind adding another dependency, we have used: https://github.com/awaitility/awaitility in other projects and it's pretty great.

One caveat is that I have only used for tests, so not sure what the implications are of adding it as a regular dependency

Copy link
Contributor

Choose a reason for hiding this comment

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

We have use Spring Retry in other Spring Cloud projects so I would be in favor of that

@anavidad3
Copy link
Author

anavidad3 commented Aug 21, 2019

I don't understand the error in CI flow.
I've just cloned the repository and checkout spring-boot:master branch. I have tried to build it and I've gotten the same error in local that in the PR.

Sorry if I have a misconception. Should I submit the feature against the 1.0.x stream?

@geoand
Copy link
Contributor

geoand commented Aug 22, 2019

The failure is indeed very weird. I just relaunched the job, let's see what happens

*
* @author Andres Navidad
*/
public final class RetryPolicyManager {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would actually prefer if this class was turned into an interface and we provide a default implementation as a Bean and make it @ConditionalOnMissingBean. That way if someone wants to customize this to their liking they can easily do so

…bean. Update README with these changes. Some additional test
@Jumwah
Copy link

Jumwah commented Dec 19, 2019

@anavidad3 @ryanjbaxter is there any progress on this? I'm currently trying to use SCK-ConfigMap and it doesn't work more than it does (80% failure rate) in GKE... so without this fix it feels not fit for purpose.

Any other tips on how to get this working while I wait for a release with this fix?

@anavidad3
Copy link
Author

Hi @Jumwah. PR is complete with changes requested by @ryanjbaxter. I think it's ready to be merge.

@ryanjbaxter
Copy link
Contributor

@anavidad3 I will take a look at it, but it probably won't make our Hoxton.SR1 release.

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.

Just some high level comments at the moment.

I would like @spencergibb to take a look at this as well

* maxAttempts: < 0 (infinite retries)
* maxAttempts: > 1 (number maximum of retries)

For `spring.cloud.kubernetes.config.retryPolicy.delay` property (in milliseconds):
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than delay I would be consistent and change this to be backoffpolicy

@@ -173,6 +177,10 @@
<version>${groovy.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this in here twice?

@@ -61,6 +61,10 @@
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-rsa</artifactId>
</dependency>
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be optional....ie retry is only going to happen if the app has spring-retry on the classpath

@@ -29,6 +31,8 @@

protected String namespace;

protected RetryPolicy retryPolicy;
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this used for?

@@ -48,12 +54,16 @@
@Autowired
private KubernetesClient client;

@Autowired
private RetryPolicyOperations retryPolicyOperations;

@Bean
@ConditionalOnProperty(name = "spring.cloud.kubernetes.config.enabled",
matchIfMissing = true)
public 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.

Can we not just pass RetryPolicyOperations in the method signature here?

@sagacity
Copy link

sagacity commented Mar 2, 2020

@anavidad3 Are you planning on continuing work on this PR? We are quite eager to have this feature as well, since we want to make sure nodes don't come up with partial configuration.

Otherwise, is there another way we can move the PR forward? Happy to assist.

@ryanjbaxter
Copy link
Contributor

@RoyJacobs feel free to revisit this if you want, for now I am going to close this since we have not heard back from the author.

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.

ConfigMapPropertySource can't read configMap. Retry Policy?
7 participants