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

make cluster quota controller tolerate inaccessible api resources #20693

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
quotainformer "github.com/openshift/origin/pkg/quota/generated/informers/internalversion/quota/internalversion"
quotatypedclient "github.com/openshift/origin/pkg/quota/generated/internalclientset/typed/quota/internalversion"
quotalister "github.com/openshift/origin/pkg/quota/generated/listers/quota/internalversion"
"k8s.io/client-go/discovery"
)

type ClusterQuotaReconcilationControllerOptions struct {
Expand Down Expand Up @@ -107,11 +108,14 @@ func NewClusterQuotaReconcilationController(options ClusterQuotaReconcilationCon

c.quotaMonitor = qm

// do initial quota monitor setup
// do initial quota monitor setup. If we have a discovery failure here, it's ok. We'll discover more resources when a later sync happens.
resources, err := resourcequota.GetQuotableResources(options.DiscoveryFunc)
if err != nil {
if discovery.IsGroupDiscoveryFailedError(err) {
utilruntime.HandleError(fmt.Errorf("initial discovery check failure, continuing and counting on future sync update: %v", err))
} else if err != nil {
return nil, err
}

if err = qm.SyncMonitors(resources); err != nil {
utilruntime.HandleError(fmt.Errorf("initial monitor sync has error: %v", err))
}
Expand Down Expand Up @@ -157,7 +161,16 @@ func (c *ClusterQuotaReconcilationController) Sync(discoveryFunc resourcequota.N
newResources, err := resourcequota.GetQuotableResources(discoveryFunc)
if err != nil {
utilruntime.HandleError(err)
return

if discovery.IsGroupDiscoveryFailedError(err) && len(newResources) > 0 {
// In partial discovery cases, don't remove any existing informers, just add new ones
for k, v := range oldResources {
newResources[k] = v
}
} else {
// short circuit in non-discovery error cases or if discovery returned zero resources
return
}
}

// Decide whether discovery has reported a change.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.