From 16b563e208563061892d78ee751861bd93567fa7 Mon Sep 17 00:00:00 2001 From: changluyi <47097611+changluyi@users.noreply.github.com> Date: Wed, 28 Feb 2024 16:03:16 +0800 Subject: [PATCH] fix sts pod's logical switch port do not update externa_id vendor and ls (#3778) Signed-off-by: Changlu Yi --- pkg/ovs/ovn-nb-logical_switch_port.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/ovs/ovn-nb-logical_switch_port.go b/pkg/ovs/ovn-nb-logical_switch_port.go index 01154ff1897..05c37030fac 100644 --- a/pkg/ovs/ovn-nb-logical_switch_port.go +++ b/pkg/ovs/ovn-nb-logical_switch_port.go @@ -16,7 +16,7 @@ import ( "github.com/kubeovn/kube-ovn/pkg/util" ) -func buildLogicalSwitchPort(lspName, ip, mac, podName, namespace string, portSecurity bool, securityGroups, vips string, enableDHCP bool, dhcpOptions *DHCPOptionsUUIDs, vpc string) *ovnnb.LogicalSwitchPort { +func buildLogicalSwitchPort(lspName, lsName, ip, mac, podName, namespace string, portSecurity bool, securityGroups, vips string, enableDHCP bool, dhcpOptions *DHCPOptionsUUIDs, vpc string) *ovnnb.LogicalSwitchPort { /* normal lsp creation */ lsp := &ovnnb.LogicalSwitchPort{ UUID: ovsclient.NamedUUID(), @@ -67,6 +67,10 @@ func buildLogicalSwitchPort(lspName, ip, mac, podName, namespace string, portSec lsp.ExternalIDs["pod"] = namespace + "/" + podName } + // attach necessary info + lsp.ExternalIDs[logicalSwitchKey] = lsName + lsp.ExternalIDs["vendor"] = util.CniTypeName + // set dhcp options if enableDHCP && dhcpOptions != nil { if len(dhcpOptions.DHCPv4OptionsUUID) != 0 { @@ -89,7 +93,7 @@ func (c *OVNNbClient) CreateLogicalSwitchPort(lsName, lspName, ip, mac, podName, // update if exists if exist { - lsp := buildLogicalSwitchPort(lspName, ip, mac, podName, namespace, portSecurity, securityGroups, vips, enableDHCP, dhcpOptions, vpc) + lsp := buildLogicalSwitchPort(lspName, lsName, ip, mac, podName, namespace, portSecurity, securityGroups, vips, enableDHCP, dhcpOptions, vpc) if err := c.UpdateLogicalSwitchPort(lsp, &lsp.PortSecurity, &lsp.ExternalIDs); err != nil { klog.Error(err) return fmt.Errorf("failed to update logical switch port %s: %v", lspName, err) @@ -97,7 +101,7 @@ func (c *OVNNbClient) CreateLogicalSwitchPort(lsName, lspName, ip, mac, podName, return nil } - lsp := buildLogicalSwitchPort(lspName, ip, mac, podName, namespace, portSecurity, securityGroups, vips, enableDHCP, dhcpOptions, vpc) + lsp := buildLogicalSwitchPort(lspName, lsName, ip, mac, podName, namespace, portSecurity, securityGroups, vips, enableDHCP, dhcpOptions, vpc) ops, err := c.CreateLogicalSwitchPortOp(lsp, lsName) if err != nil { klog.Error(err)