Skip to content

Commit

Permalink
fix: default network
Browse files Browse the repository at this point in the history
  • Loading branch information
fanriming committed Dec 2, 2020
1 parent ccea68b commit 86584b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,19 @@ func (c *Controller) handleAddPod(key string) error {
return err
}

podSubnets := attachmentSubnets
if _, hasOtherDefaultNet := pod.Annotations[util.DefaultNetworkAnnotation]; !hasOtherDefaultNet {
podSubnets = append(attachmentSubnets, defaultSubnet)
}

op := "replace"
if pod.Annotations == nil || len(pod.Annotations) == 0 {
op = "add"
pod.Annotations = map[string]string{}
}

// Avoid create lsp for already running pod in ovn-nb when controller restart
for _, subnet := range needAllocateSubnets(pod, append(attachmentSubnets, defaultSubnet)) {
for _, subnet := range needAllocateSubnets(pod, podSubnets) {
ip, mac, err := c.acquireAddress(pod, subnet)
if err != nil {
c.recorder.Eventf(pod, v1.EventTypeWarning, "AcquireAddressFailed", err.Error())
Expand Down Expand Up @@ -477,6 +482,10 @@ func (c *Controller) handleUpdatePod(key string) error {
return err
}

if _, hasOtherDefaultNet := pod.Annotations[util.DefaultNetworkAnnotation]; hasOtherDefaultNet {
return nil
}

klog.Infof("update pod %s/%s", namespace, name)
podIP := pod.Annotations[util.IpAddressAnnotation]

Expand Down
1 change: 1 addition & 0 deletions pkg/util/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const (

OvnProvider = "ovn"
AttachmentNetworkAnnotation = "k8s.v1.cni.cncf.io/networks"
DefaultNetworkAnnotation = "v1.multus-cni.io/default-network"

SRIOVResourceName = "mellanox.com/cx5_sriov_switchdev"

Expand Down

0 comments on commit 86584b9

Please sign in to comment.