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 wrong labels and annotations in kubernetes discovery native client #1282

Merged

Conversation

wind57
Copy link
Contributor

@wind57 wind57 commented Apr 1, 2023

No description provided.

wind57 and others added 30 commits December 4, 2021 07:59
@@ -112,27 +113,7 @@ public List<ServiceInstance> getInstances(String serviceId) {
}

private Stream<ServiceInstance> getServiceInstanceDetails(V1Service service, String serviceId) {
Map<String, String> svcMetadata = new HashMap<>();
Copy link
Contributor Author

@wind57 wind57 Apr 1, 2023

Choose a reason for hiding this comment

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

this PR fixes an issue, imo. if you look at this piece of code:

service.getMetadata().getAnnotations().entrySet().stream()
							.filter(e -> e.getKey().startsWith(annotationPrefix))
							.forEach(e -> svcMetadata.put(e.getKey(), e.getValue()));

it says that we are going to take only annotations that start with annotationPrefix. In the fabric8 implementation we do it differently: we prefix existing values with it. As a matter of fact we do this in configmaps and secrets property sources also.

As such, I removed this code and fixed the bug in the utils class, where the code is the same as in the fabric8 implementation. Also added tests.

serviceMetadata.putAll(annotationMetadata);
}

serviceMetadata.put(NAMESPACE_METADATA_KEY,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

metadata now includes two more fields, just like we do in the fabric8 implementation.

@wind57 wind57 changed the title Fix wrong labels and annotations Fix wrong labels and annotations in kubernetes discovery native client Apr 4, 2023
Assertions.assertEquals(serviceInstance.getServiceId(), "spring-cloud-kubernetes-client-discovery-it");
Assertions.assertNotNull(serviceInstance.getHost());
Assertions.assertEquals(serviceInstance.getMetadata(),
Map.of("http", "8080", "k8s_namespace", "default", "type", "ClusterIP",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

an integration test that asserts for proper labels and annotations with prefix

@wind57 wind57 marked this pull request as ready for review April 4, 2023 20:21
@wind57
Copy link
Contributor Author

wind57 commented Apr 4, 2023

@ryanjbaxter this one can be looked at too. I started to fix some issues as I dive into the implementation and have fabric8 context in my head

@ryanjbaxter ryanjbaxter added this to the 3.0.3 milestone Apr 5, 2023
@ryanjbaxter ryanjbaxter merged commit 640602b into spring-cloud:main Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants