Skip to content

Commit

Permalink
lazyload: delete grpc port from wormPort
Browse files Browse the repository at this point in the history
  • Loading branch information
MouceL committed May 10, 2023
1 parent e5d984f commit ecd2b8b
Showing 1 changed file with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ func (r *ServicefenceReconciler) StartSvcCache(ctx context.Context) {
portProtos = make(map[Protocol]uint)
r.portProtocolCache.Data[p] = portProtos
}
proto := getProtocol(port)
portProtos[proto]++
if isHttp(port) {
portProtos[ProtocolHTTP]++
}
}
r.portProtocolCache.Unlock()
}
Expand Down Expand Up @@ -157,24 +158,12 @@ func (r *ServicefenceReconciler) StartAutoPort(ctx context.Context) {
}()
}

// find protocol of service port
func getProtocol(port corev1.ServicePort) Protocol {
func isHttp(port corev1.ServicePort) bool {
if port.Protocol != "TCP" {
return ProtocolUnknown
return false
}
p := strings.Split(port.Name, "-")[0]
return portProtocolToProtocol(PortProtocol(p))
}

func portProtocolToProtocol(p PortProtocol) Protocol {
switch p {
case HTTP, HTTP2, GRPC, GRPCWeb:
return ProtocolHTTP
case TCP, HTTPS, TLS, Mongo, Redis, MySQL:
return ProtocolTCP
default:
return ProtocolUnknown
}
return PortProtocol(p) == HTTP
}

func updateWormholePort(wormholePort []string, portProtocolCache *PortProtocolCache) ([]string, bool) {
Expand Down

0 comments on commit ecd2b8b

Please sign in to comment.