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 (#3777)

Signed-off-by: Changlu Yi <[email protected]>
  • Loading branch information
changluyi authored Feb 28, 2024
1 parent aa6e36d commit da6b522
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/ovs/ovn-nb-logical_switch_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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 @@ -68,6 +68,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 @@ -90,15 +94,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 da6b522

Please sign in to comment.