Skip to content

Commit

Permalink
Flaky: e2e namespace deletion
Browse files Browse the repository at this point in the history
This fixes the issue if the e2e test tries to delete namespace
that is already in a Terminating state.
  • Loading branch information
markmandel committed Jul 1, 2020
1 parent b9825c9 commit 98e15a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,13 +581,13 @@ func (f *Framework) DeleteNamespace(namespace string) error {
}}
payloadBytes, _ := json.Marshal(payload)
if _, err := kubeCore.Pods(namespace).Patch(pod.Name, types.JSONPatchType, payloadBytes); err != nil {
return errors.Errorf("updating pod %s failed: %s", pod.GetName(), err)
return errors.Wrapf(err, "updating pod %s failed", pod.GetName())
}
}
}

if err := kubeCore.Namespaces().Delete(namespace, &metav1.DeleteOptions{}); err != nil {
return errors.Errorf("deleting namespace %s failed: %s", namespace, err)
return errors.Wrapf(err, "deleting namespace %s failed", namespace)
}
logrus.Infof("Namespace %s is deleted", namespace)
return nil
Expand Down
14 changes: 11 additions & 3 deletions test/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ import (
"time"

e2eframework "agones.dev/agones/test/e2e/framework"
"github.com/sirupsen/logrus"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
)

var framework *e2eframework.Framework

func TestMain(m *testing.M) {
logrus.SetFormatter(&logrus.TextFormatter{
log.SetFormatter(&log.TextFormatter{
EnvironmentOverrideColors: true,
FullTimestamp: true,
TimestampFormat: "2006-01-02 15:04:05.000",
Expand Down Expand Up @@ -103,7 +104,14 @@ func cleanupNamespaces(framework *e2eframework.Framework) error {
// loop through them, and delete them
for _, ns := range list.Items {
if err := framework.DeleteNamespace(ns.ObjectMeta.Name); err != nil {
return err
cause := errors.Cause(err)
if k8serrors.IsConflict(cause) {
log.WithError(cause).Warn("namespace already being deleted")
continue
}
// here just in case we need to catch other errors
log.WithField("reason", k8serrors.ReasonForError(cause)).Info("cause for namespace deletion error")
return cause
}
}

Expand Down

0 comments on commit 98e15a5

Please sign in to comment.