You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/08/03 08:27:11 UTC
[camel] branch camel-3.20.x updated: CAMEL-19701: camel-main - Filter out k8s injected service ENV variables that can cause camel-main to fail startup. (#10971)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.20.x by this push:
new d0826866e88 CAMEL-19701: camel-main - Filter out k8s injected service ENV variables that can cause camel-main to fail startup. (#10971)
d0826866e88 is described below
commit d0826866e88a6223d465f175983883fb6a5cae73
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Aug 3 10:26:04 2023 +0200
CAMEL-19701: camel-main - Filter out k8s injected service ENV variables that can cause camel-main to fail startup. (#10971)
---
.../src/main/java/org/apache/camel/main/MainHelper.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java b/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
index 35d1cf94a1b..8d7e04bdf59 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
@@ -120,9 +120,17 @@ public final class MainHelper {
final String pk2 = pk.replace('-', '_');
System.getenv().forEach((k, v) -> {
k = k.toUpperCase(Locale.US);
- if (k.startsWith(pk) || k.startsWith(pk2)) {
- String key = k.toLowerCase(Locale.US).replace('_', '.');
- answer.put(key, v);
+ // kubernetes ENV injected services should be skipped
+ // (https://learn.microsoft.com/en-us/visualstudio/bridge/kubernetes-environment-variables#environment-variables-table)
+ boolean k8s = k.endsWith("_SERVICE_HOST") || k.endsWith("_SERVICE_PORT") || k.endsWith("_PORT")
+ || k.contains("_PORT_");
+ if (k8s) {
+ LOG.trace("Skipping Kubernetes Service OS environment variable: {}", k);
+ } else {
+ if (k.startsWith(pk) || k.startsWith(pk2)) {
+ String key = k.toLowerCase(Locale.US).replace('_', '.');
+ answer.put(key, v);
+ }
}
});
}