Skip to content

Commit

Permalink
robustness-dymmy-int
Browse files Browse the repository at this point in the history
added robustness for the hanging resources when a deployment fails.
  • Loading branch information
henderiw committed Sep 8, 2020
1 parent 8310570 commit 76f90fc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions clab/netlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,27 @@ import (
log "github.com/sirupsen/logrus"
)

func (c *cLab) InitVirtualWiring() {
log.Debug("delete dummyA eth link")
var cmd *exec.Cmd
var err error
cmd = exec.Command("sudo", "ip", "link", "del", "dummyA")
err = runCmd(cmd)
if err != nil {
log.Debugf("%s failed with: %v", cmd.String(), err)
}
cmd = exec.Command("sudo", "ip", "link", "del", "dummyB")
err = runCmd(cmd)
if err != nil {
log.Debugf("%s failed with: %v", cmd.String(), err)
}
}

// CreateVirtualWiring provides the virtual topology between the containers
func (c *cLab) CreateVirtualWiring(id int, link *Link) (err error) {
log.Infof("Create virtual wire : %s, %s, %s, %s", link.A.Node.LongName, link.B.Node.LongName, link.A.EndpointName, link.B.EndpointName)


CreateDirectory("/run/netns/", 0755)

var src, dst string
Expand Down Expand Up @@ -226,6 +243,7 @@ func (c *cLab) DeleteVirtualWiring(id int, link *Link) (err error) {
log.Debugf("%s failed with: %v", cmd.String(), err)
}
}

return nil
}

Expand Down
2 changes: 2 additions & 0 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ var deployCmd = &cobra.Command{
log.Error(err)
}
}
// cleanup hanging resources if a deployment failed before
c.InitVirtualWiring()
// wire the links between the nodes based on cabling plan
for i, link := range c.Links {
if err = c.CreateVirtualWiring(i, link); err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ var destroyCmd = &cobra.Command{
log.Error(err)
}
}
c.InitVirtualWiring()
},
}

Expand Down

0 comments on commit 76f90fc

Please sign in to comment.