Skip to content

Commit

Permalink
fix virtual service's update error. (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
cybwan authored and reaver-flomesh committed Oct 22, 2023
1 parent f4c48bc commit cbbd2e6
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pkg/connector/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,19 +442,22 @@ func (s *Sink) fillService(mode string, svcMeta *MicroSvcMeta, createSvc *apiv1.
if strings.EqualFold(mode, ConsulDiscoveryService) {
ports := make([]int, 0)
for port, appProtocol := range svcMeta.Ports {
specPort := apiv1.ServicePort{
Name: fmt.Sprintf("%s%d", appProtocol, port),
Protocol: apiv1.ProtocolTCP,
Port: int32(port),
TargetPort: intstr.FromInt(int(port)),
}
if appProtocol == constants.ProtocolHTTP {
specPort.AppProtocol = &protocolHTTP
}
if appProtocol == constants.ProtocolGRPC {
specPort.AppProtocol = &protocolGRPC
if exists := s.existPort(createSvc, MicroSvcPort(port), appProtocol); !exists {
specPort := apiv1.ServicePort{
Name: fmt.Sprintf("%s%d", appProtocol, port),
Protocol: apiv1.ProtocolTCP,
Port: int32(port),
TargetPort: intstr.FromInt(int(port)),
}
if appProtocol == constants.ProtocolHTTP {
specPort.AppProtocol = &protocolHTTP
}
if appProtocol == constants.ProtocolGRPC {
specPort.AppProtocol = &protocolGRPC
}
createSvc.Spec.Ports = append(createSvc.Spec.Ports, specPort)
}
createSvc.Spec.Ports = append(createSvc.Spec.Ports, specPort)
ports = append(ports, int(port))
}
sort.Ints(ports)
for addr := range svcMeta.Addresses {
Expand Down

0 comments on commit cbbd2e6

Please sign in to comment.