Skip to content

Commit a9901a5

Browse files
Merge pull request #20693 from deads2k/controller-04-missingapi
make cluster quota controller tolerate inaccessible api resources
2 parents 64882c0 + f9b905d commit a9901a5

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

pkg/quota/controller/clusterquotareconciliation/reconciliation_controller.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
quotainformer "github.com/openshift/origin/pkg/quota/generated/informers/internalversion/quota/internalversion"
2828
quotatypedclient "github.com/openshift/origin/pkg/quota/generated/internalclientset/typed/quota/internalversion"
2929
quotalister "github.com/openshift/origin/pkg/quota/generated/listers/quota/internalversion"
30+
"k8s.io/client-go/discovery"
3031
)
3132

3233
type ClusterQuotaReconcilationControllerOptions struct {
@@ -107,11 +108,14 @@ func NewClusterQuotaReconcilationController(options ClusterQuotaReconcilationCon
107108

108109
c.quotaMonitor = qm
109110

110-
// do initial quota monitor setup
111+
// 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.
111112
resources, err := resourcequota.GetQuotableResources(options.DiscoveryFunc)
112-
if err != nil {
113+
if discovery.IsGroupDiscoveryFailedError(err) {
114+
utilruntime.HandleError(fmt.Errorf("initial discovery check failure, continuing and counting on future sync update: %v", err))
115+
} else if err != nil {
113116
return nil, err
114117
}
118+
115119
if err = qm.SyncMonitors(resources); err != nil {
116120
utilruntime.HandleError(fmt.Errorf("initial monitor sync has error: %v", err))
117121
}
@@ -157,7 +161,16 @@ func (c *ClusterQuotaReconcilationController) Sync(discoveryFunc resourcequota.N
157161
newResources, err := resourcequota.GetQuotableResources(discoveryFunc)
158162
if err != nil {
159163
utilruntime.HandleError(err)
160-
return
164+
165+
if discovery.IsGroupDiscoveryFailedError(err) && len(newResources) > 0 {
166+
// In partial discovery cases, don't remove any existing informers, just add new ones
167+
for k, v := range oldResources {
168+
newResources[k] = v
169+
}
170+
} else {
171+
// short circuit in non-discovery error cases or if discovery returned zero resources
172+
return
173+
}
161174
}
162175

163176
// Decide whether discovery has reported a change.

vendor/k8s.io/kubernetes/pkg/controller/resourcequota/resource_quota_controller.go

Lines changed: 16 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)