From a726082f707c5069e6a6cbf2792460ebc923d05e Mon Sep 17 00:00:00 2001 From: Vadim Rutkovsky Date: Wed, 9 Oct 2024 09:06:50 +0200 Subject: [PATCH 1/2] tls registry: extend time for cert collection pod to start --- test/extended/operators/certs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/extended/operators/certs.go b/test/extended/operators/certs.go index 95ad91ac361f..accdfedcf489 100644 --- a/test/extended/operators/certs.go +++ b/test/extended/operators/certs.go @@ -385,7 +385,7 @@ func createPods(ctx context.Context, kubeClient kubernetes.Interface, namespace return podOnNode, fmt.Errorf("error creating pod on node %s: %v", node.Name, err) } - timeLimitedCtx, cancel := context.WithTimeout(ctx, time.Minute) + timeLimitedCtx, cancel := context.WithTimeout(ctx, 5*time.Minute) defer cancel() if _, watchErr := watchtools.UntilWithSync(timeLimitedCtx, From 943d92f44ed6e3004148adfbaf328eb6dcdc4a2a Mon Sep 17 00:00:00 2001 From: Vadim Rutkovsky Date: Wed, 9 Oct 2024 09:16:07 +0200 Subject: [PATCH 2/2] tls registry: retry tests image resolution Sometimes registry is slow to reply or throws temporary error. Add a method to retry the attempt --- .../network/disruptionpodnetwork/utils.go | 23 ++++++++++++++++++- test/extended/operators/certs.go | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/pkg/monitortests/network/disruptionpodnetwork/utils.go b/pkg/monitortests/network/disruptionpodnetwork/utils.go index f3745f13e3e0..3555253e0e2d 100644 --- a/pkg/monitortests/network/disruptionpodnetwork/utils.go +++ b/pkg/monitortests/network/disruptionpodnetwork/utils.go @@ -3,12 +3,15 @@ package disruptionpodnetwork import ( "bytes" "context" + "errors" "fmt" - "github.com/sirupsen/logrus" "io/ioutil" "os" "os/exec" "strings" + "time" + + "github.com/sirupsen/logrus" configclient "github.com/openshift/client-go/config/clientset/versioned" exutil "github.com/openshift/origin/test/extended/util" @@ -136,3 +139,21 @@ func GetOpenshiftTestsImagePullSpec(ctx context.Context, adminRESTConfig *rest.C return openshiftTestsImagePullSpec, nil } + +func GetOpenshiftTestsImagePullSpecWithRetries(ctx context.Context, adminRESTConfig *rest.Config, suggestedPayloadImage string, oc *exutil.CLI, retries int) (string, error) { + var errs []error + + for i := 0; i < retries; i++ { + result, err := GetOpenshiftTestsImagePullSpec(ctx, adminRESTConfig, suggestedPayloadImage, oc) + if err == nil { + return result, nil + } + select { + case <-ctx.Done(): + return "", ctx.Err() + case <-time.After(30 * time.Second): + } + errs = append(errs, err) + } + return "", errors.Join(errs...) +} diff --git a/test/extended/operators/certs.go b/test/extended/operators/certs.go index accdfedcf489..8ffe5a4a90cd 100644 --- a/test/extended/operators/certs.go +++ b/test/extended/operators/certs.go @@ -117,7 +117,7 @@ var _ = g.Describe(fmt.Sprintf("[sig-arch][Late][Jira:%q]", "kube-apiserver"), g inClusterPKIContent, err := gatherCertsFromPlatformNamespaces(ctx, kubeClient, masters, bootstrapHostname) o.Expect(err).NotTo(o.HaveOccurred()) - openshiftTestImagePullSpec, err := disruptionpodnetwork.GetOpenshiftTestsImagePullSpec(ctx, oc.AdminConfig(), "", oc) + openshiftTestImagePullSpec, err := disruptionpodnetwork.GetOpenshiftTestsImagePullSpecWithRetries(ctx, oc.AdminConfig(), "", oc, 5) // Skip metal jobs if test image pullspec cannot be determined if jobType.Platform != "metal" || err == nil { o.Expect(err).NotTo(o.HaveOccurred())