Skip to content

Commit

Permalink
Revert "fix: wait namespace is actually deleted (kudobuilder#413)" (k…
Browse files Browse the repository at this point in the history
…udobuilder#421)

This reverts commit 6b6e6b9.

Signed-off-by: Israel Blancas <iblancasa@gmail.com>
  • Loading branch information
kensipe authored and iblancasa committed Nov 17, 2022
1 parent 891056b commit 7fffd24
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions pkg/test/case.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import (
corev1 "k8s.io/api/core/v1"
eventsv1 "k8s.io/api/events/v1"
eventsbeta1 "k8s.io/api/events/v1beta1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/discovery"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down Expand Up @@ -70,26 +69,13 @@ func (t *Case) DeleteNamespace(cl client.Client, ns *namespace) error {
defer cancel()
}

nsObj := &corev1.Namespace{
return cl.Delete(ctx, &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: ns.Name,
},
TypeMeta: metav1.TypeMeta{
Kind: "Namespace",
},
}

if err := cl.Delete(ctx, nsObj); err != nil {
return err
}

return wait.PollImmediateUntilWithContext(ctx, 100*time.Millisecond, func(ctx context.Context) (done bool, err error) {
actual := &corev1.Namespace{}
err = cl.Get(ctx, client.ObjectKey{Name: ns.Name}, actual)
if k8serrors.IsNotFound(err) {
return true, nil
}
return false, err
})
}

Expand Down Expand Up @@ -134,7 +120,7 @@ func (t *Case) NamespaceExists(namespace string) (bool, error) {
}
ns := &corev1.Namespace{}
err = cl.Get(context.TODO(), client.ObjectKey{Name: namespace}, ns)
if err != nil && !k8serrors.IsNotFound(err) {
if err != nil && !errors.IsNotFound(err) {
return false, err
}
return ns.Name == namespace, nil
Expand Down

0 comments on commit 7fffd24

Please sign in to comment.