ricardozanini commented on code in PR #309:
URL: 
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/309#discussion_r1402234188


##########
controllers/discovery/kubernetes_catalog.go:
##########
@@ -58,21 +72,97 @@ func (c k8sServiceCatalog) resolveServiceQuery(ctx 
context.Context, uri Resource
 }
 
 func (c k8sServiceCatalog) resolvePodQuery(ctx context.Context, uri 
ResourceUri, outputFormat string) (string, error) {
-       if pod, service, err := findPodAndReferenceServiceByPodLabels(ctx, 
c.Client, uri.Namespace, uri.Name); err != nil {
+       if pod, serviceList, err := findPodAndReferenceServices(ctx, c.Client, 
uri.Namespace, uri.Name); err != nil {
                return "", err
        } else {
-               if service != nil {
-                       if serviceUri, err := resolveServiceUri(service, 
uri.GetPort(), outputFormat); err != nil {
+               if serviceList != nil && len(serviceList.Items) > 0 {
+                       referenceService := 
selectBestSuitedServiceByCustomLabels(serviceList, uri.CustomLabels)
+                       return resolveServiceUri(referenceService, 
uri.GetPort(), outputFormat)
+               } else {
+                       return resolvePodUri(pod, "", uri.GetPort(), 
outputFormat)
+               }
+       }
+}
+
+func (c k8sServiceCatalog) resolveDeploymentQuery(ctx context.Context, uri 
ResourceUri, outputFormat string) (string, error) {

Review Comment:
   So, if you can't find the service, you try to find the pod assuming that 
there's only one pod in the deployment as a fallback? I think it's safer to 
just fail and not assume that. Otherwise, we might see weird behaviors in the 
service connectivity. Also, we can add this to the docs saying that a 
Deployment must have a Service.



##########
controllers/discovery/discovery.go:
##########
@@ -57,6 +59,7 @@ type ResourceUri struct {
        GVK          v1.GroupVersionKind
        Namespace    string
        Name         string
+       Port         string

Review Comment:
   Is this only valid for Services and Containers? We might have to add this to 
a specific struct or have a custom query attribute here.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to