Skip to content

Commit

Permalink
fix sts pod's logical switch port do not update externa_id vendor and…
Browse files Browse the repository at this point in the history
… ls (#3778)

Signed-off-by: Changlu Yi <clyi@alauda.io>
  • Loading branch information
changluyi committed Feb 28, 2024
1 parent 078a03f commit 16b563e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/ovs/ovn-nb-logical_switch_port.go
Expand Up @@ -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(),
Expand Down Expand Up @@ -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 {
Expand All @@ -89,15 +93,15 @@ 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)
}
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)
Expand Down

0 comments on commit 16b563e

Please sign in to comment.