Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick of Aggregated Discovery Patches: #115302 #115770 #115998 #115859 #115805

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -61,14 +61,10 @@ type DiscoveryAggregationController interface {
// Spwans a worker which waits for added/updated apiservices and updates
// the unified discovery document by contacting the aggregated api services
Run(stopCh <-chan struct{})

// Returns true if all non-local APIServices that have been added
// are synced at least once to the discovery document
ExternalServicesSynced() bool
}

type discoveryManager struct {
// Locks `services`
// Locks `apiServices`
servicesLock sync.RWMutex

// Map from APIService's name (or a unique string for local servers)
Expand Down Expand Up @@ -147,9 +143,6 @@ type groupVersionInfo struct {
// was stored, the discovery document will always be re-fetched.
lastMarkedDirty time.Time

// Last time sync function was run for this GV.
lastReconciled time.Time

// ServiceReference of this GroupVersion. This identifies the Service which
// describes how to contact the server responsible for this GroupVersion.
service serviceKey
Expand Down Expand Up @@ -299,9 +292,9 @@ func (dm *discoveryManager) fetchFreshDiscoveryForService(gv metav1.GroupVersion
lastUpdated: now,
}

// Save the resolve, because it is still useful in case other services
// are already marked dirty. THey can use it without making http request
dm.setCacheEntryForService(info.service, cached)
// Do not save the resolve as the legacy fallback only fetches
// one group version and an API Service may serve multiple
// group versions.
return &cached, nil

case http.StatusOK:
Expand Down Expand Up @@ -350,12 +343,8 @@ func (dm *discoveryManager) syncAPIService(apiServiceName string) error {
}

// Lookup last cached result for this apiservice's service.
now := time.Now()
cached, err := dm.fetchFreshDiscoveryForService(mgv, info)

info.lastReconciled = now
dm.setInfoForAPIService(apiServiceName, &info)

var entry apidiscoveryv2beta1.APIVersionDiscovery

// Extract the APIService's specific resource information from the
Expand Down Expand Up @@ -477,18 +466,6 @@ func (dm *discoveryManager) RemoveAPIService(apiServiceName string) {
}
}

func (dm *discoveryManager) ExternalServicesSynced() bool {
dm.servicesLock.RLock()
defer dm.servicesLock.RUnlock()
for _, info := range dm.apiServices {
if info.lastReconciled.IsZero() {
return false
}
}

return true
}

//
// Lock-protected accessors
//
Expand Down