From 56490aaec09543398f16567349a9bb551bd70326 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Mon, 18 Nov 2024 09:52:46 -0500 Subject: [PATCH 1/6] Propagate PublishNotReadyAddresses flag to GN internal service Fixes https://github.com/submariner-io/submariner/issues/3216 Signed-off-by: Tom Pantelis --- .../controllers/global_ingressip_controller.go | 9 +++++---- .../global_ingressip_controller_test.go | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pkg/globalnet/controllers/global_ingressip_controller.go b/pkg/globalnet/controllers/global_ingressip_controller.go index 4cc5fd39e..e69ebdd42 100644 --- a/pkg/globalnet/controllers/global_ingressip_controller.go +++ b/pkg/globalnet/controllers/global_ingressip_controller.go @@ -288,10 +288,11 @@ func (c *globalIngressIPController) createOrUpdateInternalService(from *corev1.S Finalizers: []string{InternalServiceFinalizer}, }, Spec: corev1.ServiceSpec{ - Ports: from.Spec.Ports, - Selector: from.Spec.Selector, - ExternalIPs: []string{extIP}, - IPFamilyPolicy: ptr.To(corev1.IPFamilyPolicySingleStack), + Ports: from.Spec.Ports, + Selector: from.Spec.Selector, + ExternalIPs: []string{extIP}, + IPFamilyPolicy: ptr.To(corev1.IPFamilyPolicySingleStack), + PublishNotReadyAddresses: from.Spec.PublishNotReadyAddresses, }, } diff --git a/pkg/globalnet/controllers/global_ingressip_controller_test.go b/pkg/globalnet/controllers/global_ingressip_controller_test.go index 19ae9cbf2..969a348f5 100644 --- a/pkg/globalnet/controllers/global_ingressip_controller_test.go +++ b/pkg/globalnet/controllers/global_ingressip_controller_test.go @@ -132,8 +132,11 @@ var _ = Describe("GlobalIngressIP controller", func() { func testGlobalIngressIPCreatedClusterIPSvc(t *globalIngressIPControllerTestDriver, ingressIP *submarinerv1.GlobalIngressIP) { var service *corev1.Service - JustBeforeEach(func() { + BeforeEach(func() { service = newClusterIPService() + }) + + JustBeforeEach(func() { t.createService(service) t.createGlobalIngressIP(ingressIP) }) @@ -150,11 +153,23 @@ func testGlobalIngressIPCreatedClusterIPSvc(t *globalIngressIPControllerTestDriv Expect(intSvc.Spec.Ports).To(Equal(service.Spec.Ports)) Expect(intSvc.Spec.IPFamilyPolicy).ToNot(BeNil()) Expect(*intSvc.Spec.IPFamilyPolicy).To(Equal(corev1.IPFamilyPolicySingleStack)) + Expect(intSvc.Spec.PublishNotReadyAddresses).To(BeFalse()) finalizer := intSvc.GetFinalizers()[0] Expect(finalizer).To(Equal(controllers.InternalServiceFinalizer)) }) + Context("and the service has PublishNotReadyAddresses set to true", func() { + BeforeEach(func() { + service.Spec.PublishNotReadyAddresses = true + }) + + It("should set PublishNotReadyAddresses to true on the internal submariner service", func() { + intSvc := t.awaitService(controllers.GetInternalSvcName(serviceName)) + Expect(intSvc.Spec.PublishNotReadyAddresses).To(BeTrue()) + }) + }) + Context("with the IP pool exhausted", func() { BeforeEach(func() { _, err := t.pool.Allocate(t.pool.Size()) From b8fb994545b8ba94ad4502eaea64daec7c619cab Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Thu, 14 Nov 2024 15:02:24 -0500 Subject: [PATCH 2/6] Adjust golangci-lint linters Added new linters (some commented out if not needed) and removed deprecated linters. Also addressed violations reported by new linters (in separate commits). Related to https://github.com/submariner-io/enhancements/issues/231 Signed-off-by: Tom Pantelis --- .golangci.yml | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 2d6951fcb..69d98c6b7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -53,6 +53,7 @@ linters: - asciicheck - bidichk - bodyclose + # - canonicalheader # This is a slow linter and we don't use the net/http.Header API - containedctx - contextcheck - copyloopvar @@ -69,15 +70,19 @@ linters: - errname # - execinquery # No SQL - exhaustive - # - exhauststruct # Not recommended for general use - meant to be used only for special cases + # - exhaustruct # This is too cumbersome as it requires all string, int, pointer et al fields to be initialized even when the + # type's default suffices, which is most of the time + - fatcontext # - forbidigo # We don't forbid any statements # - forcetypeassert # There are many unchecked type assertions that would be the result of a programming error so the # reasonable recourse would be to panic anyway if checked so this doesn't seem useful # - funlen # gocyclo is enabled which is generally a better metric than simply LOC. - gci - ginkgolinter + - gocheckcompilerdirectives # - gochecknoglobals # We don't want to forbid global variable constants # - gochecknoinits # We use init functions for valid reasons + # - gochecksumtype # The usefulness is very narrow:w - gocognit - goconst - gocritic @@ -89,24 +94,29 @@ linters: - gofumpt - goheader - goimports - # - gomnd # It doesn't seem useful in general to enforce constants for all numeric values # - gomoddirectives # We don't want to forbid the 'replace' directive # - gomodguard # We don't block any modules # - goprintffuncname # This doesn't seem useful at all + # - gosmopolitan # This is related to internationalization which is not a concern for us - gosec - gosimple - govet - grouper + - iface - importas + - inamedparam - ineffassign # - interfacebloat # We track complexity elsewhere + - intrange # - ireturn # The argument to always "Return Concrete Types" doesn't seem compelling. It is perfectly valid to return # an interface to avoid exposing the entire underlying struct - lll - loggercheck - maintidx - makezero + - mirror - misspell + # - mnd # It doesn't seem useful in general to enforce constants for all numeric values - nakedret # - nestif # This calculates cognitive complexity but we're doing that elsewhere - nilerr @@ -114,21 +124,28 @@ linters: # - nlreturn # This is reasonable with a block-size of 2 but setting it above isn't honored # - noctx # We don't send HTTP requests - nolintlint - # - nonamedreturns # We don't forbid named returns - - nosprintfhostport + - nonamedreturns + # - nosprintfhostport # The use of this is very narrow # - paralleltest # Not relevant for Ginkgo UTs + - perfsprint - prealloc - predeclared - promlinter + - protogetter - reassign + - recvcheck - revive # - rowserrcheck # We don't use SQL + # - sloglint # We don't use log/slog + # - spancheck # We don't use OpenTelemetry/OpenCensus # - sqlclosecheck # We don't use SQL - staticcheck - stylecheck + - tagalign # - tagliatelle # Inconsistent with stylecheck and not as good # - tenv # Not relevant for our Ginkgo UTs - - testableexamples + # - testableexamples # We don't need this + # - testifylint # We don't use testify - testpackage # - thelper # Not relevant for our Ginkgo UTs # - tparallel # Not relevant for our Ginkgo UTs @@ -142,6 +159,7 @@ linters: - whitespace - wrapcheck - wsl + # - zerologlint # We use zerolog indirectly so this isn't needed issues: exclude-rules: # Allow dot-imports for Gomega BDD directives per idiomatic Gomega From 7ef12d9a23517ea921853c8340dd0b6e1e340402 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Thu, 14 Nov 2024 15:04:39 -0500 Subject: [PATCH 3/6] Address protogetter linter violations Fix "avoid direct access to proto field". Signed-off-by: Tom Pantelis --- pkg/natdiscovery/proto/methods.go | 12 ++----- pkg/natdiscovery/request_handle.go | 34 +++++++++--------- .../request_handle_internal_test.go | 34 +++++++++--------- pkg/natdiscovery/request_send.go | 12 +++---- .../request_send_internal_test.go | 24 ++++++------- pkg/natdiscovery/response_handle.go | 35 ++++++++++--------- 6 files changed, 72 insertions(+), 79 deletions(-) diff --git a/pkg/natdiscovery/proto/methods.go b/pkg/natdiscovery/proto/methods.go index 26d324dac..271961e24 100644 --- a/pkg/natdiscovery/proto/methods.go +++ b/pkg/natdiscovery/proto/methods.go @@ -19,17 +19,9 @@ limitations under the License. package proto func (x *SubmarinerNATDiscoveryResponse) GetSenderEndpointID() string { - if x != nil && x.Sender != nil { - return x.Sender.EndpointId - } - - return "" + return x.GetSender().GetEndpointId() } func (x *SubmarinerNATDiscoveryResponse) GetReceiverEndpointID() string { - if x != nil && x.Receiver != nil { - return x.Receiver.EndpointId - } - - return "" + return x.GetReceiver().GetEndpointId() } diff --git a/pkg/natdiscovery/request_handle.go b/pkg/natdiscovery/request_handle.go index 7834d226d..d44ee06d9 100644 --- a/pkg/natdiscovery/request_handle.go +++ b/pkg/natdiscovery/request_handle.go @@ -31,19 +31,19 @@ func (nd *natDiscovery) handleRequestFromAddress(req *proto.SubmarinerNATDiscove localEndpointSpec := nd.localEndpoint.Spec() response := proto.SubmarinerNATDiscoveryResponse{ - RequestNumber: req.RequestNumber, + RequestNumber: req.GetRequestNumber(), Sender: &proto.EndpointDetails{ ClusterId: localEndpointSpec.ClusterID, EndpointId: localEndpointSpec.CableName, }, - Receiver: req.Sender, + Receiver: req.GetSender(), ReceivedSrc: &proto.IPPortPair{ Port: int32(addr.Port), //nolint:gosec // We can safely ignore integer conversion error IP: addr.IP.String(), }, } - if req.Receiver == nil || req.Sender == nil || req.UsingDst == nil || req.UsingSrc == nil { + if req.GetReceiver() == nil || req.GetSender() == nil || req.GetUsingDst() == nil || req.GetUsingSrc() == nil { logger.Warningf("Received NAT discovery packet %#v from %s which seems to be malformed ", req, addr.String()) response.Response = proto.ResponseType_MALFORMED @@ -52,10 +52,10 @@ func (nd *natDiscovery) handleRequestFromAddress(req *proto.SubmarinerNATDiscove } logger.V(log.DEBUG).Infof("Received request from %s:%d - REQUEST_NUMBER: 0x%x, SENDER: %q, RECEIVER: %q", - addr.IP.String(), addr.Port, req.RequestNumber, req.Sender.EndpointId, req.Receiver.EndpointId) + addr.IP.String(), addr.Port, req.GetRequestNumber(), req.GetSender().GetEndpointId(), req.GetReceiver().GetEndpointId()) - if req.Receiver.GetClusterId() != localEndpointSpec.ClusterID { - logger.Warningf("Received NAT discovery packet for cluster %q, but we are cluster %q", req.Receiver.GetClusterId(), + if req.GetReceiver().GetClusterId() != localEndpointSpec.ClusterID { + logger.Warningf("Received NAT discovery packet for cluster %q, but we are cluster %q", req.GetReceiver().GetClusterId(), localEndpointSpec.ClusterID) response.Response = proto.ResponseType_UNKNOWN_DST_CLUSTER @@ -63,9 +63,9 @@ func (nd *natDiscovery) handleRequestFromAddress(req *proto.SubmarinerNATDiscove return nd.sendResponseToAddress(&response, addr) } - if req.Receiver.GetEndpointId() != localEndpointSpec.CableName { + if req.GetReceiver().GetEndpointId() != localEndpointSpec.CableName { logger.Warningf("Received NAT discovery packet for endpoint %q, but we are endpoint %q "+ - "if the port for NAT discovery has been mapped somewhere an error may exist", req.Receiver.GetEndpointId(), + "if the port for NAT discovery has been mapped somewhere an error may exist", req.GetReceiver().GetEndpointId(), localEndpointSpec.CableName) response.Response = proto.ResponseType_UNKNOWN_DST_ENDPOINT @@ -73,20 +73,20 @@ func (nd *natDiscovery) handleRequestFromAddress(req *proto.SubmarinerNATDiscove return nd.sendResponseToAddress(&response, addr) } - if req.UsingSrc.GetIP() != "" && req.UsingSrc.GetIP() != addr.IP.String() { + if req.GetUsingSrc().GetIP() != "" && req.GetUsingSrc().GetIP() != addr.IP.String() { logger.V(log.DEBUG).Infof("Received NAT packet from endpoint %q, cluster %q, where NAT has been detected, "+ "source IP changed", - req.Sender.GetEndpointId(), req.Sender.GetClusterId()) - logger.V(log.DEBUG).Infof("Original src IP was %q, received src IP is %q", req.UsingSrc.IP, addr.IP.String()) + req.GetSender().GetEndpointId(), req.GetSender().GetClusterId()) + logger.V(log.DEBUG).Infof("Original src IP was %q, received src IP is %q", req.GetUsingSrc().GetIP(), addr.IP.String()) response.SrcIpNatDetected = true } - if int(req.UsingSrc.Port) != addr.Port { + if int(req.GetUsingSrc().GetPort()) != addr.Port { logger.V(log.DEBUG).Infof("Received NAT packet from endpoint %q, cluster %q, where NAT on the source has been detected, "+ "src port changed", - req.Sender.GetEndpointId(), req.Sender.GetClusterId()) - logger.V(log.DEBUG).Infof("Original src IP was %q, received src IP is %q", req.UsingSrc.IP, addr.IP.String()) + req.GetSender().GetEndpointId(), req.GetSender().GetClusterId()) + logger.V(log.DEBUG).Infof("Original src IP was %q, received src IP is %q", req.GetUsingSrc().GetIP(), addr.IP.String()) response.SrcPortNatDetected = true } @@ -94,11 +94,11 @@ func (nd *natDiscovery) handleRequestFromAddress(req *proto.SubmarinerNATDiscove // Detect DST NAT with a naive implementation that assumes that we always receive on the PrivateIP, // if we will listen at some point on multiple addresses we will need to implement the // unix.IP_RECVORIGDSTADDR on the UDP socket, and the go recvmsg implementation instead of readfrom - if req.UsingDst.IP != localEndpointSpec.PrivateIP { + if req.GetUsingDst().GetIP() != localEndpointSpec.PrivateIP { response.DstIpNatDetected = true } - if response.SrcPortNatDetected || response.SrcIpNatDetected || response.DstIpNatDetected { + if response.GetSrcPortNatDetected() || response.GetSrcIpNatDetected() || response.GetDstIpNatDetected() { response.Response = proto.ResponseType_NAT_DETECTED } else { response.Response = proto.ResponseType_OK @@ -117,7 +117,7 @@ func (nd *natDiscovery) sendResponseToAddress(response *proto.SubmarinerNATDisco } logger.V(log.DEBUG).Infof("Sending response to %s:%d - REQUEST_NUMBER: 0x%x, RESPONSE: %v, SENDER: %q, RECEIVER: %q", - addr.IP.String(), addr.Port, response.RequestNumber, response.Response, response.GetSenderEndpointID(), + addr.IP.String(), addr.Port, response.GetRequestNumber(), response.GetResponse(), response.GetSenderEndpointID(), response.GetReceiverEndpointID()) if length, err := nd.serverUDPWrite(buf, addr); err != nil { diff --git a/pkg/natdiscovery/request_handle_internal_test.go b/pkg/natdiscovery/request_handle_internal_test.go index 1a528e425..99c22ccf5 100644 --- a/pkg/natdiscovery/request_handle_internal_test.go +++ b/pkg/natdiscovery/request_handle_internal_test.go @@ -72,11 +72,11 @@ var _ = Describe("Request handling", func() { It("should respond with OK", func() { localListener.AddEndpoint(&remoteEndpoint) response := requestResponseFromRemoteToLocal(&remoteUDPAddr) - Expect(response[0].Response).To(Equal(natproto.ResponseType_OK)) - Expect(response[1].Response).To(Equal(natproto.ResponseType_NAT_DETECTED)) - Expect(response[1].DstIpNatDetected).To(BeTrue()) - Expect(response[1].SrcIpNatDetected).To(BeFalse()) - Expect(response[1].SrcPortNatDetected).To(BeFalse()) + Expect(response[0].GetResponse()).To(Equal(natproto.ResponseType_OK)) + Expect(response[1].GetResponse()).To(Equal(natproto.ResponseType_NAT_DETECTED)) + Expect(response[1].GetDstIpNatDetected()).To(BeTrue()) + Expect(response[1].GetSrcIpNatDetected()).To(BeFalse()) + Expect(response[1].GetSrcPortNatDetected()).To(BeFalse()) }) Context("with a modified IP", func() { @@ -84,9 +84,9 @@ var _ = Describe("Request handling", func() { remoteUDPAddr.IP = net.ParseIP(testRemotePublicIP) localListener.AddEndpoint(&remoteEndpoint) response := requestResponseFromRemoteToLocal(&remoteUDPAddr) - Expect(response[0].Response).To(Equal(natproto.ResponseType_NAT_DETECTED)) - Expect(response[0].SrcIpNatDetected).To(BeTrue()) - Expect(response[0].SrcPortNatDetected).To(BeFalse()) + Expect(response[0].GetResponse()).To(Equal(natproto.ResponseType_NAT_DETECTED)) + Expect(response[0].GetSrcIpNatDetected()).To(BeTrue()) + Expect(response[0].GetSrcPortNatDetected()).To(BeFalse()) }) }) @@ -95,9 +95,9 @@ var _ = Describe("Request handling", func() { remoteUDPAddr.Port = int(testRemoteNATPort + 1) localListener.AddEndpoint(&remoteEndpoint) response := requestResponseFromRemoteToLocal(&remoteUDPAddr) - Expect(response[0].Response).To(Equal(natproto.ResponseType_NAT_DETECTED)) - Expect(response[0].SrcIpNatDetected).To(BeFalse()) - Expect(response[0].SrcPortNatDetected).To(BeTrue()) + Expect(response[0].GetResponse()).To(Equal(natproto.ResponseType_NAT_DETECTED)) + Expect(response[0].GetSrcIpNatDetected()).To(BeFalse()) + Expect(response[0].GetSrcPortNatDetected()).To(BeTrue()) }) }) }) @@ -107,7 +107,7 @@ var _ = Describe("Request handling", func() { localListener.AddEndpoint(&remoteEndpoint) localEndpoint.Spec.CableName = "invalid" response := requestResponseFromRemoteToLocal(&remoteUDPAddr) - Expect(response[0].Response).To(Equal(natproto.ResponseType_UNKNOWN_DST_ENDPOINT)) + Expect(response[0].GetResponse()).To(Equal(natproto.ResponseType_UNKNOWN_DST_ENDPOINT)) }) }) @@ -116,7 +116,7 @@ var _ = Describe("Request handling", func() { localListener.AddEndpoint(&remoteEndpoint) localEndpoint.Spec.ClusterID = "invalid" response := requestResponseFromRemoteToLocal(&remoteUDPAddr) - Expect(response[0].Response).To(Equal(natproto.ResponseType_UNKNOWN_DST_CLUSTER)) + Expect(response[0].GetResponse()).To(Equal(natproto.ResponseType_UNKNOWN_DST_CLUSTER)) }) }) @@ -126,7 +126,7 @@ var _ = Describe("Request handling", func() { msg.GetRequest().Sender = nil }) response := parseResponseInLocalListener(request, &remoteUDPAddr) - Expect(response.Response).To(Equal(natproto.ResponseType_MALFORMED)) + Expect(response.GetResponse()).To(Equal(natproto.ResponseType_MALFORMED)) }) }) @@ -136,7 +136,7 @@ var _ = Describe("Request handling", func() { msg.GetRequest().Receiver = nil }) response := parseResponseInLocalListener(request, &remoteUDPAddr) - Expect(response.Response).To(Equal(natproto.ResponseType_MALFORMED)) + Expect(response.GetResponse()).To(Equal(natproto.ResponseType_MALFORMED)) }) }) @@ -146,7 +146,7 @@ var _ = Describe("Request handling", func() { msg.GetRequest().UsingDst = nil }) response := parseResponseInLocalListener(request, &remoteUDPAddr) - Expect(response.Response).To(Equal(natproto.ResponseType_MALFORMED)) + Expect(response.GetResponse()).To(Equal(natproto.ResponseType_MALFORMED)) }) }) @@ -156,7 +156,7 @@ var _ = Describe("Request handling", func() { msg.GetRequest().UsingSrc = nil }) response := parseResponseInLocalListener(request, &remoteUDPAddr) - Expect(response.Response).To(Equal(natproto.ResponseType_MALFORMED)) + Expect(response.GetResponse()).To(Equal(natproto.ResponseType_MALFORMED)) }) }) }) diff --git a/pkg/natdiscovery/request_send.go b/pkg/natdiscovery/request_send.go index 1e5360cc1..71ba67b71 100644 --- a/pkg/natdiscovery/request_send.go +++ b/pkg/natdiscovery/request_send.go @@ -106,7 +106,7 @@ func (nd *natDiscovery) sendCheckRequestToTargetIP(remoteNAT *remoteEndpointNAT, buf, err := proto.Marshal(&message) if err != nil { - return request.RequestNumber, errors.Wrapf(err, "error marshaling request %#v", request) + return request.GetRequestNumber(), errors.Wrapf(err, "error marshaling request %#v", request) } addr := net.UDPAddr{ @@ -115,17 +115,17 @@ func (nd *natDiscovery) sendCheckRequestToTargetIP(remoteNAT *remoteEndpointNAT, } logger.V(log.DEBUG).Infof("Sending request - REQUEST_NUMBER: 0x%x, SENDER: %q, RECEIVER: %q, USING_SRC: %s:%d, USING_DST: %s:%d", - request.RequestNumber, request.Sender.EndpointId, request.Receiver.EndpointId, request.UsingSrc.IP, request.UsingSrc.Port, - request.UsingDst.IP, request.UsingDst.Port) + request.GetRequestNumber(), request.GetSender().GetEndpointId(), request.GetReceiver().GetEndpointId(), + request.GetUsingSrc().GetIP(), request.GetUsingSrc().GetPort(), request.GetUsingDst().GetIP(), request.GetUsingDst().GetPort()) if length, err := nd.serverUDPWrite(buf, &addr); err != nil { - return request.RequestNumber, errors.Wrapf(err, "error sending request packet %#v", request) + return request.GetRequestNumber(), errors.Wrapf(err, "error sending request packet %#v", request) } else if length != len(buf) { - return request.RequestNumber, errors.Errorf("the sent UDP packet was smaller than requested, sent=%d, expected=%d", length, + return request.GetRequestNumber(), errors.Errorf("the sent UDP packet was smaller than requested, sent=%d, expected=%d", length, len(buf)) } remoteNAT.checkSent() - return request.RequestNumber, nil + return request.GetRequestNumber(), nil } diff --git a/pkg/natdiscovery/request_send_internal_test.go b/pkg/natdiscovery/request_send_internal_test.go index 6d22070b5..857bbcd25 100644 --- a/pkg/natdiscovery/request_send_internal_test.go +++ b/pkg/natdiscovery/request_send_internal_test.go @@ -53,27 +53,27 @@ var _ = When("a request is sent", func() { testRequest := func(srcIP string) { It("should set the sender fields correctly", func() { - Expect(request.Sender).NotTo(BeNil()) - Expect(request.Sender.ClusterId).To(Equal(testLocalClusterID)) - Expect(request.Sender.EndpointId).To(Equal(testLocalEndpointName)) + Expect(request.GetSender()).NotTo(BeNil()) + Expect(request.GetSender().GetClusterId()).To(Equal(testLocalClusterID)) + Expect(request.GetSender().GetEndpointId()).To(Equal(testLocalEndpointName)) }) It("should set the receiver fields correctly", func() { - Expect(request.Receiver).NotTo(BeNil()) - Expect(request.Receiver.ClusterId).To(Equal(testRemoteClusterID)) - Expect(request.Receiver.EndpointId).To(Equal(testRemoteEndpointName)) + Expect(request.GetReceiver()).NotTo(BeNil()) + Expect(request.GetReceiver().GetClusterId()).To(Equal(testRemoteClusterID)) + Expect(request.GetReceiver().GetEndpointId()).To(Equal(testRemoteEndpointName)) }) It("should set the using source fields correctly", func() { - Expect(request.UsingSrc).NotTo(BeNil()) - Expect(request.UsingSrc.IP).To(Equal(testLocalPrivateIP)) - Expect(request.UsingSrc.Port).To(Equal(testLocalNATPort)) + Expect(request.GetUsingSrc()).NotTo(BeNil()) + Expect(request.GetUsingSrc().GetIP()).To(Equal(testLocalPrivateIP)) + Expect(request.GetUsingSrc().GetPort()).To(Equal(testLocalNATPort)) }) It("should set the using destination fields correctly", func() { - Expect(request.UsingDst).NotTo(BeNil()) - Expect(request.UsingDst.Port).To(Equal(testRemoteNATPort)) - Expect(request.UsingDst.IP).To(Equal(srcIP)) + Expect(request.GetUsingDst()).NotTo(BeNil()) + Expect(request.GetUsingDst().GetPort()).To(Equal(testRemoteNATPort)) + Expect(request.GetUsingDst().GetIP()).To(Equal(srcIP)) }) It("should not send another request", func() { diff --git a/pkg/natdiscovery/response_handle.go b/pkg/natdiscovery/response_handle.go index fd8529160..2cb35c356 100644 --- a/pkg/natdiscovery/response_handle.go +++ b/pkg/natdiscovery/response_handle.go @@ -29,35 +29,36 @@ import ( func (nd *natDiscovery) handleResponseFromAddress(req *proto.SubmarinerNATDiscoveryResponse, addr *net.UDPAddr) error { logger.V(log.DEBUG).Infof("Received response from %s:%d - REQUEST_NUMBER: 0x%x, RESPONSE: %v, SENDER: %q, RECEIVER: %q", - addr.IP.String(), addr.Port, req.RequestNumber, req.Response, req.Sender.EndpointId, req.Receiver.EndpointId) + addr.IP.String(), addr.Port, req.GetRequestNumber(), req.GetResponse(), req.GetSender().GetEndpointId(), + req.GetReceiver().GetEndpointId()) if req.GetSender() == nil || req.GetReceiver() == nil || req.GetReceivedSrc() == nil { return errors.Errorf("received malformed response %#v", req) } - if req.Response != proto.ResponseType_OK && req.Response != proto.ResponseType_NAT_DETECTED { + if req.GetResponse() != proto.ResponseType_OK && req.GetResponse() != proto.ResponseType_NAT_DETECTED { var ok bool var name string - if name, ok = proto.ResponseType_name[int32(req.Response)]; !ok { - name = fmt.Sprintf("%d", req.Response) + if name, ok = proto.ResponseType_name[int32(req.GetResponse())]; !ok { + name = fmt.Sprintf("%d", req.GetResponse()) } - return errors.Errorf("remote endpoint %q responded with %q : %#v", req.Sender.EndpointId, name, req) + return errors.Errorf("remote endpoint %q responded with %q : %#v", req.GetSender().GetEndpointId(), name, req) } nd.Lock() - remoteNAT, ok := nd.remoteEndpoints[req.GetSender().EndpointId] + remoteNAT, ok := nd.remoteEndpoints[req.GetSender().GetEndpointId()] defer nd.Unlock() if !ok { - return errors.Errorf("received response from unknown endpoint %q", req.GetSender().EndpointId) + return errors.Errorf("received response from unknown endpoint %q", req.GetSender().GetEndpointId()) } // response to a PublicIP request - if remoteNAT.lastPublicIPRequestID == req.RequestNumber { - useNAT := req.Response == proto.ResponseType_NAT_DETECTED - if !remoteNAT.transitionToPublicIP(req.GetSender().EndpointId, useNAT) { + if remoteNAT.lastPublicIPRequestID == req.GetRequestNumber() { + useNAT := req.GetResponse() == proto.ResponseType_NAT_DETECTED + if !remoteNAT.transitionToPublicIP(req.GetSender().GetEndpointId(), useNAT) { return nil } @@ -67,21 +68,21 @@ func (nd *natDiscovery) handleResponseFromAddress(req *proto.SubmarinerNATDiscov } // response to a PrivateIP request - if remoteNAT.lastPrivateIPRequestID == req.RequestNumber { + if remoteNAT.lastPrivateIPRequestID == req.GetRequestNumber() { if addr.IP.String() != remoteNAT.endpoint.Spec.PrivateIP { return errors.Errorf("response for NAT discovery on endpoint %q private IP %q comes from different IP %q, "+ "NAT on private IPs is unlikely and filtered for security reasons", - req.GetSender().EndpointId, remoteNAT.endpoint.Spec.PrivateIP, addr.IP) + req.GetSender().GetEndpointId(), remoteNAT.endpoint.Spec.PrivateIP, addr.IP) } - if req.Response == proto.ResponseType_NAT_DETECTED { + if req.GetResponse() == proto.ResponseType_NAT_DETECTED { logger.Warningf("response for NAT discovery on endpoint %q private IP %q says src was modified which is unexpected", - req.GetSender().EndpointId, remoteNAT.endpoint.Spec.PrivateIP) + req.GetSender().GetEndpointId(), remoteNAT.endpoint.Spec.PrivateIP) } - useNAT := req.Response == proto.ResponseType_NAT_DETECTED + useNAT := req.GetResponse() == proto.ResponseType_NAT_DETECTED - if !remoteNAT.transitionToPrivateIP(req.GetSender().EndpointId, useNAT) { + if !remoteNAT.transitionToPrivateIP(req.GetSender().GetEndpointId(), useNAT) { return nil } @@ -91,5 +92,5 @@ func (nd *natDiscovery) handleResponseFromAddress(req *proto.SubmarinerNATDiscov } return errors.Errorf("received response for unknown request id 0x%x, lastPublicIPRequestID: %d, lastPrivateIPRequestID: %d", - req.RequestNumber, remoteNAT.lastPublicIPRequestID, remoteNAT.lastPrivateIPRequestID) + req.GetRequestNumber(), remoteNAT.lastPublicIPRequestID, remoteNAT.lastPrivateIPRequestID) } From 66be51b2b76b58bf7390c3e455d4e1644e50412e Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Fri, 15 Nov 2024 08:33:38 -0500 Subject: [PATCH 4/6] Address intrange linter violations Signed-off-by: Tom Pantelis --- pkg/cable/libreswan/libreswan.go | 4 ++-- pkg/cableengine/syncer/syncer_test.go | 2 +- pkg/globalnet/main.go | 2 +- pkg/netlink/netlink.go | 2 +- pkg/packetfilter/adapter.go | 2 +- pkg/pinger/pinger_test.go | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/cable/libreswan/libreswan.go b/pkg/cable/libreswan/libreswan.go index 142c3ed76..648e510d5 100644 --- a/pkg/cable/libreswan/libreswan.go +++ b/pkg/cable/libreswan/libreswan.go @@ -320,7 +320,7 @@ func extractSubnets(endpoint *subv1.EndpointSpec) []string { func whack(args ...string) error { var err error - for i := 0; i < 3; i++ { + for range 3 { err = func() error { ctx, cancel := context.WithTimeout(context.TODO(), whackTimeout) defer cancel() @@ -653,7 +653,7 @@ func (i *libreswan) waitForControlSocket() error { const retryInterval = 100 * time.Millisecond const controlSocketPath = "/run/pluto/pluto.ctl" - for i := 0; i < maxAttempts; i++ { + for range maxAttempts { _, err := os.Stat(controlSocketPath) if err == nil { return nil diff --git a/pkg/cableengine/syncer/syncer_test.go b/pkg/cableengine/syncer/syncer_test.go index 42ce608cd..d7bc56f34 100644 --- a/pkg/cableengine/syncer/syncer_test.go +++ b/pkg/cableengine/syncer/syncer_test.go @@ -96,7 +96,7 @@ func testGatewaySyncing() { It("should periodically update the Gateway resource timestamp", func() { var lastTimestamp int64 - for i := 0; i < 3; i++ { + for range 3 { var currentTimestamp int64 Eventually(func() int64 { diff --git a/pkg/globalnet/main.go b/pkg/globalnet/main.go index 1be107a34..9ff12ff10 100644 --- a/pkg/globalnet/main.go +++ b/pkg/globalnet/main.go @@ -113,7 +113,7 @@ func main() { var localCluster *submarinerv1.Cluster // During installation, sometimes creation of clusterCRD by submariner-gateway-pod would take few secs. - for i := 0; i < 100; i++ { + for range 100 { localCluster, err = submarinerClient.SubmarinerV1().Clusters(spec.Namespace).Get(context.TODO(), spec.ClusterID, metav1.GetOptions{}) if err == nil { diff --git a/pkg/netlink/netlink.go b/pkg/netlink/netlink.go index 8e35bcffb..69c774528 100644 --- a/pkg/netlink/netlink.go +++ b/pkg/netlink/netlink.go @@ -184,7 +184,7 @@ func (n *netlinkType) EnableLooseModeReversePathFilter(interfaceName string) err } func (n *netlinkType) EnsureLooseModeIsConfigured(interfaceName string) error { - for i := 0; i < 10; i++ { + for range 10 { // Revisit: This is a temporary work-around to fix https://github.com/submariner-io/submariner/issues/2422 // Allow the interface to get initialized. time.Sleep(100 * time.Millisecond) diff --git a/pkg/packetfilter/adapter.go b/pkg/packetfilter/adapter.go index 15c5f5ec4..a4ac9f77f 100644 --- a/pkg/packetfilter/adapter.go +++ b/pkg/packetfilter/adapter.go @@ -63,7 +63,7 @@ func (a *Adapter) ensureRuleAtPosition(table TableType, chain string, existingRu // The required rule is present in the chain, but either there are multiple occurrences or it's not at the desired position. if numOccurrences > 1 || !isPresentAtRequiredPosition { - for i := 0; i < numOccurrences; i++ { + for range numOccurrences { logger.V(level.TRACE).Infof("Deleting misplaced occurrence of rule %q from table %q, chain %q", rule, table, chain) if err := a.Delete(table, chain, rule); err != nil { diff --git a/pkg/pinger/pinger_test.go b/pkg/pinger/pinger_test.go index 43817ecf5..1079d8c8b 100644 --- a/pkg/pinger/pinger_test.go +++ b/pkg/pinger/pinger_test.go @@ -101,7 +101,7 @@ var _ = Describe("Pinger", func() { verifyPingStats := func(count int) { last := &pinger.LatencyInfo{} - for i := 0; i < count; i++ { + for range count { var current *pinger.LatencyInfo Eventually(func() *pinger.LatencyInfo { From a64ffe66d4e53c45bcc2ea82d1fabd5e5501301a Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Fri, 15 Nov 2024 08:41:12 -0500 Subject: [PATCH 5/6] Address nonamedreturns linter violations Signed-off-by: Tom Pantelis --- pkg/cableengine/syncer/syncer_test.go | 2 +- pkg/netlink/fake/netlink.go | 10 +++++----- pkg/routeagent_driver/handlers/ovn/vsctl/vsctl.go | 2 +- pkg/util/clusterfiles/cluster_files.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/cableengine/syncer/syncer_test.go b/pkg/cableengine/syncer/syncer_test.go index d7bc56f34..93ee67ae7 100644 --- a/pkg/cableengine/syncer/syncer_test.go +++ b/pkg/cableengine/syncer/syncer_test.go @@ -675,6 +675,6 @@ func (m *equalGatewayMatcher) FailureMessage(actual interface{}) string { return format.Message(actual, "to equal", m.expected) } -func (m *equalGatewayMatcher) NegatedFailureMessage(actual interface{}) (message string) { +func (m *equalGatewayMatcher) NegatedFailureMessage(actual interface{}) string { return format.Message(actual, "not to equal", m.expected) } diff --git a/pkg/netlink/fake/netlink.go b/pkg/netlink/fake/netlink.go index 59a030767..fe9df9b08 100644 --- a/pkg/netlink/fake/netlink.go +++ b/pkg/netlink/fake/netlink.go @@ -450,13 +450,15 @@ func (n *basicType) ConfigureTCPMTUProbe(_, _ string) error { return nil } -func (n *NetLink) AwaitLink(name string) (link netlink.Link) { +func (n *NetLink) AwaitLink(name string) netlink.Link { + var link netlink.Link + Eventually(func() netlink.Link { link, _ = n.LinkByName(name) return link }, 5).ShouldNot(BeNil(), "Link %q not found", name) - return + return link } func (n *NetLink) AwaitNoLink(name string) { @@ -466,7 +468,7 @@ func (n *NetLink) AwaitNoLink(name string) { }, 5).Should(BeTrue(), "Link %q exists", name) } -func (n *NetLink) AwaitLinkSetup(name string) (link netlink.Link) { +func (n *NetLink) AwaitLinkSetup(name string) { Eventually(func() bool { n.basic().mutex.Lock() defer n.basic().mutex.Unlock() @@ -478,8 +480,6 @@ func (n *NetLink) AwaitLinkSetup(name string) (link netlink.Link) { return false }, 5).Should(BeTrue(), "Link %q not setup", name) - - return } func routeList[T any](n *NetLink, linkIndex, table int, f func(r *netlink.Route) *T) []T { diff --git a/pkg/routeagent_driver/handlers/ovn/vsctl/vsctl.go b/pkg/routeagent_driver/handlers/ovn/vsctl/vsctl.go index 4c4b927bd..c4163f823 100644 --- a/pkg/routeagent_driver/handlers/ovn/vsctl/vsctl.go +++ b/pkg/routeagent_driver/handlers/ovn/vsctl/vsctl.go @@ -36,7 +36,7 @@ const ( var logger = log.Logger{Logger: logf.Log.WithName("ovs-vsctl")} -func vsctlCmd(parameters ...string) (output string, err error) { +func vsctlCmd(parameters ...string) (string, error) { allParameters := []string{fmt.Sprintf("--timeout=%d", ovsCommandTimeout)} allParameters = append(allParameters, parameters...) diff --git a/pkg/util/clusterfiles/cluster_files.go b/pkg/util/clusterfiles/cluster_files.go index bc1871606..9e93e15b7 100644 --- a/pkg/util/clusterfiles/cluster_files.go +++ b/pkg/util/clusterfiles/cluster_files.go @@ -38,7 +38,7 @@ var logger = log.Logger{Logger: logf.Log.WithName("ClusterFiles")} // using an url schema that supports configmap://// // secret://// and file:/// returning // a local path to the file. -func Get(k8sClient kubernetes.Interface, urlAddress string) (pathStr string, err error) { +func Get(k8sClient kubernetes.Interface, urlAddress string) (string, error) { logger.V(log.DEBUG).Infof("Reading cluster_file: %s", urlAddress) parsedURL, err := url.Parse(urlAddress) From 98d0d7eeb67d49773ebf610c627192f7940a7846 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Fri, 15 Nov 2024 08:55:51 -0500 Subject: [PATCH 6/6] Address perfsprint linter violations "fmt.Errorf can be replaced with errors.New" "fmt.Sprintf can be replaced with string concatenation" "fmt.Sprintf can be replaced with faster strconv.Itoa" Signed-off-by: Tom Pantelis --- pkg/apis/submariner.io/v1/endpoint.go | 4 ++-- pkg/cable/wireguard/driver.go | 4 ++-- pkg/globalnet/controllers/egress_pod_watcher.go | 4 +--- pkg/ipset/ipset.go | 3 ++- pkg/netlink/netlink.go | 4 ++-- pkg/routeagent_driver/handlers/ovn/utils.go | 2 +- pkg/routeagent_driver/handlers/ovn/vsctl/vsctl.go | 7 ++++--- pkg/versions/version.go | 9 ++++----- test/e2e/framework/dataplane.go | 4 ++-- test/external/dataplane/gn_connectivity.go | 4 ++-- 10 files changed, 22 insertions(+), 23 deletions(-) diff --git a/pkg/apis/submariner.io/v1/endpoint.go b/pkg/apis/submariner.io/v1/endpoint.go index db4d2ed8f..ff50c18f8 100644 --- a/pkg/apis/submariner.io/v1/endpoint.go +++ b/pkg/apis/submariner.io/v1/endpoint.go @@ -68,11 +68,11 @@ func parsePort(port string) (int32, error) { func (ep *EndpointSpec) GenerateName() (string, error) { if ep.ClusterID == "" { - return "", fmt.Errorf("ClusterID cannot be empty") + return "", errors.New("ClusterID cannot be empty") } if ep.CableName == "" { - return "", fmt.Errorf("CableName cannot be empty") + return "", errors.New("CableName cannot be empty") } return resource.EnsureValidName(fmt.Sprintf("%s-%s", ep.ClusterID, ep.CableName)), nil diff --git a/pkg/cable/wireguard/driver.go b/pkg/cable/wireguard/driver.go index d3f497ccf..9578a0a71 100644 --- a/pkg/cable/wireguard/driver.go +++ b/pkg/cable/wireguard/driver.go @@ -104,7 +104,7 @@ func NewDriver(localEndpoint *endpoint.Local, _ *types.SubmarinerCluster) (cable // Create the controller. if w.client, err = wgctrl.New(); err != nil { if os.IsNotExist(err) { - return nil, fmt.Errorf("wgctrl is not available on this system") + return nil, errors.New("wgctrl is not available on this system") } return nil, errors.Wrap(err, "failed to open wgctl client") @@ -312,7 +312,7 @@ func (w *wireguard) ConnectToEndpoint(endpointInfo *natdiscovery.NATEndpointInfo func keyFromSpec(ep *v1.EndpointSpec) (*wgtypes.Key, error) { s, found := ep.BackendConfig[PublicKey] if !found { - return nil, fmt.Errorf("endpoint is missing public key") + return nil, errors.New("endpoint is missing public key") } key, err := wgtypes.ParseKey(s) diff --git a/pkg/globalnet/controllers/egress_pod_watcher.go b/pkg/globalnet/controllers/egress_pod_watcher.go index dfd08516c..b98697f7c 100644 --- a/pkg/globalnet/controllers/egress_pod_watcher.go +++ b/pkg/globalnet/controllers/egress_pod_watcher.go @@ -19,8 +19,6 @@ limitations under the License. package controllers import ( - "fmt" - "github.com/pkg/errors" "github.com/submariner-io/admiral/pkg/log" "github.com/submariner-io/admiral/pkg/watcher" @@ -53,7 +51,7 @@ func startEgressPodWatcher(name, namespace string, namedSet packetfilter.NamedSe Scheme: config.Scheme, ResourceConfigs: []watcher.ResourceConfig{ { - Name: fmt.Sprintf("Pod watcher %s", name), + Name: "Pod watcher " + name, ResourceType: &corev1.Pod{}, Handler: watcher.EventHandlerFuncs{ OnCreateFunc: pw.onCreateOrUpdate, diff --git a/pkg/ipset/ipset.go b/pkg/ipset/ipset.go index 09f365381..8b8130481 100644 --- a/pkg/ipset/ipset.go +++ b/pkg/ipset/ipset.go @@ -50,6 +50,7 @@ limitations under the License. package ipset import ( + "errors" "fmt" "os/exec" "regexp" @@ -384,7 +385,7 @@ func (runner *runner) ListSets() ([]string, error) { // ListEntries lists all the entries from a named set. func (runner *runner) ListEntries(set string) ([]string, error) { if set == "" { - return nil, fmt.Errorf("set name can't be empty") + return nil, errors.New("set name can't be empty") } out, err := runner.runWithOutput([]string{"list", set}, "error listing set %q", set) diff --git a/pkg/netlink/netlink.go b/pkg/netlink/netlink.go index 69c774528..5b6c92ad1 100644 --- a/pkg/netlink/netlink.go +++ b/pkg/netlink/netlink.go @@ -274,7 +274,7 @@ func GetDefaultGatewayInterface() (*net.Interface, error) { for i := range routes { if routes[i].Dst == nil || routes[i].Dst.String() == allZeroAddress { if routes[i].LinkIndex == 0 { - return nil, fmt.Errorf("default gateway interface could not be determined") + return nil, errors.New("default gateway interface could not be determined") } iface, err := net.InterfaceByIndex(routes[i].LinkIndex) @@ -286,7 +286,7 @@ func GetDefaultGatewayInterface() (*net.Interface, error) { } } - return nil, fmt.Errorf("unable to find default route") + return nil, errors.New("unable to find default route") } func DeleteIfaceAndAssociatedRoutes(iface string, tableID int) error { diff --git a/pkg/routeagent_driver/handlers/ovn/utils.go b/pkg/routeagent_driver/handlers/ovn/utils.go index 3f6c25431..ac5075a5d 100644 --- a/pkg/routeagent_driver/handlers/ovn/utils.go +++ b/pkg/routeagent_driver/handlers/ovn/utils.go @@ -60,7 +60,7 @@ func jsonToIP(jsonData string) (string, error) { ipStr, found := data["ipv4"] if !found { - return "", fmt.Errorf("json data does not contain an 'ipv4' field") + return "", errors.New("json data does not contain an 'ipv4' field") } ip, _, err := net.ParseCIDR(ipStr) diff --git a/pkg/routeagent_driver/handlers/ovn/vsctl/vsctl.go b/pkg/routeagent_driver/handlers/ovn/vsctl/vsctl.go index c4163f823..b24839745 100644 --- a/pkg/routeagent_driver/handlers/ovn/vsctl/vsctl.go +++ b/pkg/routeagent_driver/handlers/ovn/vsctl/vsctl.go @@ -22,6 +22,7 @@ import ( "bytes" "fmt" "os/exec" + "strconv" "strings" "github.com/pkg/errors" @@ -75,8 +76,8 @@ func DelBridge(bridgeName string) error { func AddInternalPort(bridgeName, portName, macAddress string, mtu int) error { _, err := vsctlCmd("--may-exist", "add-port", bridgeName, portName, "--", - "set", "interface", portName, "type=internal", "mtu_request="+fmt.Sprintf("%d", mtu), - fmt.Sprintf("mac=%s", strings.ReplaceAll(macAddress, ":", "\\:"))) + "set", "interface", portName, "type=internal", "mtu_request="+strconv.Itoa(mtu), + "mac="+strings.ReplaceAll(macAddress, ":", "\\:")) return err } @@ -109,7 +110,7 @@ func AddOVNBridgeMapping(netName, bridgeName string) error { } if _, err = vsctlCmd("set", "Open_vSwitch", ".", - fmt.Sprintf("external_ids:ovn-bridge-mappings=%s", bridgeMappings)); err != nil { + "external_ids:ovn-bridge-mappings="+bridgeMappings); err != nil { return errors.Wrap(err, "failed to set ovn-bridge-mappings") } diff --git a/pkg/versions/version.go b/pkg/versions/version.go index 7f1c039cc..ce3330f4a 100644 --- a/pkg/versions/version.go +++ b/pkg/versions/version.go @@ -19,7 +19,6 @@ limitations under the License. package versions import ( - "fmt" "runtime" "github.com/submariner-io/admiral/pkg/log" @@ -32,10 +31,10 @@ var ( ) func Log(logger *log.Logger) { - logger.Info(fmt.Sprintf("Go Version: %s", runtime.Version())) - logger.Info(fmt.Sprintf("Go Arch: %s", runtime.GOARCH)) - logger.Info(fmt.Sprintf("Git Commit Hash: %s", gitCommitHash)) - logger.Info(fmt.Sprintf("Git Commit Date: %s", gitCommitDate)) + logger.Info("Go Version: " + runtime.Version()) + logger.Info("Go Arch: " + runtime.GOARCH) + logger.Info("Git Commit Hash: " + gitCommitHash) + logger.Info("Git Commit Date: " + gitCommitDate) } // Submariner returns the version info of submariner. diff --git a/test/e2e/framework/dataplane.go b/test/e2e/framework/dataplane.go index a28927a79..b82dd02bf 100644 --- a/test/e2e/framework/dataplane.go +++ b/test/e2e/framework/dataplane.go @@ -219,7 +219,7 @@ func getGlobalIngressIP(p tcp.ConnectivityTestParams, service *v1.Service) strin } else if p.ToEndpointType == tcp.GlobalPodIP { podList := p.Framework.AwaitPodsByLabelSelector(p.ToCluster, labels.Set(service.Spec.Selector).AsSelector().String(), service.Namespace, 1) - ingressIPName := fmt.Sprintf("pod-%s", podList.Items[0].Name) + ingressIPName := "pod-" + podList.Items[0].Name return p.Framework.AwaitGlobalIngressIP(p.ToCluster, ingressIPName, service.Namespace) } @@ -228,7 +228,7 @@ func getGlobalIngressIP(p tcp.ConnectivityTestParams, service *v1.Service) strin } func newGlobalEgressIPObj(namespace string, selector *metav1.LabelSelector) (*unstructured.Unstructured, error) { - geipName := fmt.Sprintf("test-e2e-egressip-%s", namespace) + geipName := "test-e2e-egressip-" + namespace egressIPSpec := &submarinerv1.GlobalEgressIP{ ObjectMeta: metav1.ObjectMeta{ Name: geipName, diff --git a/test/external/dataplane/gn_connectivity.go b/test/external/dataplane/gn_connectivity.go index 41e27aaae..83cdd62ad 100644 --- a/test/external/dataplane/gn_connectivity.go +++ b/test/external/dataplane/gn_connectivity.go @@ -412,7 +412,7 @@ func testGlobalNetExternalConnectivity(p testParams, g globalnetTestParams) { } func newGlobalEgressIPObj(namespace string, selector *metav1.LabelSelector) (*unstructured.Unstructured, error) { - geipName := fmt.Sprintf("test-e2e-egressip-%s", namespace) + geipName := "test-e2e-egressip-" + namespace egressIPSpec := &submarinerv1.GlobalEgressIP{ ObjectMeta: metav1.ObjectMeta{ Name: geipName, @@ -461,7 +461,7 @@ func getGlobalIngressIP(p testParams, service *v1.Service) string { case tcp.GlobalPodIP: podList := p.Framework.AwaitPodsByLabelSelector(p.Cluster, labels.Set(service.Spec.Selector).AsSelector().String(), service.Namespace, 1) - ingressIPName := fmt.Sprintf("pod-%s", podList.Items[0].Name) + ingressIPName := "pod-" + podList.Items[0].Name return p.Framework.AwaitGlobalIngressIP(p.Cluster, ingressIPName, service.Namespace) }