Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ovn: remove unnecessary patch #3720

Merged
merged 4 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ lint:
@GOOS=linux gosec -exclude=G204,G306,G402,G404,G601,G301 -exclude-dir=test -exclude-dir=pkg/client ./...

.PHONY: gofumpt
gofumpt: gofumpt
gofumpt:
gofumpt -w -extra .

.PHONY: lint-windows
Expand Down
2 changes: 0 additions & 2 deletions dist/images/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ RUN cd /usr/src/ && git clone -b branch-22.12 --depth=1 https://github.com/ovn-o
curl -s https://github.com/kubeovn/ovn/commit/6934f1a1eb5986a904eefb560c0d6d57811453d9.patch | git apply && \
# ovn-controller: do not send GARP on localnet for Kube-OVN ports
curl -s https://github.com/kubeovn/ovn/commit/8af8751cdb55f582c675db921f2526b06fd3d8c0.patch | git apply && \
# ovn-ic blacklist function not work on ipv6
curl -s https://github.com/kubeovn/ovn/commit/78ab91005854532e7eb5c4fe6b2923ce292e3681.patch | git apply && \
# fix lr-lb dnat with multiple distributed gateway ports
curl -s https://github.com/kubeovn/ovn/commit/80f37c2debbf9f5230403691f791d11cc2b2e277.patch | git apply && \
# lflow: do not send direct traffic between lports to conntrack
Expand Down
24 changes: 12 additions & 12 deletions mocks/pkg/ovs/interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/controller/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ func (c *Controller) checkGatewayReady() error {

success := false

pinger.OnRecv = func(p *goping.Packet) {
pinger.OnRecv = func(_ *goping.Packet) {
success = true
pinger.Stop()
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,14 +502,14 @@ func (c *Controller) reconcilePortSg(portName, securityGroups string) error {
needAssociated = "true"
}

if err = c.OVNNbClient.SetLogicalSwitchPortExternalIds(portName, map[string]string{fmt.Sprintf("associated_sg_%s", sgName): needAssociated}); err != nil {
if err = c.OVNNbClient.SetLogicalSwitchPortExternalIDs(portName, map[string]string{fmt.Sprintf("associated_sg_%s", sgName): needAssociated}); err != nil {
klog.Errorf("set logical switch port %s external_ids: %v", portName, err)
return err
}
c.syncSgPortsQueue.Add(sgName)
}

if err = c.OVNNbClient.SetLogicalSwitchPortExternalIds(portName, map[string]string{"security_groups": strings.ReplaceAll(securityGroups, ",", "/")}); err != nil {
if err = c.OVNNbClient.SetLogicalSwitchPortExternalIDs(portName, map[string]string{"security_groups": strings.ReplaceAll(securityGroups, ",", "/")}); err != nil {
klog.Errorf("set logical switch port %s external_ids: %v", portName, err)
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/daemon/ovs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ func pingGateway(gw, src string, verbose bool, maxRetry int) (count int, err err
pinger.Timeout = time.Duration(maxRetry) * time.Second
pinger.Interval = time.Second

pinger.OnRecv = func(p *goping.Packet) {
pinger.OnRecv = func(_ *goping.Packet) {
pinger.Stop()
}

pinger.OnSend = func(p *goping.Packet) {
pinger.OnSend = func(_ *goping.Packet) {
if pinger.PacketsRecv == 0 && pinger.PacketsSent != 0 && pinger.PacketsSent%3 == 0 {
klog.Warningf("%s network not ready after %d ping to gateway %s", src, pinger.PacketsSent, gw)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ovs/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type LogicalSwitchPort interface {
SetLogicalSwitchPortSecurity(portSecurity bool, lspName, mac, ips, vips string) error
SetLogicalSwitchPortVirtualParents(lsName, parents string, ips ...string) error
SetLogicalSwitchPortArpProxy(lspName string, enableArpProxy bool) error
SetLogicalSwitchPortExternalIds(lspName string, externalIds map[string]string) error
SetLogicalSwitchPortExternalIDs(lspName string, externalIDs map[string]string) error
SetLogicalSwitchPortVlanTag(lspName string, vlanID int) error
SetLogicalSwitchPortsSecurityGroup(sgName, op string) error
EnablePortLayer2forward(lspName string) error
Expand Down
2 changes: 1 addition & 1 deletion pkg/ovs/ovn-nb-acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ func (suite *OvnClientTestSuite) testCreateNodeACL() {
require.Contains(t, pg.ACLs, acl.UUID)
}

expect := func(pg *ovnnb.PortGroup, gateway string) {
expect := func(pg *ovnnb.PortGroup, _ string) {
for _, ip := range strings.Split(nodeIP, ",") {
protocol := util.CheckProtocol(ip)
ipSuffix := "ip4"
Expand Down
1 change: 0 additions & 1 deletion pkg/ovs/ovn-nb-load_balancer_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ func (c *OVNNbClient) DeleteLoadBalancerHealthChecks(filter func(lb *ovnnb.LoadB
return true
},
).Delete()

if err != nil {
return fmt.Errorf("generate operations for delete lb health checks: %v", err)
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/ovs/ovn-nb-logical_switch_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ func (c *OVNNbClient) SetLogicalSwitchPortSecurity(portSecurity bool, lspName, m
return nil
}

// SetLogicalSwitchPortExternalIds set logical switch port external ids
func (c *OVNNbClient) SetLogicalSwitchPortExternalIds(lspName string, externalIds map[string]string) error {
// SetLogicalSwitchPortExternalIDs sets logical switch port external ids
func (c *OVNNbClient) SetLogicalSwitchPortExternalIDs(lspName string, externalIDs map[string]string) error {
lsp, err := c.GetLogicalSwitchPort(lspName, false)
if err != nil {
klog.Error(err)
Expand All @@ -396,12 +396,12 @@ func (c *OVNNbClient) SetLogicalSwitchPortExternalIds(lspName string, externalId
lsp.ExternalIDs = make(map[string]string)
}

for k, v := range externalIds {
for k, v := range externalIDs {
lsp.ExternalIDs[k] = v
}

if err := c.UpdateLogicalSwitchPort(lsp, &lsp.ExternalIDs); err != nil {
return fmt.Errorf("set logical switch port %s external ids %v: %v", lspName, externalIds, err)
return fmt.Errorf("set logical switch port %s external ids %v: %v", lspName, externalIDs, err)
}

return nil
Expand Down Expand Up @@ -467,11 +467,11 @@ func (c *OVNNbClient) SetLogicalSwitchPortsSecurityGroup(sgName, op string) erro
associated = "true"
}

externalIds := map[string]string{associatedSgKey: associated}
lsps, err := c.ListNormalLogicalSwitchPorts(true, externalIds)
externalIDs := map[string]string{associatedSgKey: associated}
lsps, err := c.ListNormalLogicalSwitchPorts(true, externalIDs)
if err != nil {
klog.Error(err)
return fmt.Errorf("list logical switch ports with external_ids %v: %v", externalIds, err)
return fmt.Errorf("list logical switch ports with external_ids %v: %v", externalIDs, err)
}

/* add to or remove from sgs form port external_ids */
Expand Down
6 changes: 3 additions & 3 deletions pkg/ovs/ovn-nb-logical_switch_port_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func (suite *OvnClientTestSuite) testSetLogicalSwitchPortSecurity() {
})
}

func (suite *OvnClientTestSuite) testSetSetLogicalSwitchPortExternalIds() {
func (suite *OvnClientTestSuite) testSetSetLogicalSwitchPortExternalIDs() {
t := suite.T()
t.Parallel()

Expand All @@ -473,7 +473,7 @@ func (suite *OvnClientTestSuite) testSetSetLogicalSwitchPortExternalIds() {
err := createLogicalSwitchPort(ovnClient, lsp)
require.NoError(t, err)

err = ovnClient.SetLogicalSwitchPortExternalIds(lspName, map[string]string{"k1": "v1"})
err = ovnClient.SetLogicalSwitchPortExternalIDs(lspName, map[string]string{"k1": "v1"})
require.NoError(t, err)

lsp, err = ovnClient.GetLogicalSwitchPort(lspName, false)
Expand All @@ -483,7 +483,7 @@ func (suite *OvnClientTestSuite) testSetSetLogicalSwitchPortExternalIds() {
"vendor": util.CniTypeName,
}, lsp.ExternalIDs)

err = ovnClient.SetLogicalSwitchPortExternalIds(lspName, map[string]string{"k1": "v2"})
err = ovnClient.SetLogicalSwitchPortExternalIDs(lspName, map[string]string{"k1": "v2"})
require.NoError(t, err)

lsp, err = ovnClient.GetLogicalSwitchPort(lspName, false)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ovs/ovn-nb-suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (suite *OvnClientTestSuite) Test_SetLogicalSwitchPortSecurity() {
}

func (suite *OvnClientTestSuite) Test_SetSetLogicalSwitchPortExternalIds() {
suite.testSetSetLogicalSwitchPortExternalIds()
suite.testSetSetLogicalSwitchPortExternalIDs()
}

func (suite *OvnClientTestSuite) Test_SetLogicalSwitchPortSecurityGroup() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ovs/ovn-nb_global.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (c *OVNNbClient) GetNbGlobal() (*ovnnb.NBGlobal, error) {
nbGlobalList := make([]ovnnb.NBGlobal, 0, 1)

// there is only one nb_global in OVN_Northbound, so return true and it will work
err := c.WhereCache(func(config *ovnnb.NBGlobal) bool {
err := c.WhereCache(func(_ *ovnnb.NBGlobal) bool {
return true
}).List(ctx, &nbGlobalList)
if err != nil {
Expand Down
16 changes: 8 additions & 8 deletions pkg/ovs/ovs-vsctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ func ConfigInterfaceMirror(globalMirror bool, open, iface string) error {
if len(mirrorPorts) > 1 {
return fmt.Errorf("repeated mirror data, mirror name=" + util.MirrorDefaultName)
}
for _, mirrorPortIds := range mirrorPorts {
if strings.Contains(mirrorPortIds, portID) {
for _, mirrorPortIDs := range mirrorPorts {
if strings.Contains(mirrorPortIDs, portID) {
// remove port from mirror
_, err := Exec("remove", "mirror", util.MirrorDefaultName, "select_dst_port", portID)
if err != nil {
Expand Down Expand Up @@ -383,8 +383,8 @@ func GetResidualInternalPorts() []string {
}

// iface-id field does not exist in external_ids for residual internal port
externalIds := strings.Split(intf, "\n")[1]
if !strings.Contains(externalIds, "iface-id") {
externalIDs := strings.Split(intf, "\n")[1]
if !strings.Contains(externalIDs, "iface-id") {
residualPorts = append(residualPorts, name)
}
}
Expand All @@ -407,7 +407,7 @@ func ClearPortQosBinding(ifaceID string) error {
return nil
}

func ListExternalIds(table string) (map[string]string, error) {
func ListExternalIDs(table string) (map[string]string, error) {
args := []string{"--data=bare", "--format=csv", "--no-heading", "--columns=_uuid,external_ids", "find", table, "external_ids:iface-id!=[]"}
output, err := Exec(args...)
if err != nil {
Expand All @@ -425,8 +425,8 @@ func ListExternalIds(table string) (map[string]string, error) {
continue
}
uuid := strings.TrimSpace(parts[0])
externalIds := strings.Fields(parts[1])
for _, externalID := range externalIds {
externalIDs := strings.Fields(parts[1])
for _, externalID := range externalIDs {
if !strings.Contains(externalID, "iface-id=") {
continue
}
Expand All @@ -438,7 +438,7 @@ func ListExternalIds(table string) (map[string]string, error) {
return result, nil
}

func ListQosQueueIds() (map[string]string, error) {
func ListQosQueueIDs() (map[string]string, error) {
args := []string{"--data=bare", "--format=csv", "--no-heading", "--columns=_uuid,queues", "find", "qos", "queues:0!=[]"}
output, err := Exec(args...)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/ovs/ovs-vsctl_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ func SetInterfaceBandwidth(podName, podNamespace, iface, ingress, egress string)
return err
}

qosIfaceUIDMap, err := ListExternalIds("qos")
qosIfaceUIDMap, err := ListExternalIDs("qos")
if err != nil {
klog.Error(err)
return err
}

queueIfaceUIDMap, err := ListExternalIds("queue")
queueIfaceUIDMap, err := ListExternalIDs("queue")
if err != nil {
klog.Error(err)
return err
Expand Down Expand Up @@ -103,7 +103,7 @@ func ClearHtbQosQueue(podName, podNamespace, iface string) error {
}

// https://github.com/kubeovn/kube-ovn/issues/1191
qosQueueMap, err := ListQosQueueIds()
qosQueueMap, err := ListQosQueueIDs()
if err != nil {
klog.Error(err)
return err
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/framework/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (c *EndpointsClient) Patch(original, modified *corev1.Endpoints) *corev1.En
ExpectNoError(err)

var patchedEndpoints *corev1.Endpoints
err = wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(_ context.Context) (bool, error) {
s, err := c.EndpointsInterface.Patch(context.TODO(), original.Name, types.MergePatchType, patch, metav1.PatchOptions{}, "")
if err != nil {
return handleWaitingAPIError(err, false, "patch endpoints %q", original.Name)
Expand Down Expand Up @@ -106,7 +106,7 @@ func (c *EndpointsClient) DeleteSync(name string) {
// WaitUntil waits the given timeout duration for the specified condition to be met.
func (c *EndpointsClient) WaitUntil(name string, cond func(s *corev1.Endpoints) (bool, error), condDesc string, _, timeout time.Duration) *corev1.Endpoints {
var endpoints *corev1.Endpoints
err := wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
err := wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(_ context.Context) (bool, error) {
Logf("Waiting for endpoints %s to meet condition %q", name, condDesc)
endpoints = c.Get(name).DeepCopy()
met, err := cond(endpoints)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/framework/switch-lb-rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (c *SwitchLBRuleClient) Patch(original, modified *apiv1.SwitchLBRule) *apiv
ExpectNoError(err)

var patchedService *apiv1.SwitchLBRule
err = wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(_ context.Context) (bool, error) {
s, err := c.SwitchLBRuleInterface.Patch(context.TODO(), original.Name, types.MergePatchType, patch, metav1.PatchOptions{}, "")
if err != nil {
return handleWaitingAPIError(err, false, "patch switch-lb-rule %q", original.Name)
Expand Down Expand Up @@ -107,7 +107,7 @@ func (c *SwitchLBRuleClient) DeleteSync(name string) {
// WaitUntil waits the given timeout duration for the specified condition to be met.
func (c *SwitchLBRuleClient) WaitUntil(name string, cond func(s *apiv1.SwitchLBRule) (bool, error), condDesc string, _, timeout time.Duration) *apiv1.SwitchLBRule {
var rules *apiv1.SwitchLBRule
err := wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
err := wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(_ context.Context) (bool, error) {
Logf("Waiting for switch-lb-rule %s to meet condition %q", name, condDesc)
rules = c.Get(name).DeepCopy()
met, err := cond(rules)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/ha/ha_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var _ = framework.Describe("[group:ha]", func() {
deployClient.SetScale(deploy.Name, 0)

ginkgo.By("Waiting for ovn-central pods to disappear")
framework.WaitUntil(2*time.Second, 30*time.Second, func(ctx context.Context) (bool, error) {
framework.WaitUntil(2*time.Second, 30*time.Second, func(_ context.Context) (bool, error) {
pods, err := deployClient.GetAllPods(deploy)
if err != nil {
return false, err
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/kube-ovn/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ var _ = framework.Describe("[group:service]", func() {
protocol := strings.ToLower(util.CheckProtocol(nodeIP))
ginkgo.By("Checking " + protocol + " connection via node " + nodeName)
cmd := fmt.Sprintf("curl -q -s --connect-timeout 5 %s/clientip", util.JoinHostPort(nodeIP, nodePort))
framework.WaitUntil(2*time.Second, 30*time.Second, func(ctx context.Context) (bool, error) {
framework.WaitUntil(2*time.Second, 30*time.Second, func(_ context.Context) (bool, error) {
ginkgo.By(fmt.Sprintf(`Executing %q in pod %s/%s`, cmd, namespaceName, hostPodName))
_, err := e2epodoutput.RunHostCmd(namespaceName, hostPodName, cmd)
return err == nil, nil
Expand Down
Loading