@@ -48,8 +48,43 @@ import (
4848const pvPrefix = "pv-"
4949const nfsPrefix = "nfs-"
5050
51+ // WaitForInternalRegistryHostname waits for the internal registry hostname to be made available to the cluster.
52+ func WaitForInternalRegistryHostname (oc * CLI ) (string , error ) {
53+ e2e .Logf ("Waiting up to 2 minutes for the internal registry hostname to be published" )
54+ var registryHostname string
55+ err := wait .Poll (2 * time .Second , 2 * time .Minute , func () (bool , error ) {
56+ imageConfig , err := oc .AsAdmin ().AdminConfigClient ().ConfigV1 ().Images ().Get ("cluster" , metav1.GetOptions {})
57+ if err != nil {
58+ if errors .IsNotFound (err ) {
59+ return false , nil
60+ }
61+ return false , err
62+ }
63+ if imageConfig == nil {
64+ return false , nil
65+ }
66+ registryHostname = imageConfig .Status .InternalRegistryHostname
67+ if len (registryHostname ) == 0 {
68+ return false , nil
69+ }
70+ return true , nil
71+ })
72+ if err == wait .ErrWaitTimeout {
73+ return "" , fmt .Errorf ("Timed out waiting for internal registry hostname to be published" )
74+ }
75+ if err != nil {
76+ return "" , err
77+ }
78+ return registryHostname , nil
79+ }
80+
5181// WaitForOpenShiftNamespaceImageStreams waits for the standard set of imagestreams to be imported
5282func WaitForOpenShiftNamespaceImageStreams (oc * CLI ) error {
83+ // First wait for the internal registry hostname to be published
84+ registryHostname , err := WaitForInternalRegistryHostname (oc )
85+ if err != nil {
86+ return err
87+ }
5388 langs := []string {"ruby" , "nodejs" , "perl" , "php" , "python" , "mysql" , "postgresql" , "mongodb" , "jenkins" }
5489 scan := func () bool {
5590 for _ , lang := range langs {
@@ -59,6 +94,10 @@ func WaitForOpenShiftNamespaceImageStreams(oc *CLI) error {
5994 e2e .Logf ("ImageStream Error: %#v \n " , err )
6095 return false
6196 }
97+ if ! strings .HasPrefix (is .Status .DockerImageRepository , registryHostname ) {
98+ e2e .Logf ("ImageStream repository %s does not match expected host %s \n " , is .Status .DockerImageRepository , registryHostname )
99+ return false
100+ }
62101 for tag := range is .Spec .Tags {
63102 e2e .Logf ("Checking tag %v \n " , tag )
64103 if _ , ok := is .Status .Tags [tag ]; ! ok {
@@ -70,7 +109,6 @@ func WaitForOpenShiftNamespaceImageStreams(oc *CLI) error {
70109 return true
71110 }
72111
73- success := false
74112 // with the move to ocp/rhel as the default for the samples in 4.0, there are alot more imagestreams;
75113 // if by some chance this path runs very soon after the cluster has come up, the original time out would
76114 // not be sufficient;
@@ -79,15 +117,12 @@ func WaitForOpenShiftNamespaceImageStreams(oc *CLI) error {
79117 // have proven less reliable that docker.io)
80118 // we've also determined that e2e-aws-image-ecosystem can be started before all the operators have completed; while
81119 // that is getting sorted out, the longer time will help there as well
82- for i := 0 ; i < 15 ; i ++ {
83- e2e .Logf ("Running scan #%v \n " , i )
120+ e2e .Logf ("Scanning openshift ImageStreams \n " )
121+ success := false
122+ wait .Poll (10 * time .Second , 150 * time .Second , func () (bool , error ) {
84123 success = scan ()
85- if success {
86- break
87- }
88- e2e .Logf ("Sleeping for 10 seconds \n " )
89- time .Sleep (10 * time .Second )
90- }
124+ return success , nil
125+ })
91126 if success {
92127 e2e .Logf ("Success! \n " )
93128 return nil
0 commit comments