Skip to content

Commit 943d92f

Browse files
author
Vadim Rutkovsky
committed
tls registry: retry tests image resolution
Sometimes registry is slow to reply or throws temporary error. Add a method to retry the attempt
1 parent a726082 commit 943d92f

File tree

2 files changed

+23
-2
lines changed
  • pkg/monitortests/network/disruptionpodnetwork
  • test/extended/operators

2 files changed

+23
-2
lines changed

pkg/monitortests/network/disruptionpodnetwork/utils.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ package disruptionpodnetwork
33
import (
44
"bytes"
55
"context"
6+
"errors"
67
"fmt"
7-
"github.com/sirupsen/logrus"
88
"io/ioutil"
99
"os"
1010
"os/exec"
1111
"strings"
12+
"time"
13+
14+
"github.com/sirupsen/logrus"
1215

1316
configclient "github.com/openshift/client-go/config/clientset/versioned"
1417
exutil "github.com/openshift/origin/test/extended/util"
@@ -136,3 +139,21 @@ func GetOpenshiftTestsImagePullSpec(ctx context.Context, adminRESTConfig *rest.C
136139

137140
return openshiftTestsImagePullSpec, nil
138141
}
142+
143+
func GetOpenshiftTestsImagePullSpecWithRetries(ctx context.Context, adminRESTConfig *rest.Config, suggestedPayloadImage string, oc *exutil.CLI, retries int) (string, error) {
144+
var errs []error
145+
146+
for i := 0; i < retries; i++ {
147+
result, err := GetOpenshiftTestsImagePullSpec(ctx, adminRESTConfig, suggestedPayloadImage, oc)
148+
if err == nil {
149+
return result, nil
150+
}
151+
select {
152+
case <-ctx.Done():
153+
return "", ctx.Err()
154+
case <-time.After(30 * time.Second):
155+
}
156+
errs = append(errs, err)
157+
}
158+
return "", errors.Join(errs...)
159+
}

test/extended/operators/certs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ var _ = g.Describe(fmt.Sprintf("[sig-arch][Late][Jira:%q]", "kube-apiserver"), g
117117
inClusterPKIContent, err := gatherCertsFromPlatformNamespaces(ctx, kubeClient, masters, bootstrapHostname)
118118
o.Expect(err).NotTo(o.HaveOccurred())
119119

120-
openshiftTestImagePullSpec, err := disruptionpodnetwork.GetOpenshiftTestsImagePullSpec(ctx, oc.AdminConfig(), "", oc)
120+
openshiftTestImagePullSpec, err := disruptionpodnetwork.GetOpenshiftTestsImagePullSpecWithRetries(ctx, oc.AdminConfig(), "", oc, 5)
121121
// Skip metal jobs if test image pullspec cannot be determined
122122
if jobType.Platform != "metal" || err == nil {
123123
o.Expect(err).NotTo(o.HaveOccurred())

0 commit comments

Comments
 (0)