Skip to content

Commit 28e7f94

Browse files
committed
Return CRD uninstall error
Signed-off-by: Pires <[email protected]>
1 parent bc5ae78 commit 28e7f94

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

pkg/envtest/crd.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"bytes"
2222
"io"
2323
"io/ioutil"
24+
apierrors "k8s.io/apimachinery/pkg/api/errors"
2425
"os"
2526
"path/filepath"
2627
"time"
@@ -204,7 +205,10 @@ func UninstallCRDs(config *rest.Config, options CRDInstallOptions) error {
204205
for _, crd := range options.CRDs {
205206
log.V(1).Info("uninstalling CRD", "crd", crd.Name)
206207
if err := cs.ApiextensionsV1beta1().CustomResourceDefinitions().Delete(crd.Name, &metav1.DeleteOptions{}); err != nil {
207-
return err
208+
// If CRD is not found, we can consider success
209+
if !apierrors.IsNotFound(err) {
210+
return err
211+
}
208212
}
209213
}
210214

pkg/envtest/server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ type Environment struct {
140140
func (te *Environment) Stop() error {
141141
if te.CRDInstallOptions.CleanUpAfterUse {
142142
if err := UninstallCRDs(te.Config, te.CRDInstallOptions); err != nil {
143-
// This error should be harmless so just log it.
144-
log.Error(err, "failed to uninstall CRDs")
143+
return err
145144
}
146145
}
147146
if te.useExistingCluster() {

0 commit comments

Comments
 (0)