Skip to content

Commit 6e40eb9

Browse files
pedjakclaude
andcommitted
fix: make demo e2e catalog queries resilient to transient failures
The generate-demos CI job fails ~45% of the time with jq exit status 5 on the ClusterCatalog Quickstart scenario. Three issues contribute: - jq -s (slurp mode) buffers the entire operatorhubio FBC response in memory before processing, risking system errors on large catalogs - catalog content queries run exactly once with no retry, so any transient port-forward or network hiccup fails the step immediately - bash() does not attach stderr to ExitError, making failures opaque Remove jq slurp mode so each JSON object is processed in constant memory. Wrap CatalogContainsSomePackages, PackageHasSomeChannels, and PackageHasSomeBundles in waitFor for retry on transient errors. Add curl --retry for transport-level resilience. Inject stderr into ExitError in bash() to match k8sClient diagnostics. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7ec6a0e commit 6e40eb9

1 file changed

Lines changed: 30 additions & 25 deletions

File tree

‎test/e2e/steps/demo_steps.go‎

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"crypto/tls"
77
"encoding/json"
8+
"errors"
89
"fmt"
910
"net"
1011
"net/http"
@@ -41,6 +42,10 @@ func bash(ctx context.Context, script string) (string, error) {
4142

4243
if err != nil {
4344
logger.V(1).Info("Failed to run", "command", script, "stderr", stderr, "error", err)
45+
var exitErr *exec.ExitError
46+
if errors.As(err, &exitErr) {
47+
exitErr.Stderr = stderrBuf.Bytes()
48+
}
4449
}
4550
logger.V(1).Info("Output", "command", script, "output", stdout)
4651

@@ -115,45 +120,45 @@ func catalogCurlJq(ctx context.Context, catalogName, jqFilter string) (string, e
115120
return "", err
116121
}
117122
script := fmt.Sprintf(
118-
`curl -s -k https://%s/catalogs/%s/api/v1/all | jq -s '%s'`,
123+
`curl -s -k --retry 3 --retry-delay 2 --retry-all-errors https://%s/catalogs/%s/api/v1/all | jq '%s'`,
119124
addr, catalogName, jqFilter,
120125
)
121126
return bash(ctx, script)
122127
}
123128

124129
func CatalogContainsSomePackages(ctx context.Context, catalogName string) error {
125-
out, err := catalogCurlJq(ctx, catalogName,
126-
`.[] | select(.schema == "olm.package") | .name`)
127-
if err != nil {
128-
return err
129-
}
130-
if strings.TrimSpace(out) == "" {
131-
return fmt.Errorf("catalog %q contains no packages", catalogName)
132-
}
130+
waitFor(ctx, func() bool {
131+
out, err := catalogCurlJq(ctx, catalogName,
132+
`select(.schema == "olm.package") | .name`)
133+
if err != nil {
134+
return false
135+
}
136+
return strings.TrimSpace(out) != ""
137+
})
133138
return nil
134139
}
135140

136141
func PackageHasSomeChannels(ctx context.Context, packageName, catalogName string) error {
137-
out, err := catalogCurlJq(ctx, catalogName,
138-
fmt.Sprintf(`.[] | select(.schema == "olm.channel") | select(.package == "%s") | .name`, packageName))
139-
if err != nil {
140-
return err
141-
}
142-
if strings.TrimSpace(out) == "" {
143-
return fmt.Errorf("package %q in catalog %q has no channels", packageName, catalogName)
144-
}
142+
waitFor(ctx, func() bool {
143+
out, err := catalogCurlJq(ctx, catalogName,
144+
fmt.Sprintf(`select(.schema == "olm.channel") | select(.package == "%s") | .name`, packageName))
145+
if err != nil {
146+
return false
147+
}
148+
return strings.TrimSpace(out) != ""
149+
})
145150
return nil
146151
}
147152

148153
func PackageHasSomeBundles(ctx context.Context, packageName, catalogName string) error {
149-
out, err := catalogCurlJq(ctx, catalogName,
150-
fmt.Sprintf(`.[] | select(.schema == "olm.bundle") | select(.package == "%s") | .name`, packageName))
151-
if err != nil {
152-
return err
153-
}
154-
if strings.TrimSpace(out) == "" {
155-
return fmt.Errorf("package %q in catalog %q has no bundles", packageName, catalogName)
156-
}
154+
waitFor(ctx, func() bool {
155+
out, err := catalogCurlJq(ctx, catalogName,
156+
fmt.Sprintf(`select(.schema == "olm.bundle") | select(.package == "%s") | .name`, packageName))
157+
if err != nil {
158+
return false
159+
}
160+
return strings.TrimSpace(out) != ""
161+
})
157162
return nil
158163
}
159164

0 commit comments

Comments
 (0)