Skip to content

Commit

Permalink
refactor: add unknown config to lsp (#2076)
Browse files Browse the repository at this point in the history
* reflactor: add unkown config to lsp

* fix merge error
  • Loading branch information
changluyi committed Nov 24, 2022
1 parent d1bd047 commit c97b1f1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (c *Controller) handleAddNode(key string) error {
}

ipStr := util.GetStringIP(v4IP, v6IP)
if err := c.ovnLegacyClient.CreatePort(c.config.NodeSwitch, portName, ipStr, mac, "", "", false, "", "", false); err != nil {
if err := c.ovnLegacyClient.CreatePort(c.config.NodeSwitch, portName, ipStr, mac, "", "", false, "", "", false, false); err != nil {
return err
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ func (c *Controller) handleAddPod(key string) error {
}

portName := ovs.PodNameToPortName(podName, namespace, podNet.ProviderName)
if err := c.ovnLegacyClient.CreatePort(subnet.Name, portName, ipStr, mac, podName, pod.Namespace, portSecurity, securityGroupAnnotation, vips, podNet.AllowLiveMigration); err != nil {
hasUnknown := pod.Annotations[fmt.Sprintf(util.Layer2ForwardAnnotationTemplate, podNet.ProviderName)] == "true"
if err := c.ovnLegacyClient.CreatePort(subnet.Name, portName, ipStr, mac, podName, pod.Namespace, portSecurity, securityGroupAnnotation, vips, podNet.AllowLiveMigration, hasUnknown); err != nil {
c.recorder.Eventf(pod, v1.EventTypeWarning, "CreateOVNPortFailed", err.Error())
return err
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/ovs/ovn-nbctl-legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (c LegacyClient) SetPortSecurity(portSecurity bool, port, mac, ipStr, vips
}

// CreatePort create logical switch port in ovn
func (c LegacyClient) CreatePort(ls, port, ip, mac, pod, namespace string, portSecurity bool, securityGroups string, vips string, liveMigration bool) error {
func (c LegacyClient) CreatePort(ls, port, ip, mac, pod, namespace string, portSecurity bool, securityGroups string, vips string, liveMigration bool, hasUnknown bool) error {
var ovnCommand []string
var addresses []string
addresses = append(addresses, mac)
Expand Down Expand Up @@ -217,6 +217,10 @@ func (c LegacyClient) CreatePort(ls, port, ip, mac, pod, namespace string, portS
// set mac and ip
ovnCommand = append(ovnCommand,
"--", "lsp-set-addresses", port, strings.Join(addresses, " "))

if hasUnknown {
ovnCommand = append(ovnCommand, "unknown")
}
}

if portSecurity {
Expand Down
9 changes: 5 additions & 4 deletions pkg/util/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ const (
LogicalRouterAnnotation = "ovn.kubernetes.io/logical_router"
VpcAnnotation = "ovn.kubernetes.io/vpc"

PortSecurityAnnotationTemplate = "%s.kubernetes.io/port_security"
PortVipAnnotationTemplate = "%s.kubernetes.io/port_vips"
PortSecurityAnnotation = "ovn.kubernetes.io/port_security"
NorthGatewayAnnotation = "ovn.kubernetes.io/north_gateway"
Layer2ForwardAnnotationTemplate = "%s.kubernetes.io/layer2_forward"
PortSecurityAnnotationTemplate = "%s.kubernetes.io/port_security"
PortVipAnnotationTemplate = "%s.kubernetes.io/port_vips"
PortSecurityAnnotation = "ovn.kubernetes.io/port_security"
NorthGatewayAnnotation = "ovn.kubernetes.io/north_gateway"

AllocatedAnnotationSuffix = ".kubernetes.io/allocated"
AllocatedAnnotationTemplate = "%s.kubernetes.io/allocated"
Expand Down

0 comments on commit c97b1f1

Please sign in to comment.