question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fabric8ProfileEnvironmentPostProcessor seems to do a bit "too little"

See original GitHub issue

Sorry for a bad description, I could not come up with a better one.

This is not really a bug, but more of a question to see if it’s OK for me to fix this or not. Currently, Fabric8ProfileEnvironmentPostProcessor has isInsideKubernetes defined as:

	@Override
	protected boolean isInsideKubernetes(Environment environment) {
		try (DefaultKubernetesClient client = new DefaultKubernetesClient()) {
			final Fabric8PodUtils podUtils = new Fabric8PodUtils(client);
			return environment.containsProperty(KUBERNETES_SERVICE_ENV_VAR) || podUtils.isInsideKubernetes();
		}
	}

it checks for KUBERNETES_SERVICE_ENV_VAR being present in Environment.

On the other hand podUtils::isInsideKubernetes, specifically checks if “currently we are inside k8s”. Though, besides the KUBERNETES_SERVICE_ENV_VAR property, it also checks HOSTNAME and the presence of both /var/run/secrets/kubernetes.io/serviceaccount/token and /var/run/secrets/kubernetes.io/serviceaccount/ca.crt.

IMO, the check environment.containsProperty(KUBERNETES_SERVICE_ENV_VAR) is too “thin” to prove if we are currently inside kubernetes or not.

This long description is to propose the change to become:

	@Override
	protected boolean isInsideKubernetes(Environment environment) {
		try (DefaultKubernetesClient client = new DefaultKubernetesClient()) {
			final Fabric8PodUtils podUtils = new Fabric8PodUtils(client);
			return podUtils.isInsideKubernetes();
		}
	}

The change itself is trivial, but will require some changes for the tests to correctly work.

I will take this and work on it, only if you agree on the change. Thank you.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
wind57commented, Feb 17, 2021

yes. I will take that in a future PR. It’s a minor thing, indeed

0reactions
ryanjbaxtercommented, Feb 17, 2021

Basically just using Fabric8PodUtils instead of defining the variable name ourselves?

Read more comments on GitHub >

github_iconTop Results From Across the Web

spring.cloud.kubernetes.enabled=false is not read ... - GitHub
I am a tiny bit confused, can you explain please where ... is already a transitive dependency from spring-cloud-starter-kubernetes-fabric8-config so the ...
Read more >
fabric8io/fabric8-maven-plugin
Enrichment of resource fragments can be fine-tuned by using profile sub-directories. For more details see Profiles. Now that we have seen some ...
Read more >
Exception on spring application startup with spring-cloud ...
I have a few spring services which has both Eureka-client and spring-cloud-starter-kubernetes-fabric8-all dependencies.
Read more >
spring-cloud.pdf
Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service.
Read more >
Baeldung Author
Learn a few techniques for getting the number of messages in a Kafka topic. ... Learn how a Java program can detect whether...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found