Skip to content

Commit bc159fd

Browse files
committed
UPSTREAM: 54257: Use GetByKey() in lister NonNamespacedGet
The Get() function of non-namespace lister passes a temporary object to indexer.Get() in order to fetch the actual object from the indexer. This may cause Go to allocate the temporary object on the heap instead of the stack, as it is passed into interfaces. For non-namespaced objects, Get(&Type{ObjectMeta: v1.ObjectMeta{Name: name}}) should be equivalent to GetByKey(name). This could be the root cause of excessive allocations, e.g. in tests clusterRoleLister.Get() has trigger 4 billion allocations. See openshift/origin#16954 Signed-off-by: Christian Heimes <[email protected]>
1 parent 2899646 commit bc159fd

File tree

43 files changed

+43
-128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+43
-128
lines changed

pkg/client/listers/admissionregistration/internalversion/externaladmissionhookconfiguration.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package internalversion
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
admissionregistration "k8s.io/kubernetes/pkg/apis/admissionregistration"
@@ -55,8 +54,7 @@ func (s *externalAdmissionHookConfigurationLister) List(selector labels.Selector
5554

5655
// Get retrieves the ExternalAdmissionHookConfiguration from the index for a given name.
5756
func (s *externalAdmissionHookConfigurationLister) Get(name string) (*admissionregistration.ExternalAdmissionHookConfiguration, error) {
58-
key := &admissionregistration.ExternalAdmissionHookConfiguration{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/admissionregistration/internalversion/initializerconfiguration.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package internalversion
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
admissionregistration "k8s.io/kubernetes/pkg/apis/admissionregistration"
@@ -55,8 +54,7 @@ func (s *initializerConfigurationLister) List(selector labels.Selector) (ret []*
5554

5655
// Get retrieves the InitializerConfiguration from the index for a given name.
5756
func (s *initializerConfigurationLister) Get(name string) (*admissionregistration.InitializerConfiguration, error) {
58-
key := &admissionregistration.InitializerConfiguration{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/admissionregistration/v1alpha1/externaladmissionhookconfiguration.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package v1alpha1
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
v1alpha1 "k8s.io/kubernetes/pkg/apis/admissionregistration/v1alpha1"
@@ -55,8 +54,7 @@ func (s *externalAdmissionHookConfigurationLister) List(selector labels.Selector
5554

5655
// Get retrieves the ExternalAdmissionHookConfiguration from the index for a given name.
5756
func (s *externalAdmissionHookConfigurationLister) Get(name string) (*v1alpha1.ExternalAdmissionHookConfiguration, error) {
58-
key := &v1alpha1.ExternalAdmissionHookConfiguration{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/admissionregistration/v1alpha1/initializerconfiguration.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package v1alpha1
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
v1alpha1 "k8s.io/kubernetes/pkg/apis/admissionregistration/v1alpha1"
@@ -55,8 +54,7 @@ func (s *initializerConfigurationLister) List(selector labels.Selector) (ret []*
5554

5655
// Get retrieves the InitializerConfiguration from the index for a given name.
5756
func (s *initializerConfigurationLister) Get(name string) (*v1alpha1.InitializerConfiguration, error) {
58-
key := &v1alpha1.InitializerConfiguration{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/authentication/internalversion/tokenreview.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package internalversion
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
authentication "k8s.io/kubernetes/pkg/apis/authentication"
@@ -55,8 +54,7 @@ func (s *tokenReviewLister) List(selector labels.Selector) (ret []*authenticatio
5554

5655
// Get retrieves the TokenReview from the index for a given name.
5756
func (s *tokenReviewLister) Get(name string) (*authentication.TokenReview, error) {
58-
key := &authentication.TokenReview{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/authentication/v1/tokenreview.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package v1
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
v1 "k8s.io/kubernetes/pkg/apis/authentication/v1"
@@ -55,8 +54,7 @@ func (s *tokenReviewLister) List(selector labels.Selector) (ret []*v1.TokenRevie
5554

5655
// Get retrieves the TokenReview from the index for a given name.
5756
func (s *tokenReviewLister) Get(name string) (*v1.TokenReview, error) {
58-
key := &v1.TokenReview{ObjectMeta: meta_v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/authentication/v1beta1/tokenreview.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package v1beta1
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
v1beta1 "k8s.io/kubernetes/pkg/apis/authentication/v1beta1"
@@ -55,8 +54,7 @@ func (s *tokenReviewLister) List(selector labels.Selector) (ret []*v1beta1.Token
5554

5655
// Get retrieves the TokenReview from the index for a given name.
5756
func (s *tokenReviewLister) Get(name string) (*v1beta1.TokenReview, error) {
58-
key := &v1beta1.TokenReview{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/authorization/internalversion/selfsubjectaccessreview.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package internalversion
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
authorization "k8s.io/kubernetes/pkg/apis/authorization"
@@ -55,8 +54,7 @@ func (s *selfSubjectAccessReviewLister) List(selector labels.Selector) (ret []*a
5554

5655
// Get retrieves the SelfSubjectAccessReview from the index for a given name.
5756
func (s *selfSubjectAccessReviewLister) Get(name string) (*authorization.SelfSubjectAccessReview, error) {
58-
key := &authorization.SelfSubjectAccessReview{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/authorization/internalversion/subjectaccessreview.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package internalversion
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
authorization "k8s.io/kubernetes/pkg/apis/authorization"
@@ -55,8 +54,7 @@ func (s *subjectAccessReviewLister) List(selector labels.Selector) (ret []*autho
5554

5655
// Get retrieves the SubjectAccessReview from the index for a given name.
5756
func (s *subjectAccessReviewLister) Get(name string) (*authorization.SubjectAccessReview, error) {
58-
key := &authorization.SubjectAccessReview{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/authorization/v1/selfsubjectaccessreview.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package v1
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
v1 "k8s.io/kubernetes/pkg/apis/authorization/v1"
@@ -55,8 +54,7 @@ func (s *selfSubjectAccessReviewLister) List(selector labels.Selector) (ret []*v
5554

5655
// Get retrieves the SelfSubjectAccessReview from the index for a given name.
5756
func (s *selfSubjectAccessReviewLister) Get(name string) (*v1.SelfSubjectAccessReview, error) {
58-
key := &v1.SelfSubjectAccessReview{ObjectMeta: meta_v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/authorization/v1/subjectaccessreview.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package v1
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
v1 "k8s.io/kubernetes/pkg/apis/authorization/v1"
@@ -55,8 +54,7 @@ func (s *subjectAccessReviewLister) List(selector labels.Selector) (ret []*v1.Su
5554

5655
// Get retrieves the SubjectAccessReview from the index for a given name.
5756
func (s *subjectAccessReviewLister) Get(name string) (*v1.SubjectAccessReview, error) {
58-
key := &v1.SubjectAccessReview{ObjectMeta: meta_v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/authorization/v1beta1/selfsubjectaccessreview.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package v1beta1
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
v1beta1 "k8s.io/kubernetes/pkg/apis/authorization/v1beta1"
@@ -55,8 +54,7 @@ func (s *selfSubjectAccessReviewLister) List(selector labels.Selector) (ret []*v
5554

5655
// Get retrieves the SelfSubjectAccessReview from the index for a given name.
5756
func (s *selfSubjectAccessReviewLister) Get(name string) (*v1beta1.SelfSubjectAccessReview, error) {
58-
key := &v1beta1.SelfSubjectAccessReview{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/authorization/v1beta1/subjectaccessreview.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package v1beta1
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
v1beta1 "k8s.io/kubernetes/pkg/apis/authorization/v1beta1"
@@ -55,8 +54,7 @@ func (s *subjectAccessReviewLister) List(selector labels.Selector) (ret []*v1bet
5554

5655
// Get retrieves the SubjectAccessReview from the index for a given name.
5756
func (s *subjectAccessReviewLister) Get(name string) (*v1beta1.SubjectAccessReview, error) {
58-
key := &v1beta1.SubjectAccessReview{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/certificates/internalversion/certificatesigningrequest.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package internalversion
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
certificates "k8s.io/kubernetes/pkg/apis/certificates"
@@ -55,8 +54,7 @@ func (s *certificateSigningRequestLister) List(selector labels.Selector) (ret []
5554

5655
// Get retrieves the CertificateSigningRequest from the index for a given name.
5756
func (s *certificateSigningRequestLister) Get(name string) (*certificates.CertificateSigningRequest, error) {
58-
key := &certificates.CertificateSigningRequest{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/certificates/v1beta1/certificatesigningrequest.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package v1beta1
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
v1beta1 "k8s.io/kubernetes/pkg/apis/certificates/v1beta1"
@@ -55,8 +54,7 @@ func (s *certificateSigningRequestLister) List(selector labels.Selector) (ret []
5554

5655
// Get retrieves the CertificateSigningRequest from the index for a given name.
5756
func (s *certificateSigningRequestLister) Get(name string) (*v1beta1.CertificateSigningRequest, error) {
58-
key := &v1beta1.CertificateSigningRequest{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/core/internalversion/componentstatus.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package internalversion
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
api "k8s.io/kubernetes/pkg/api"
@@ -55,8 +54,7 @@ func (s *componentStatusLister) List(selector labels.Selector) (ret []*api.Compo
5554

5655
// Get retrieves the ComponentStatus from the index for a given name.
5756
func (s *componentStatusLister) Get(name string) (*api.ComponentStatus, error) {
58-
key := &api.ComponentStatus{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/core/internalversion/namespace.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package internalversion
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
api "k8s.io/kubernetes/pkg/api"
@@ -55,8 +54,7 @@ func (s *namespaceLister) List(selector labels.Selector) (ret []*api.Namespace,
5554

5655
// Get retrieves the Namespace from the index for a given name.
5756
func (s *namespaceLister) Get(name string) (*api.Namespace, error) {
58-
key := &api.Namespace{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/core/internalversion/node.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package internalversion
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
api "k8s.io/kubernetes/pkg/api"
@@ -55,8 +54,7 @@ func (s *nodeLister) List(selector labels.Selector) (ret []*api.Node, err error)
5554

5655
// Get retrieves the Node from the index for a given name.
5756
func (s *nodeLister) Get(name string) (*api.Node, error) {
58-
key := &api.Node{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/core/internalversion/persistentvolume.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package internalversion
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
api "k8s.io/kubernetes/pkg/api"
@@ -55,8 +54,7 @@ func (s *persistentVolumeLister) List(selector labels.Selector) (ret []*api.Pers
5554

5655
// Get retrieves the PersistentVolume from the index for a given name.
5756
func (s *persistentVolumeLister) Get(name string) (*api.PersistentVolume, error) {
58-
key := &api.PersistentVolume{ObjectMeta: v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/core/v1/componentstatus.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package v1
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
v1 "k8s.io/kubernetes/pkg/api/v1"
@@ -55,8 +54,7 @@ func (s *componentStatusLister) List(selector labels.Selector) (ret []*v1.Compon
5554

5655
// Get retrieves the ComponentStatus from the index for a given name.
5756
func (s *componentStatusLister) Get(name string) (*v1.ComponentStatus, error) {
58-
key := &v1.ComponentStatus{ObjectMeta: meta_v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/core/v1/namespace.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package v1
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
v1 "k8s.io/kubernetes/pkg/api/v1"
@@ -55,8 +54,7 @@ func (s *namespaceLister) List(selector labels.Selector) (ret []*v1.Namespace, e
5554

5655
// Get retrieves the Namespace from the index for a given name.
5756
func (s *namespaceLister) Get(name string) (*v1.Namespace, error) {
58-
key := &v1.Namespace{ObjectMeta: meta_v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

pkg/client/listers/core/v1/node.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package v1
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/api/errors"
23-
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423
"k8s.io/apimachinery/pkg/labels"
2524
"k8s.io/client-go/tools/cache"
2625
v1 "k8s.io/kubernetes/pkg/api/v1"
@@ -55,8 +54,7 @@ func (s *nodeLister) List(selector labels.Selector) (ret []*v1.Node, err error)
5554

5655
// Get retrieves the Node from the index for a given name.
5756
func (s *nodeLister) Get(name string) (*v1.Node, error) {
58-
key := &v1.Node{ObjectMeta: meta_v1.ObjectMeta{Name: name}}
59-
obj, exists, err := s.indexer.Get(key)
57+
obj, exists, err := s.indexer.GetByKey(name)
6058
if err != nil {
6159
return nil, err
6260
}

0 commit comments

Comments
 (0)