Skip to content

Commit 8aaddeb

Browse files
committed
fix: Delete functionality
Signed-off-by: Harisudarsan <[email protected]>
1 parent cefdc04 commit 8aaddeb

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

relay-server/server/relayServer.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ type LogService struct {
9898
//
9999
}
100100

101-
// IP to K8sResource MAp
101+
// IP to K8sResource Map
102102
var Ipcache sync.Map
103103

104104
// HealthCheck Function
@@ -876,16 +876,15 @@ func startIPInformers(ctx context.Context, wg *sync.WaitGroup) {
876876
updateIP := func(kind, namespace, name, ip string) {
877877

878878
if ip == "" {
879-
Ipcache.Delete(ip)
880879
return
881880
}
882881
resource := ""
883882
switch strings.ToUpper(kind) {
884883

885884
case "POD":
886-
resource = fmt.Sprintf("%s.%s.pod", name, namespace)
885+
resource = fmt.Sprintf("pod/%s/%s", namespace, name)
887886
case "SERVICE":
888-
resource = fmt.Sprintf("%s.%s.svc", name, namespace)
887+
resource = fmt.Sprintf("svc/%s/%s", namespace, name)
889888
}
890889

891890
Ipcache.Store(ip, resource)
@@ -913,8 +912,8 @@ func startIPInformers(ctx context.Context, wg *sync.WaitGroup) {
913912
if !ok {
914913
return
915914
}
915+
Ipcache.Delete(pod.Status.PodIP)
916916

917-
updateIP("POD", pod.Namespace, pod.Name, "")
918917
},
919918
})
920919

@@ -945,7 +944,7 @@ func startIPInformers(ctx context.Context, wg *sync.WaitGroup) {
945944
if !ok {
946945
return
947946
}
948-
updateIP("SERVICE", svc.Namespace, svc.Name, "")
947+
Ipcache.Delete(svc.Spec.ClusterIP)
949948
},
950949
})
951950

0 commit comments

Comments
 (0)