Skip to content

Commit

Permalink
fix: when podName or namespace contains dot, lsp cannot be deleted co…
Browse files Browse the repository at this point in the history
…rrectly
  • Loading branch information
oilbeater committed May 12, 2020
1 parent bad76ad commit 5f8b9b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,15 @@ func (c *Controller) Run(stopCh <-chan struct{}) {
klog.Fatalf("failed to init ovn resource %v", err)
}

if err := c.InitIPAM(); err != nil {
klog.Fatalf("failed to init ipam %v", err)
}

// remove resources in ovndb that not exist any more in kubernetes resources
if err := c.gc(); err != nil {
klog.Fatalf("gc failed %v", err)
}

if err := c.InitIPAM(); err != nil {
klog.Fatalf("failed to init ipam %v", err)
}

// start workers to do all the network operations
c.startWorkers(stopCh)
<-stopCh
Expand Down
16 changes: 8 additions & 8 deletions pkg/controller/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ func (c *Controller) gcLogicalSwitchPort() error {
return err
}
for _, lsp := range lsps {
if !strings.Contains(lsp, ".") {
// ignore router ports
continue
}
if !util.IsStringIn(lsp, ipNames) {
if strings.Contains(lsp, ".") {
klog.Infof("gc logical switch port %s", lsp)
podName := strings.Split(lsp, ".")[0]
podNameSpace := strings.Split(lsp, ".")[1]
if err := c.handleDeletePod(fmt.Sprintf("%s/%s", podNameSpace, podName)); err != nil {
klog.Errorf("failed to gc port %s, %v", lsp, err)
return err
}
klog.Infof("gc logical switch port %s", lsp)
if err := c.ovnClient.DeletePort(lsp); err != nil {
klog.Errorf("failed to delete lsp %s, %v", lsp, err)
return err
}
}
}
Expand Down

0 comments on commit 5f8b9b4

Please sign in to comment.