From 7357bf3b37d9f42c34dcfdb918607b5d94ebf08c Mon Sep 17 00:00:00 2001 From: Vaishnav88sk Date: Wed, 10 Jun 2026 00:47:12 +0530 Subject: [PATCH] fix: auth module dns resolution and code quality Signed-off-by: Vaishnav88sk --- .../kubernetes/operator/auth/ReshaprApiClientFactory.java | 4 ++++ .../operator/auth/ReshaprAuthenticationService.java | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) 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); } }