Merge pull request #117992 from liggitt/gc-discovery-flutter

Fix duplicate GC event handlers getting added if discovery flutters

Kubernetes-commit: 7407f36b4b8937f982def35dd99b5647fc5245c5
This commit is contained in:
Kubernetes Publisher 2023-08-15 15:16:50 -07:00
commit 41d4a164f9

View File

@ -19,6 +19,7 @@ package discovery
import (
"context"
"encoding/json"
goerrors "errors"
"fmt"
"mime"
"net/http"
@ -422,6 +423,16 @@ func IsGroupDiscoveryFailedError(err error) bool {
return err != nil && ok
}
// GroupDiscoveryFailedErrorGroups returns true if the error is an ErrGroupDiscoveryFailed error,
// along with the map of group versions that failed discovery.
func GroupDiscoveryFailedErrorGroups(err error) (map[schema.GroupVersion]error, bool) {
var groupDiscoveryError *ErrGroupDiscoveryFailed
if err != nil && goerrors.As(err, &groupDiscoveryError) {
return groupDiscoveryError.Groups, true
}
return nil, false
}
func ServerGroupsAndResources(d DiscoveryInterface) ([]*metav1.APIGroup, []*metav1.APIResourceList, error) {
var sgs *metav1.APIGroupList
var resources []*metav1.APIResourceList