Skip to content

Commit

Permalink
fix(ci): k8s integration suite wait for resource
Browse files Browse the repository at this point in the history
The code was previously calling `GetUnstructuredResource` which wraps
the k8s error, construct the mapping and call the api directly.

Signed-off-by: Noel Georgi <git@frezbo.dev>
  • Loading branch information
frezbo committed Jan 26, 2025
1 parent cd5e549 commit baf81cd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/integration/base/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,20 @@ func (k8sSuite *K8sSuite) WaitForResource(ctx context.Context, namespace, group,
// WaitForResourceToBeAvailable waits for the resource with the given namespace, group, kind, version and name to be available.
func (k8sSuite *K8sSuite) WaitForResourceToBeAvailable(ctx context.Context, duration time.Duration, namespace, group, kind, version, resourceName string) error {
return retry.Constant(duration).Retry(func() error {
_, err := k8sSuite.GetUnstructuredResource(ctx, namespace, group, kind, version, resourceName)
mapping, err := k8sSuite.Mapper.RESTMapping(schema.GroupKind{
Group: group,
Kind: kind,
}, version)
if err != nil {
return fmt.Errorf("error creating mapping for resource %s/%s/%s", group, kind, version)
}

dr := k8sSuite.DynamicClient.Resource(mapping.Resource).Namespace(namespace)

_, err = dr.Get(ctx, resourceName, metav1.GetOptions{})
if errors.IsNotFound(err) {
k8sSuite.T().Logf("resource %s/%s/%s/%s not found, retrying", group, version, kind, resourceName)

return retry.ExpectedError(err)
}

Expand Down

0 comments on commit baf81cd

Please sign in to comment.