@@ -15,7 +15,6 @@ import (
1515 "k8s.io/apiserver/pkg/storage/names"
1616 "k8s.io/kubernetes/test/e2e/framework"
1717
18- "github.com/openshift/origin/test/extended/testdata"
1918 exutil "github.com/openshift/origin/test/extended/util"
2019)
2120
@@ -547,10 +546,35 @@ var _ = g.Describe("[sig-cli] oc adm", func() {
547546 })
548547
549548 g .It ("release extract image-references" , func () {
550- expected := string (testdata .MustAsset ("test/extended/testdata/cli/test-release-image-references.json" ))
551- out , err := oc .Run ("adm" , "release" , "extract" ).Args ("--file" , "image-references" , "quay.io/openshift-release-dev/ocp-release:4.13.0-rc.0-x86_64" ).Output ()
552- o .Expect (err ).NotTo (o .HaveOccurred ())
553- o .Expect (out ).To (o .Equal (expected ))
549+ payloadImage , err := oc .AsAdmin ().Run ("get" ).Args ("clusterversion" , "version" , "-o" , "jsonpath={.status.desired.image}" ).Output ()
550+ o .Expect (err ).NotTo (o .HaveOccurred (), "Failed to get current payload image from clusterversion" )
551+ payloadImage = strings .TrimSpace (payloadImage )
552+ o .Expect (payloadImage ).NotTo (o .BeEmpty ())
553+ var out string
554+ cleanup , regArgs , prepErr := exutil .PrepareImagePullSecretAndCABundle (ocns )
555+ if cleanup != nil {
556+ defer cleanup ()
557+ }
558+ if prepErr == nil {
559+ args := append ([]string {"--file" , "image-references" }, regArgs ... )
560+ args = append (args , payloadImage )
561+ out , err = oc .AsAdmin ().Run ("adm" , "release" , "extract" ).Args (args ... ).Output ()
562+ } else {
563+ err = prepErr
564+ }
565+ if err != nil {
566+ ctx := context .Background ()
567+ isHyperShift , hsErr := exutil .IsHypershift (ctx , oc .AdminConfigClient ())
568+ o .Expect (hsErr ).NotTo (o .HaveOccurred ())
569+ errorText := fmt .Sprintf ("release extract err=%v output=%s" , err , out )
570+ if isHyperShift && cliOutputSuggestsNetworkIsolation (errorText ) {
571+ g .Skip ("Skipping on HyperShift: `oc adm release extract` failed due to likely outbound network reachability issues to the release image registry (expected in some restricted VPC environments without mirrors)" )
572+ }
573+ o .Expect (err ).NotTo (o .HaveOccurred (), "oc adm release extract failed where registry reachability appears healthy; details: %s" , errorText )
574+ }
575+ o .Expect (out ).To (o .ContainSubstring (`"kind": "ImageStream"` ))
576+ o .Expect (out ).To (o .ContainSubstring (`"apiVersion": "image.openshift.io/v1"` ))
577+ o .Expect (out ).To (o .MatchRegexp (`"name": ".*"` ), "Output should contain a valid name field" )
554578 })
555579
556580 // TODO (soltysh): sync with Standa and figure out if we can get these
@@ -636,3 +660,32 @@ func randomNode(oc *exutil.CLI) string {
636660 o .Expect (err ).NotTo (o .HaveOccurred ())
637661 return nodes .Items [rand .Intn (len (nodes .Items ))].Name
638662}
663+
664+ // cliOutputSuggestsNetworkIsolation returns true when command output contains
665+ // errors typical of blocked egress or DNS/connectivity failures.
666+ func cliOutputSuggestsNetworkIsolation (output string ) bool {
667+ lowerOutput := strings .ToLower (output )
668+ networkHints := []string {
669+ "connection refused" ,
670+ "connection reset by peer" ,
671+ "context deadline exceeded" ,
672+ "dial tcp" ,
673+ "i/o timeout" ,
674+ "no route to host" ,
675+ "network is unreachable" ,
676+ "tls handshake timeout" ,
677+ "temporary failure in name resolution" ,
678+ "failed to resolve" ,
679+ "name or service not known" ,
680+ "lookup " ,
681+ "rpc error" ,
682+ "code = unavailable" ,
683+ "unavailable: connection" ,
684+ }
685+ for _ , hint := range networkHints {
686+ if strings .Contains (lowerOutput , hint ) {
687+ return true
688+ }
689+ }
690+ return false
691+ }
0 commit comments