From fc2e2e52c559d49961933be276468e0485f42754 Mon Sep 17 00:00:00 2001 From: josedonizetti Date: Thu, 23 May 2019 06:17:12 -0300 Subject: [PATCH] Skip kvm network deletion if private network doesn't exist --- pkg/drivers/kvm/network.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/drivers/kvm/network.go b/pkg/drivers/kvm/network.go index bcea96441ef3..7ea38a2aa666 100644 --- a/pkg/drivers/kvm/network.go +++ b/pkg/drivers/kvm/network.go @@ -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)