-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Refactor k8s client reload #1902
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
Changes from all commits
0e73b14
7c441df
1e70cab
074404c
e67cc1a
b851f9c
71c9c89
adfe2b5
92405f2
bd1599b
96fca8d
2057672
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| import org.springframework.cloud.bootstrap.config.BootstrapPropertySource; | ||
| import org.springframework.cloud.bootstrap.config.PropertySourceLocator; | ||
| import org.springframework.cloud.kubernetes.commons.config.MountConfigMapPropertySource; | ||
| import org.springframework.cloud.kubernetes.commons.config.SecretsPropertySource; | ||
| import org.springframework.core.env.CompositePropertySource; | ||
| import org.springframework.core.env.ConfigurableEnvironment; | ||
| import org.springframework.core.env.MapPropertySource; | ||
|
|
@@ -120,6 +121,10 @@ else if (propertySource instanceof MountConfigMapPropertySource mountConfigMapPr | |
| // we know that the type is correct here | ||
| managedSources.add((S) mountConfigMapPropertySource); | ||
| } | ||
| else if (propertySource instanceof SecretsPropertySource secretsPropertySource) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am fixing a bug here with this one. In case of configmaps, when we create a property source from paths, we create an instance of which means that reloads will take it into consideration. While refactoring one integration test, I saw that it is failing, and after some debugging, realized that we have no code like the above for secrets. As such, I added that simple condition, because when we create a property source from paths in case of secrets, we create an instance of |
||
| // we know that the type is correct here | ||
| managedSources.add((S) secretsPropertySource); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -179,6 +184,8 @@ static boolean changed(List<? extends MapPropertySource> k8sSources, List<? exte | |
| for (int i = 0; i < k8sSources.size(); i++) { | ||
| MapPropertySource k8sSource = k8sSources.get(i); | ||
| MapPropertySource appSource = appSources.get(i); | ||
| System.out.println("k8sSource (abc): " + k8sSource.getSource()); | ||
| System.out.println("appSource (abc): " + appSource.getSource()); | ||
| if (changed(k8sSource, appSource)) { | ||
| LOG.debug(() -> "found change in : " + k8sSource); | ||
| return true; | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,14 @@ | ||
| logging: | ||
| level: | ||
| root: DEBUG | ||
|
|
||
| spring: | ||
| cloud: | ||
| kubernetes: | ||
| config: | ||
| sources: | ||
| - namespace: left | ||
| name: left-configmap | ||
| - namespace: right | ||
| name: right-configmap | ||
| - namespace: right | ||
| name: right-configmap-with-label | ||
|
|
||
| # otherwise on context refresh we lose this property | ||
| # and test fails, since beans are not wired. | ||
| main: | ||
| cloud-platform: kubernetes |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,12 @@ | ||
| logging: | ||
| level: | ||
| root: DEBUG | ||
|
|
||
| spring: | ||
| cloud: | ||
| kubernetes: | ||
| config: | ||
| sources: | ||
| - namespace: left | ||
| name: left-configmap | ||
| - namespace: right | ||
| name: right-configmap | ||
|
|
||
| # otherwise on context refresh we lose this property | ||
| # and test fails, since beans are not wired. | ||
| main: | ||
| cloud-platform: kubernetes |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,12 @@ | ||
| spring: | ||
| cloud: | ||
| kubernetes: | ||
| config: | ||
| secrets: | ||
| paths: | ||
| - /tmp/application.properties | ||
| # at the moment, we do not support reading properties/yaml/yml | ||
| # files when mounting via 'paths' | ||
| - /tmp/from.properties.secret.key | ||
| enabled: true | ||
|
|
||
| config: | ||
| enabled: false |
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.
we do this for configmaps, but not for secrets, so I decided to add it here