@@ -15,6 +15,7 @@ import (
1515 exutil "github.com/openshift/origin/test/extended/util"
1616 authnv1 "k8s.io/api/authentication/v1"
1717 corev1 "k8s.io/api/core/v1"
18+ "k8s.io/apimachinery/pkg/api/equality"
1819 apierrors "k8s.io/apimachinery/pkg/api/errors"
1920 "k8s.io/apimachinery/pkg/util/errors"
2021
@@ -150,7 +151,8 @@ var _ = g.Describe("[sig-auth][Suite:openshift/auth/external-oidc][Serial][Slow]
150151 gomega .Expect (err ).NotTo (o .HaveOccurred (), "should not encounter an error authenticating as keycloak user" )
151152
152153 copiedOC := * oc
153- tokenOC := copiedOC .WithToken (keycloakCli .AccessToken ())
154+ token := keycloakCli .AccessToken ()
155+ tokenOC := copiedOC .WithToken (token )
154156 ssr , err := tokenOC .KubeClient ().AuthenticationV1 ().SelfSubjectReviews ().Create (ctx , & authnv1.SelfSubjectReview {
155157 ObjectMeta : metav1.ObjectMeta {
156158 Name : fmt .Sprintf ("%s-info" , username ),
@@ -183,10 +185,12 @@ var _ = g.Describe("[sig-auth][Suite:openshift/auth/external-oidc][Serial][Slow]
183185 gomega .Expect (err ).NotTo (o .HaveOccurred (), "should be able to create a SelfSubjectReview" )
184186 }).WithTimeout (5 * time .Minute ).WithPolling (10 * time .Second ).Should (o .Succeed ())
185187
186- err := resetAuthentication (ctx , oc , originalAuth )
188+ err , modified := resetAuthentication (ctx , oc , originalAuth )
187189 o .Expect (err ).NotTo (o .HaveOccurred (), "should not encounter an error reverting authentication to original state" )
188190
189- waitForRollout (ctx , oc )
191+ if modified {
192+ waitForRollout (ctx , oc )
193+ }
190194 })
191195
192196 g .It ("should rollout configuration on the kube-apiserver successfully" , func () {
@@ -360,13 +364,16 @@ var _ = g.Describe("[sig-auth][Suite:openshift/auth/external-oidc][Serial][Slow]
360364 })
361365
362366 g .AfterAll (func () {
363- err := removeResources (ctx , cleanups ... )
364- o .Expect (err ).NotTo (o .HaveOccurred (), "should not encounter an error cleaning up keycloak resources" )
365-
366- err = resetAuthentication (ctx , oc , originalAuth )
367+ err , modified := resetAuthentication (ctx , oc , originalAuth )
367368 o .Expect (err ).NotTo (o .HaveOccurred (), "should not encounter an error reverting authentication to original state" )
368369
369- waitForRollout (ctx , oc )
370+ // Only if we modified the Authentication resource during the reset should we wait for a rollout
371+ if modified {
372+ waitForRollout (ctx , oc )
373+ }
374+
375+ err = removeResources (ctx , cleanups ... )
376+ o .Expect (err ).NotTo (o .HaveOccurred (), "should not encounter an error cleaning up keycloak resources" )
370377 })
371378})
372379
@@ -477,11 +484,12 @@ func admittedURLForRoute(ctx context.Context, client *exutil.CLI, routeName, nam
477484 return fmt .Sprintf ("https://%s" , admittedURL ), err
478485}
479486
480- func resetAuthentication (ctx context.Context , client * exutil.CLI , original * configv1.Authentication ) error {
487+ func resetAuthentication (ctx context.Context , client * exutil.CLI , original * configv1.Authentication ) ( error , bool ) {
481488 if original == nil {
482- return nil
489+ return nil , false
483490 }
484491
492+ modified := false
485493 timeoutCtx , cancel := context .WithDeadline (ctx , time .Now ().Add (5 * time .Minute ))
486494 defer cancel ()
487495 cli := client .AdminConfigClient ().ConfigV1 ().Authentications ()
@@ -491,17 +499,24 @@ func resetAuthentication(ctx context.Context, client *exutil.CLI, original *conf
491499 return false , fmt .Errorf ("getting the current authentications.config.openshift.io/cluster: %w" , err )
492500 }
493501
502+ if equality .Semantic .DeepEqual (current .Spec , original .Spec ) {
503+ return true , nil
504+ }
505+
494506 current .Spec = original .Spec
507+ modified = true
495508
496509 _ , err = cli .Update (ctx , current , metav1.UpdateOptions {})
497510 if err != nil {
498- return false , err
511+ // Only log the error so we continue to retry until the context has timed out
512+ fmt .Println ("updating authentication resource:" , err )
513+ return false , nil
499514 }
500515
501516 return true , nil
502517 })
503518
504- return err
519+ return err , modified
505520}
506521
507522func waitForRollout (ctx context.Context , client * exutil.CLI ) {
@@ -523,8 +538,8 @@ func waitForRollout(ctx context.Context, client *exutil.CLI) {
523538 }
524539
525540 gomega .Expect (found ).To (o .BeTrue (), "should have found the NodeInstallerProgressing condition" )
526- gomega .Expect (nipCond .Status ).To (o .Equal (operatorv1 .ConditionTrue ), "NodeInstallerProgressing condition should be True" )
527- }).WithTimeout (5 * time .Minute ).WithPolling (10 * time .Second ).Should (o .Succeed (), "should eventually begin rolling out a new revision" )
541+ gomega .Expect (nipCond .Status ).To (o .Equal (operatorv1 .ConditionTrue ), "NodeInstallerProgressing condition should be True" , nipCond )
542+ }).WithTimeout (10 * time .Minute ).WithPolling (20 * time .Second ).Should (o .Succeed (), "should eventually begin rolling out a new revision" )
528543
529544 // Then wait for it to flip back
530545 o .Eventually (func (gomega o.Gomega ) {
@@ -542,6 +557,6 @@ func waitForRollout(ctx context.Context, client *exutil.CLI) {
542557 }
543558
544559 gomega .Expect (found ).To (o .BeTrue (), "should have found the NodeInstallerProgressing condition" )
545- gomega .Expect (nipCond .Status ).To (o .Equal (operatorv1 .ConditionFalse ), "NodeInstallerProgressing condition should be True" )
560+ gomega .Expect (nipCond .Status ).To (o .Equal (operatorv1 .ConditionFalse ), "NodeInstallerProgressing condition should be False" , nipCond )
546561 }).WithTimeout (30 * time .Minute ).WithPolling (30 * time .Second ).Should (o .Succeed (), "should eventually rollout out a new revision successfully" )
547562}
0 commit comments