mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Merge pull request #88382 from jpbetz/parallel-mem-client-resource-discovery
Refresh discovery server resources for memCacheClient in parallel
This commit is contained in:
commit
62b0bbc1c6
@ -190,16 +190,29 @@ func (d *memCacheClient) refreshLocked() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg := &sync.WaitGroup{}
|
||||||
|
resultLock := &sync.Mutex{}
|
||||||
rl := map[string]*cacheEntry{}
|
rl := map[string]*cacheEntry{}
|
||||||
for _, g := range gl.Groups {
|
for _, g := range gl.Groups {
|
||||||
for _, v := range g.Versions {
|
for _, v := range g.Versions {
|
||||||
r, err := d.serverResourcesForGroupVersion(v.GroupVersion)
|
gv := v.GroupVersion
|
||||||
rl[v.GroupVersion] = &cacheEntry{r, err}
|
wg.Add(1)
|
||||||
if err != nil {
|
go func() {
|
||||||
utilruntime.HandleError(fmt.Errorf("couldn't get resource list for %v: %v", v.GroupVersion, err))
|
defer wg.Done()
|
||||||
}
|
defer utilruntime.HandleCrash()
|
||||||
|
|
||||||
|
r, err := d.serverResourcesForGroupVersion(gv)
|
||||||
|
if err != nil {
|
||||||
|
utilruntime.HandleError(fmt.Errorf("couldn't get resource list for %v: %v", gv, err))
|
||||||
|
}
|
||||||
|
|
||||||
|
resultLock.Lock()
|
||||||
|
defer resultLock.Unlock()
|
||||||
|
rl[gv] = &cacheEntry{r, err}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
d.groupToServerResources, d.groupList = rl, gl
|
d.groupToServerResources, d.groupList = rl, gl
|
||||||
d.cacheValid = true
|
d.cacheValid = true
|
||||||
|
@ -205,16 +205,22 @@ func TestServerGroupsFails(t *testing.T) {
|
|||||||
func TestPartialPermanentFailure(t *testing.T) {
|
func TestPartialPermanentFailure(t *testing.T) {
|
||||||
fake := &fakeDiscovery{
|
fake := &fakeDiscovery{
|
||||||
groupList: &metav1.APIGroupList{
|
groupList: &metav1.APIGroupList{
|
||||||
Groups: []metav1.APIGroup{{
|
Groups: []metav1.APIGroup{
|
||||||
Name: "astronomy",
|
{
|
||||||
Versions: []metav1.GroupVersionForDiscovery{{
|
Name: "astronomy",
|
||||||
GroupVersion: "astronomy/v8beta1",
|
Versions: []metav1.GroupVersionForDiscovery{{
|
||||||
Version: "v8beta1",
|
GroupVersion: "astronomy/v8beta1",
|
||||||
}, {
|
Version: "v8beta1",
|
||||||
GroupVersion: "astronomy2/v8beta1",
|
}},
|
||||||
Version: "v8beta1",
|
},
|
||||||
}},
|
{
|
||||||
}},
|
Name: "astronomy2",
|
||||||
|
Versions: []metav1.GroupVersionForDiscovery{{
|
||||||
|
GroupVersion: "astronomy2/v8beta1",
|
||||||
|
Version: "v8beta1",
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
resourceMap: map[string]*resourceMapEntry{
|
resourceMap: map[string]*resourceMapEntry{
|
||||||
"astronomy/v8beta1": {
|
"astronomy/v8beta1": {
|
||||||
@ -286,16 +292,22 @@ func TestPartialPermanentFailure(t *testing.T) {
|
|||||||
func TestPartialRetryableFailure(t *testing.T) {
|
func TestPartialRetryableFailure(t *testing.T) {
|
||||||
fake := &fakeDiscovery{
|
fake := &fakeDiscovery{
|
||||||
groupList: &metav1.APIGroupList{
|
groupList: &metav1.APIGroupList{
|
||||||
Groups: []metav1.APIGroup{{
|
Groups: []metav1.APIGroup{
|
||||||
Name: "astronomy",
|
{
|
||||||
Versions: []metav1.GroupVersionForDiscovery{{
|
Name: "astronomy",
|
||||||
GroupVersion: "astronomy/v8beta1",
|
Versions: []metav1.GroupVersionForDiscovery{{
|
||||||
Version: "v8beta1",
|
GroupVersion: "astronomy/v8beta1",
|
||||||
}, {
|
Version: "v8beta1",
|
||||||
GroupVersion: "astronomy2/v8beta1",
|
}},
|
||||||
Version: "v8beta1",
|
},
|
||||||
}},
|
{
|
||||||
}},
|
Name: "astronomy2",
|
||||||
|
Versions: []metav1.GroupVersionForDiscovery{{
|
||||||
|
GroupVersion: "astronomy2/v8beta1",
|
||||||
|
Version: "v8beta1",
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
resourceMap: map[string]*resourceMapEntry{
|
resourceMap: map[string]*resourceMapEntry{
|
||||||
"astronomy/v8beta1": {
|
"astronomy/v8beta1": {
|
||||||
|
Loading…
Reference in New Issue
Block a user