Skip to content

Commit

Permalink
fix some normative issues 24.12.16
Browse files Browse the repository at this point in the history
Signed-off-by: dolibali <[email protected]>
  • Loading branch information
dolibali committed Dec 16, 2024
1 parent ab4824e commit a095672
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
12 changes: 6 additions & 6 deletions pkg/controller/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1044,12 +1044,6 @@ func (c *Controller) addPolicyRouteForLocalDNSCacheOnNode(dnsIPs []string, nodeP
return c.deletePolicyRouteForLocalDNSCacheOnNode(nodeName, af)
}

policies, err := c.OVNNbClient.GetLogicalRouterPoliciesByExtID(c.config.ClusterRouter, "node", nodeName)
if err != nil {
klog.Errorf("failed to list logical router policies with external-ids:node = %q: %v", nodeName, err)
return err
}

var (
externalIDs = map[string]string{
"vendor": util.CniTypeName,
Expand All @@ -1066,6 +1060,12 @@ func (c *Controller) addPolicyRouteForLocalDNSCacheOnNode(dnsIPs []string, nodeP
matches.Add(fmt.Sprintf("ip%d.src == $%s && ip%d.dst == %s", af, pgAs, af, ip))
}

policies, err := c.OVNNbClient.GetLogicalRouterPoliciesByExtID(c.config.ClusterRouter, "node", nodeName)
if err != nil {
klog.Errorf("failed to list logical router policies with external-ids:node = %q: %v", nodeName, err)
return err
}

for _, policy := range policies {
if len(policy.ExternalIDs) == 0 || policy.ExternalIDs["vendor"] != util.CniTypeName || policy.ExternalIDs["isLocalDnsCache"] != "true" {
continue
Expand Down
10 changes: 5 additions & 5 deletions pkg/daemon/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func InitOVSBridges() (map[string]string, error) {

// InitNodeGateway init ovn0
func InitNodeGateway(config *Configuration) error {
var portName, ip, cidr, macAddr, gw, ipAddr string
var portName, ip, joinCIDR, macAddr, gw, ipAddr string
for {
nodeName := config.NodeName
node, err := config.KubeClient.CoreV1().Nodes().Get(context.Background(), nodeName, metav1.GetOptions{})
Expand All @@ -72,7 +72,7 @@ func InitNodeGateway(config *Configuration) error {
}
macAddr = node.Annotations[util.MacAddressAnnotation]
ip = node.Annotations[util.IPAddressAnnotation]
cidr = node.Annotations[util.CidrAnnotation]
joinCIDR = node.Annotations[util.CidrAnnotation]
portName = node.Annotations[util.PortNameAnnotation]
gw = node.Annotations[util.GatewayAnnotation]
break
Expand All @@ -82,12 +82,12 @@ func InitNodeGateway(config *Configuration) error {
return fmt.Errorf("failed to parse mac %s %w", mac, err)
}

ipAddr, err = util.GetIPAddrWithMask(ip, cidr)
ipAddr, err = util.GetIPAddrWithMask(ip, joinCIDR)
if err != nil {
klog.Errorf("failed to get ip %s with mask %s, %v", ip, cidr, err)
klog.Errorf("failed to get ip %s with mask %s, %v", ip, joinCIDR, err)
return err
}
return configureNodeNic(portName, ipAddr, gw, cidr, mac, config.MTU)
return configureNodeNic(portName, ipAddr, gw, joinCIDR, mac, config.MTU)
}

func InitMirror(config *Configuration) error {
Expand Down
1 change: 1 addition & 0 deletions pkg/ovs/ovn-nb-logical_router_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func (c *OVNNbClient) AddLogicalRouterPolicy(lrName string, priority int, match,
return fmt.Errorf("get policy priority %d match %s in logical router %s: %w", priority, match, lrName, err)
}

// Same priority, same match, only retain the first policy
duplicate := make([]string, 0, len(policyList))
var policyFound *ovnnb.LogicalRouterPolicy
for _, policy := range policyList {
Expand Down

0 comments on commit a095672

Please sign in to comment.