Skip to content

Commit

Permalink
opt: only allow specifies default subnet
Browse files Browse the repository at this point in the history
(cherry picked from commit 9eb96dd)
  • Loading branch information
fanriming authored and oilbeater committed Oct 26, 2020
1 parent 99e393e commit cf96d6d
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ func (c *Controller) getPodDefaultSubnet(pod *v1.Pod) (*kubeovnv1.Subnet, error)

lsName, lsExist := pod.Annotations[util.LogicalSwitchAnnotation]
for _, s := range subnets {
if lsExist && lsName != s.Name {
continue
if lsExist && lsName == s.Name {
return s, nil
}
for _, ns := range s.Spec.Namespaces {
if ns == pod.Namespace {
Expand All @@ -638,15 +638,10 @@ func (c *Controller) getPodAttachmentSubnet(pod *v1.Pod) ([]*kubeovnv1.Subnet, e
return nil, err
}

lsName, lsExist := pod.Annotations[util.LogicalSwitchAnnotation]
result := make([]*kubeovnv1.Subnet, 0, len(attachments))
for _, attach := range attachments {
provider := fmt.Sprintf("%s.%s", attach.Name, attach.Namespace)

for _, subnet := range subnets {
if lsExist && lsName != subnet.Name {
continue
}
if subnet.Spec.Provider == provider {
result = append(result, subnet)
break
Expand Down

0 comments on commit cf96d6d

Please sign in to comment.