Skip to content

Commit

Permalink
Make cleanup more tolerant
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Feb 27, 2024
1 parent be719e9 commit 15495af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion test/framework/ip/vcsim.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/pkg/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/rand"
Expand Down Expand Up @@ -114,7 +115,7 @@ func (h *vcsim) Cleanup(ctx context.Context, ipAddressClaims AddressClaims) erro
},
}
Byf("Deleting vcsim ControlPlaneEndpoint %s", klog.KObj(controlPlaneEndpoint))
if err := h.client.Delete(ctx, controlPlaneEndpoint); err != nil {
if err := h.client.Delete(ctx, controlPlaneEndpoint); err != nil && !apierrors.IsNotFound(err) {
errList = append(errList, err)
}
}
Expand Down
6 changes: 5 additions & 1 deletion test/framework/vcsim/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

. "github.com/onsi/ginkgo/v2"
"github.com/pkg/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -89,5 +90,8 @@ func Delete(ctx context.Context, c client.Client, name string, skipCleanup bool)
},
}
Byf("Deleting VCenterSimulator %s", klog.KObj(vcsim))
return c.Delete(ctx, vcsim)
if err := c.Delete(ctx, vcsim); err != nil && !apierrors.IsNotFound(err) {
return err
}
return nil
}

0 comments on commit 15495af

Please sign in to comment.