bobbai00 commented on code in PR #5629:
URL: https://github.com/apache/texera/pull/5629#discussion_r3405888189


##########
access-control-service/src/main/scala/org/apache/texera/service/resource/AccessControlResource.scala:
##########
@@ -136,12 +138,27 @@ object AccessControlResource extends LazyLogging {
     }
 
     // Dynamic Routing Logic
-    val workflowComputingUnitPoolName = KubernetesConfig.computeUnitPoolName
-    val workflowComputingUnitPoolNamespace = 
KubernetesConfig.computeUnitPoolNamespace
-    val workflowComputingUnitPoolPort = KubernetesConfig.computeUnitPortNumber
-
-    val targetHost =
-      
s"computing-unit-$cuidInt.$workflowComputingUnitPoolName-svc.$workflowComputingUnitPoolNamespace.svc.cluster.local:$workflowComputingUnitPoolPort"
+    // Use the URI persisted for the computing unit (written by the managing
+    // service when the pod is created) as the routing target, so the address 
is
+    // resolved from a single source of truth instead of being reconstructed
+    // here. Fall back to the conventional in-cluster address if no URI has 
been
+    // recorded for the unit yet.
+    val cuDao = new WorkflowComputingUnitDao(
+      SqlServer.getInstance().createDSLContext().configuration()
+    )
+    val unit = cuDao.fetchOneByCuid(cuidInt)
+    val recordedUri = Option(unit).flatMap(u => 
Option(u.getUri)).map(_.trim).filter(_.nonEmpty)
+
+    val targetHost = recordedUri match {
+      case Some(uri) =>
+        logger.info(s"Routing CU $cuidInt to recorded host: $uri")
+        uri
+      case None =>
+        val workflowComputingUnitPoolName = 
KubernetesConfig.computeUnitPoolName
+        val workflowComputingUnitPoolNamespace = 
KubernetesConfig.computeUnitPoolNamespace
+        val workflowComputingUnitPoolPort = 
KubernetesConfig.computeUnitPortNumber
+        
s"computing-unit-$cuidInt.$workflowComputingUnitPoolName-svc.$workflowComputingUnitPoolNamespace.svc.cluster.local:$workflowComputingUnitPoolPort"

Review Comment:
   Remove this fallback logic. If no URI is presented, refuse the connection to 
CU.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to