@@ -24,8 +24,6 @@ import (
2424 "github.com/pkg/errors"
2525 "github.com/sirupsen/logrus"
2626 "golang.org/x/mod/semver"
27- kapierrs "k8s.io/apimachinery/pkg/api/errors"
28- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2927 "k8s.io/apimachinery/pkg/util/sets"
3028 "k8s.io/klog/v2"
3129 k8simage "k8s.io/kubernetes/test/utils/image"
@@ -35,7 +33,6 @@ import (
3533 "github.com/openshift/origin/pkg/clioptions/clusterdiscovery"
3634 "github.com/openshift/origin/pkg/clioptions/imagesetup"
3735 "github.com/openshift/origin/pkg/clioptions/upgradeoptions"
38- "github.com/openshift/origin/test/extended/util"
3936 exutil "github.com/openshift/origin/test/extended/util"
4037 origingenerated "github.com/openshift/origin/test/extended/util/annotate/generated"
4138 "github.com/openshift/origin/test/extended/util/image"
@@ -422,64 +419,16 @@ func ExtractAllTestBinaries(ctx context.Context, parallelism int) (func(), TestB
422419 return nil , nil , errors .WithMessage (err , "couldn't determine release image" )
423420 }
424421
425- oc := util .NewCLIWithoutNamespace ("default" )
426-
427- // To extract binaries bearing external tests, we must inspect the release
428- // payload under tests as well as extract content from component images
429- // referenced by that payload.
430- // openshift-tests is frequently run in the context of a CI job, within a pod.
431- // CI sets $RELEASE_IMAGE_LATEST to a pullspec for the release payload under test. This
432- // pull spec resolve to:
433- // 1. A build farm ci-op-* namespace / imagestream location (anonymous access permitted).
434- // 2. A quay.io/openshift-release-dev location (for tests against promoted ART payloads -- anonymous access permitted).
435- // 3. A registry.ci.openshift.org/ocp-<arch>/release:<tag> (request registry.ci.openshift.org token).
436- // Within the pod, we don't necessarily have a pull-secret for #3 OR the component images
437- // a payload references (which are private, unless in a ci-op-* imagestream).
438- // We try the following options:
439- // 1. If set, use the REGISTRY_AUTH_FILE environment variable to an auths file with
440- // pull secrets capable of reading appropriate payload & component image
441- // information.
442- // 2. If it exists, use a file /run/secrets/ci.openshift.io/cluster-profile/pull-secret
443- // (conventional location for pull-secret information for CI cluster profile).
444- // 3. Use openshift-config secret/pull-secret from the cluster-under-test, if it exists
445- // (Microshift does not).
446- // 4. Use unauthenticated access to the payload image and component images.
447- registryAuthFilePath := os .Getenv ("REGISTRY_AUTH_FILE" )
448-
449- // if the environment variable is not set, extract the target cluster's
450- // platform pull secret.
451- if len (registryAuthFilePath ) != 0 {
452- logrus .Infof ("Using REGISTRY_AUTH_FILE environment variable: %v" , registryAuthFilePath )
453- } else {
454-
455- // See if the cluster-profile has stored a pull-secret at the conventional location.
456- ciProfilePullSecretPath := "/run/secrets/ci.openshift.io/cluster-profile/pull-secret"
457- _ , err := os .Stat (ciProfilePullSecretPath )
458- if ! os .IsNotExist (err ) {
459- logrus .Infof ("Detected %v; using cluster profile for image access" , ciProfilePullSecretPath )
460- registryAuthFilePath = ciProfilePullSecretPath
461- } else {
462- // Inspect the cluster-under-test and read its cluster pull-secret dockerconfigjson value.
463- clusterPullSecret , err := oc .AdminKubeClient ().CoreV1 ().Secrets ("openshift-config" ).Get (context .Background (), "pull-secret" , metav1.GetOptions {})
464- if err != nil {
465- if kapierrs .IsNotFound (err ) {
466- logrus .Warningf ("Cluster has no openshift-config secret/pull-secret; falling back to unauthenticated image access" )
467- } else {
468- return nil , nil , fmt .Errorf ("unable to read ephemeral cluster pull secret: %w" , err )
469- }
470- } else {
471- tmpDir , err := os .MkdirTemp ("" , "external-binary" )
472- clusterDockerConfig := clusterPullSecret .Data [".dockerconfigjson" ]
473- registryAuthFilePath = filepath .Join (tmpDir , ".dockerconfigjson" )
474- err = os .WriteFile (registryAuthFilePath , clusterDockerConfig , 0600 )
475- if err != nil {
476- return nil , nil , fmt .Errorf ("unable to serialize target cluster pull-secret locally: %w" , err )
477- }
422+ tmpDir , err := os .MkdirTemp ("" , "external-binary" )
423+ if err != nil {
424+ return nil , nil , fmt .Errorf ("failed to create temporary directory: %w" , err )
425+ }
478426
479- defer os .RemoveAll (tmpDir )
480- logrus .Infof ("Using target cluster pull-secrets for registry auth" )
481- }
482- }
427+ defer os .RemoveAll (tmpDir )
428+
429+ registryAuthFilePath , err := DetermineRegistryAuthFilePath (tmpDir )
430+ if err != nil {
431+ return nil , nil , fmt .Errorf ("failed to determine registry auth file path: %w" , err )
483432 }
484433
485434 externalBinaryProvider , err := NewExternalBinaryProvider (releaseImage , registryAuthFilePath )
0 commit comments