Merge pull request #65983 from sttts/sttts-crd-object-count

Automatic merge from submit-queue (batch tested with PRs 66822, 65983). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

apiextensions-apiserver: enable etcd_object_count metrics for CustomResources

~~This leaks one go routine per CRD that is deleted~~ The stop channel is wired already. We should not have the leak of the go routine:
d10e08fc89/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go (L1379)

```release-note
Added etcd_object_count metrics for CustomResources.
```
pull/8/head
Kubernetes Submit Queue 2018-08-03 00:08:58 -07:00 committed by GitHub
commit 5b82745caf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -664,6 +664,7 @@ type CRDRESTOptionsGetter struct {
DefaultWatchCacheSize int
EnableGarbageCollection bool
DeleteCollectionWorkers int
CountMetricPollPeriod time.Duration
}
func (t CRDRESTOptionsGetter) GetRESTOptions(resource schema.GroupResource) (generic.RESTOptions, error) {
@ -673,6 +674,7 @@ func (t CRDRESTOptionsGetter) GetRESTOptions(resource schema.GroupResource) (gen
EnableGarbageCollection: t.EnableGarbageCollection,
DeleteCollectionWorkers: t.DeleteCollectionWorkers,
ResourcePrefix: resource.Group + "/" + resource.Resource,
CountMetricPollPeriod: t.CountMetricPollPeriod,
}
if t.EnableWatchCache {
ret.Decorator = genericregistry.StorageWithCacher(t.DefaultWatchCacheSize)

View File

@ -108,6 +108,7 @@ func NewCRDRESTOptionsGetter(etcdOptions genericoptions.EtcdOptions) genericregi
DefaultWatchCacheSize: etcdOptions.DefaultWatchCacheSize,
EnableGarbageCollection: etcdOptions.EnableGarbageCollection,
DeleteCollectionWorkers: etcdOptions.DeleteCollectionWorkers,
CountMetricPollPeriod: etcdOptions.StorageConfig.CountMetricPollPeriod,
}
ret.StorageConfig.Codec = unstructured.UnstructuredJSONScheme