Skip to content

Commit

Permalink
Fix the default egress gateway problem
Browse files Browse the repository at this point in the history
Signed-off-by: bzsuni <[email protected]>
  • Loading branch information
bzsuni committed Dec 11, 2023
1 parent ee2aa76 commit 31c30f1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions test/e2e/common/egw.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/google/uuid"
"k8s.io/apimachinery/pkg/api/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -251,3 +252,26 @@ func CheckEgressGatewayStatusSynced(ctx context.Context, cli client.Client, egw
}
}
}

func DeleteEgressGateway(ctx context.Context, cli client.Client, egw *egressv1.EgressGateway, timeout time.Duration) error {
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

err := DeleteObj(ctx, cli, egw)
if err != nil {
return err
}

for {
select {
case <-ctx.Done():
return e2eerr.ErrTimeout
default:
err = cli.Get(ctx, types.NamespacedName{Name: egw.Name}, egw)
if apierrors.IsNotFound(err) {
return nil
}
time.Sleep(time.Second / 2)
}
}
}
2 changes: 1 addition & 1 deletion test/e2e/egressgateway/default_egressgateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ var _ = Describe("Test default egress gateway", Label("DefaultEgressGateway", "G
err = common.DeleteObj(ctx, cli, nsDefaultEgw)
Expect(err).NotTo(HaveOccurred())

err = common.DeleteObj(ctx, cli, clusterDefaultEgw)
err = common.DeleteEgressGateway(ctx, cli, clusterDefaultEgw, time.Second*3)
Expect(err).NotTo(HaveOccurred())

ns := &corev1.Namespace{}
Expand Down

0 comments on commit 31c30f1

Please sign in to comment.