@@ -690,15 +690,15 @@ const serveReadinessStableDuration = 500 * time.Millisecond
690690// aggregated server, so it observes the transient 503 startup window and absorbs
691691// it before the test suite proceeds.
692692func waitUntilGroupVersionsServe (ctx context.Context , c client.Client , scheme * runtime.Scheme , gvs ... schema.GroupVersion ) error {
693- var lists []client. ObjectList
693+ var listGVKs []schema. GroupVersionKind
694694 for _ , gv := range gvs {
695- list , ok := newListForGroupVersion (scheme , gv )
695+ listGVK , ok := firstListGVKForGroupVersion (scheme , gv )
696696 if ! ok {
697697 continue
698698 }
699- lists = append (lists , list )
699+ listGVKs = append (listGVKs , listGVK )
700700 }
701- if len (lists ) == 0 {
701+ if len (listGVKs ) == 0 {
702702 return nil
703703 }
704704
@@ -710,8 +710,18 @@ func waitUntilGroupVersionsServe(ctx context.Context, c client.Client, scheme *r
710710 successes := 0
711711 var lastErr error
712712 if err := wait .PollUntilContextCancel (ctx , serveReadinessPollInterval , true , func (ctx context.Context ) (bool , error ) {
713- for _ , list := range lists {
714- if err := c .List (ctx , list ); err != nil {
713+ for _ , listGVK := range listGVKs {
714+ // Instantiate a fresh list per probe via the scheme so no state
715+ // (ResourceVersion, Continue, Items) leaks across probes.
716+ list , err := scheme .New (listGVK )
717+ if err != nil {
718+ return false , fmt .Errorf ("unexpected error constructing list for %s: %w" , listGVK , err )
719+ }
720+ objectList , ok := list .(client.ObjectList )
721+ if ! ok {
722+ return false , fmt .Errorf ("unexpected type %T for %s: not a client.ObjectList" , list , listGVK )
723+ }
724+ if err := c .List (ctx , objectList ); err != nil {
715725 if ! isTransientServeError (err ) {
716726 return false , fmt .Errorf ("unexpected error probing aggregated api server: %w" , err )
717727 }
@@ -731,10 +741,11 @@ func waitUntilGroupVersionsServe(ctx context.Context, c client.Client, scheme *r
731741 return nil
732742}
733743
734- // newListForGroupVersion returns a fresh list object for the first list kind
735- // registered for the given group version (e.g. *VolumeList), constructed via the
736- // scheme so the scheme stays the single source of truth for type instantiation.
737- func newListForGroupVersion (scheme * runtime.Scheme , gv schema.GroupVersion ) (client.ObjectList , bool ) {
744+ // firstListGVKForGroupVersion returns the GroupVersionKind of the first list kind
745+ // registered for the given group version (e.g. VolumeList). Kind resolution is
746+ // deterministic (sorted) and the scheme is the single source of truth for type
747+ // discovery. Callers construct fresh list objects from the GVK via scheme.New.
748+ func firstListGVKForGroupVersion (scheme * runtime.Scheme , gv schema.GroupVersion ) (schema.GroupVersionKind , bool ) {
738749 kinds := make ([]string , 0 , len (scheme .KnownTypes (gv )))
739750 for kind := range scheme .KnownTypes (gv ) {
740751 kinds = append (kinds , kind )
@@ -745,11 +756,11 @@ func newListForGroupVersion(scheme *runtime.Scheme, gv schema.GroupVersion) (cli
745756 if err != nil {
746757 continue
747758 }
748- if list , ok := obj .(client.ObjectList ); ok {
749- return list , true
759+ if _ , ok := obj .(client.ObjectList ); ok {
760+ return gv . WithKind ( kind ) , true
750761 }
751762 }
752- return nil , false
763+ return schema. GroupVersionKind {} , false
753764}
754765
755766// isTransientServeError reports whether an error returned while probing the
0 commit comments