From a49443f10104bc941c24910f14a9186c1457c24b Mon Sep 17 00:00:00 2001 From: Nimrod Gilboa Markevich <59927337+nimrod-up9@users.noreply.github.com> Date: Wed, 30 Mar 2022 15:40:21 +0300 Subject: [PATCH] Set the entry namespace to the source namespace if the destination is not resolved (#950) * Set the entry namespace to the source namespace if the destination is not resolved * Overwrite src namespace with dst namespace only if dst non-empty --- agent/pkg/api/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/agent/pkg/api/main.go b/agent/pkg/api/main.go index 20660fd83..af11980df 100644 --- a/agent/pkg/api/main.go +++ b/agent/pkg/api/main.go @@ -168,6 +168,7 @@ func resolveIP(connectionInfo *tapApi.ConnectionInfo) (resolvedSource string, re } } else { resolvedSource = resolvedSourceObject.FullAddress + namespace = resolvedSourceObject.Namespace } unresolvedDestination := fmt.Sprintf("%s:%s", connectionInfo.ServerIP, connectionInfo.ServerPort) @@ -179,7 +180,11 @@ func resolveIP(connectionInfo *tapApi.ConnectionInfo) (resolvedSource string, re } } else { resolvedDestination = resolvedDestinationObject.FullAddress - namespace = resolvedDestinationObject.Namespace + // Overwrite namespace (if it was set according to the source) + // Only overwrite if non-empty + if resolvedDestinationObject.Namespace != "" { + namespace = resolvedDestinationObject.Namespace + } } } return resolvedSource, resolvedDestination, namespace