|
5 | 5 | "fmt" |
6 | 6 | appsv1 "k8s.io/api/apps/v1" |
7 | 7 | corev1 "k8s.io/api/core/v1" |
| 8 | + apierrs "k8s.io/apimachinery/pkg/api/errors" |
8 | 9 | "k8s.io/apimachinery/pkg/util/wait" |
9 | 10 | elbv2gw "sigs.k8s.io/aws-load-balancer-controller/apis/gateway/v1beta1" |
10 | 11 | "sigs.k8s.io/aws-load-balancer-controller/pkg/algorithm" |
@@ -107,8 +108,6 @@ func (s *commonResourceStack) ScaleDeployment(ctx context.Context, f *framework. |
107 | 108 |
|
108 | 109 | func (s *commonResourceStack) Cleanup(ctx context.Context, f *framework.Framework) { |
109 | 110 | _ = s.deleteGateway(ctx, f) |
110 | | - // todo - fix |
111 | | - time.Sleep(5 * time.Minute) |
112 | 111 | _ = s.deleteNamespace(ctx, f) |
113 | 112 | _ = s.deleteGatewayClass(ctx, f) |
114 | 113 | } |
@@ -240,7 +239,20 @@ func (s *commonResourceStack) deleteService(ctx context.Context, f *framework.Fr |
240 | 239 | } |
241 | 240 |
|
242 | 241 | func (s *commonResourceStack) deleteGateway(ctx context.Context, f *framework.Framework) error { |
243 | | - return f.K8sClient.Delete(ctx, s.gw) |
| 242 | + err := f.K8sClient.Delete(ctx, s.gw) |
| 243 | + if err != nil { |
| 244 | + return err |
| 245 | + } |
| 246 | + observedGW := &gwv1.Gateway{} |
| 247 | + return wait.PollImmediateUntil(utils.PollIntervalShort, func() (bool, error) { |
| 248 | + if err := f.K8sClient.Get(ctx, k8s.NamespacedName(s.gw), observedGW); err != nil { |
| 249 | + if apierrs.IsNotFound(err) { |
| 250 | + return true, nil |
| 251 | + } |
| 252 | + return false, err |
| 253 | + } |
| 254 | + return false, nil |
| 255 | + }, ctx.Done()) |
244 | 256 | } |
245 | 257 |
|
246 | 258 | func (s *commonResourceStack) deleteGatewayClass(ctx context.Context, f *framework.Framework) error { |
|
0 commit comments