Skip to content

Commit baf81cd

Browse files
committed
fix(ci): k8s integration suite wait for resource
The code was previously calling `GetUnstructuredResource` which wraps the k8s error, construct the mapping and call the api directly. Signed-off-by: Noel Georgi <[email protected]>
1 parent cd5e549 commit baf81cd

File tree

1 file changed

+13
-1
lines changed
  • internal/integration/base

1 file changed

+13
-1
lines changed

internal/integration/base/k8s.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,20 @@ func (k8sSuite *K8sSuite) WaitForResource(ctx context.Context, namespace, group,
640640
// WaitForResourceToBeAvailable waits for the resource with the given namespace, group, kind, version and name to be available.
641641
func (k8sSuite *K8sSuite) WaitForResourceToBeAvailable(ctx context.Context, duration time.Duration, namespace, group, kind, version, resourceName string) error {
642642
return retry.Constant(duration).Retry(func() error {
643-
_, err := k8sSuite.GetUnstructuredResource(ctx, namespace, group, kind, version, resourceName)
643+
mapping, err := k8sSuite.Mapper.RESTMapping(schema.GroupKind{
644+
Group: group,
645+
Kind: kind,
646+
}, version)
647+
if err != nil {
648+
return fmt.Errorf("error creating mapping for resource %s/%s/%s", group, kind, version)
649+
}
650+
651+
dr := k8sSuite.DynamicClient.Resource(mapping.Resource).Namespace(namespace)
652+
653+
_, err = dr.Get(ctx, resourceName, metav1.GetOptions{})
644654
if errors.IsNotFound(err) {
655+
k8sSuite.T().Logf("resource %s/%s/%s/%s not found, retrying", group, version, kind, resourceName)
656+
645657
return retry.ExpectedError(err)
646658
}
647659

0 commit comments

Comments
 (0)