diff --git a/operator/src/main/java/io/reshapr/kubernetes/operator/auth/ReshaprApiClientFactory.java b/operator/src/main/java/io/reshapr/kubernetes/operator/auth/ReshaprApiClientFactory.java index 401d236..aca9b6a 100644 --- a/operator/src/main/java/io/reshapr/kubernetes/operator/auth/ReshaprApiClientFactory.java +++ b/operator/src/main/java/io/reshapr/kubernetes/operator/auth/ReshaprApiClientFactory.java @@ -65,6 +65,10 @@ public String resolveControlPlaneUrl(String serviceName) { * @return The base URL of the control plane. */ public String resolveControlPlaneUrl(String serviceName, String namespace, int port) { + // If service name already ends with the cluster local suffix, use it as is. + if (serviceName.endsWith(".svc.cluster.local")) { + return "http://" + serviceName + ":" + port; + } // If service name contains a dot, assume it's qualified with namespace. if (serviceName.contains(".")) { return "http://" + serviceName + ".svc.cluster.local:" + port; diff --git a/operator/src/main/java/io/reshapr/kubernetes/operator/auth/ReshaprAuthenticationService.java b/operator/src/main/java/io/reshapr/kubernetes/operator/auth/ReshaprAuthenticationService.java index 331d405..9709bb2 100644 --- a/operator/src/main/java/io/reshapr/kubernetes/operator/auth/ReshaprAuthenticationService.java +++ b/operator/src/main/java/io/reshapr/kubernetes/operator/auth/ReshaprAuthenticationService.java @@ -91,8 +91,10 @@ public String authenticate(String controlPlaneBaseUrl, String organization) "Authentication failed with status " + response.statusCode() + ": " + response.body()); } - } catch (IOException | InterruptedException e) { + } catch (InterruptedException e) { Thread.currentThread().interrupt(); + throw new ReshaprAuthenticationException("Interrupted while authenticating with reShapr control plane", e); + } catch (IOException e) { throw new ReshaprAuthenticationException("Failed to authenticate with reShapr control plane", e); } }