Skip to content

Commit

Permalink
Merge pull request #4331 from josedonizetti/kvm-skip-network-deletion…
Browse files Browse the repository at this point in the history
…-if-not-exist

Skip kvm network deletion if private network doesn't exist
  • Loading branch information
tstromberg authored May 24, 2019
2 parents 2e7b8b5 + fc2e2e5 commit faf9496
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/drivers/kvm/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,12 @@ func (d *Driver) deleteNetwork() error {
log.Debugf("Checking if network %s exists...", d.PrivateNetwork)
network, err := conn.LookupNetworkByName(d.PrivateNetwork)
if err != nil {
// TODO: decide if we really wanna throw an error?
return errors.Wrap(err, "network %s does not exist")
if libvirtErr, ok := err.(libvirt.Error); ok && libvirtErr.Code == libvirt.ERR_NO_NETWORK {
log.Warnf("Network %s does not exist. Skipping deletion", d.PrivateNetwork)
return nil
}

return errors.Wrapf(err, "failed looking for network %s", d.PrivateNetwork)
}
log.Debugf("Network %s exists", d.PrivateNetwork)

Expand Down

0 comments on commit faf9496

Please sign in to comment.