Skip to content

Commit ea896a2

Browse files
authored
Merge pull request kubernetes#95224 from Git-Jiro/lint_endpoint
Fix lint errors in pkg/contoller/endpoint
2 parents 46b5eb3 + 104ad79 commit ea896a2

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

hack/.golint_failures

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ pkg/controller/daemon/config/v1alpha1
5656
pkg/controller/deployment
5757
pkg/controller/deployment/config/v1alpha1
5858
pkg/controller/disruption
59-
pkg/controller/endpoint
60-
pkg/controller/endpoint/config/v1alpha1
61-
pkg/controller/endpointslice/config/v1alpha1
62-
pkg/controller/endpointslicemirroring/config/v1alpha1
59+
pkg/controller/endpoint/config/v1alpha1 # only 'don't use underscores in Go names' due to auto generated functions
60+
pkg/controller/endpointslice/config/v1alpha1 # only 'don't use underscores in Go names' due to auto generated functions
61+
pkg/controller/endpointslicemirroring/config/v1alpha1 # only 'don't use underscores in Go names' due to auto generated functions
6362
pkg/controller/garbagecollector
6463
pkg/controller/garbagecollector/config/v1alpha1
6564
pkg/controller/job/config/v1alpha1

pkg/controller/endpoint/endpoints_controller.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ const (
7575
TolerateUnreadyEndpointsAnnotation = "service.alpha.kubernetes.io/tolerate-unready-endpoints"
7676
)
7777

78-
// NewEndpointController returns a new *EndpointController.
78+
// NewEndpointController returns a new *Controller.
7979
func NewEndpointController(podInformer coreinformers.PodInformer, serviceInformer coreinformers.ServiceInformer,
80-
endpointsInformer coreinformers.EndpointsInformer, client clientset.Interface, endpointUpdatesBatchPeriod time.Duration) *EndpointController {
80+
endpointsInformer coreinformers.EndpointsInformer, client clientset.Interface, endpointUpdatesBatchPeriod time.Duration) *Controller {
8181
broadcaster := record.NewBroadcaster()
8282
broadcaster.StartStructuredLogging(0)
8383
broadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: client.CoreV1().Events("")})
@@ -86,7 +86,7 @@ func NewEndpointController(podInformer coreinformers.PodInformer, serviceInforme
8686
if client != nil && client.CoreV1().RESTClient().GetRateLimiter() != nil {
8787
ratelimiter.RegisterMetricAndTrackRateLimiterUsage("endpoint_controller", client.CoreV1().RESTClient().GetRateLimiter())
8888
}
89-
e := &EndpointController{
89+
e := &Controller{
9090
client: client,
9191
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "endpoint"),
9292
workerLoopPeriod: time.Second,
@@ -127,8 +127,8 @@ func NewEndpointController(podInformer coreinformers.PodInformer, serviceInforme
127127
return e
128128
}
129129

130-
// EndpointController manages selector-based service endpoints.
131-
type EndpointController struct {
130+
// Controller manages selector-based service endpoints.
131+
type Controller struct {
132132
client clientset.Interface
133133
eventBroadcaster record.EventBroadcaster
134134
eventRecorder record.EventRecorder
@@ -177,7 +177,7 @@ type EndpointController struct {
177177

178178
// Run will not return until stopCh is closed. workers determines how many
179179
// endpoints will be handled in parallel.
180-
func (e *EndpointController) Run(workers int, stopCh <-chan struct{}) {
180+
func (e *Controller) Run(workers int, stopCh <-chan struct{}) {
181181
defer utilruntime.HandleCrash()
182182
defer e.queue.ShutDown()
183183

@@ -202,7 +202,7 @@ func (e *EndpointController) Run(workers int, stopCh <-chan struct{}) {
202202

203203
// When a pod is added, figure out what services it will be a member of and
204204
// enqueue them. obj must have *v1.Pod type.
205-
func (e *EndpointController) addPod(obj interface{}) {
205+
func (e *Controller) addPod(obj interface{}) {
206206
pod := obj.(*v1.Pod)
207207
services, err := e.serviceSelectorCache.GetPodServiceMemberships(e.serviceLister, pod)
208208
if err != nil {
@@ -250,7 +250,7 @@ func podToEndpointAddressForService(svc *v1.Service, pod *v1.Pod) (*v1.EndpointA
250250
// When a pod is updated, figure out what services it used to be a member of
251251
// and what services it will be a member of, and enqueue the union of these.
252252
// old and cur must be *v1.Pod types.
253-
func (e *EndpointController) updatePod(old, cur interface{}) {
253+
func (e *Controller) updatePod(old, cur interface{}) {
254254
services := endpointutil.GetServicesToUpdateOnPodChange(e.serviceLister, e.serviceSelectorCache, old, cur)
255255
for key := range services {
256256
e.queue.AddAfter(key, e.endpointUpdatesBatchPeriod)
@@ -259,15 +259,15 @@ func (e *EndpointController) updatePod(old, cur interface{}) {
259259

260260
// When a pod is deleted, enqueue the services the pod used to be a member of.
261261
// obj could be an *v1.Pod, or a DeletionFinalStateUnknown marker item.
262-
func (e *EndpointController) deletePod(obj interface{}) {
262+
func (e *Controller) deletePod(obj interface{}) {
263263
pod := endpointutil.GetPodFromDeleteAction(obj)
264264
if pod != nil {
265265
e.addPod(pod)
266266
}
267267
}
268268

269269
// onServiceUpdate updates the Service Selector in the cache and queues the Service for processing.
270-
func (e *EndpointController) onServiceUpdate(obj interface{}) {
270+
func (e *Controller) onServiceUpdate(obj interface{}) {
271271
key, err := controller.KeyFunc(obj)
272272
if err != nil {
273273
utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %+v: %v", obj, err))
@@ -279,7 +279,7 @@ func (e *EndpointController) onServiceUpdate(obj interface{}) {
279279
}
280280

281281
// onServiceDelete removes the Service Selector from the cache and queues the Service for processing.
282-
func (e *EndpointController) onServiceDelete(obj interface{}) {
282+
func (e *Controller) onServiceDelete(obj interface{}) {
283283
key, err := controller.KeyFunc(obj)
284284
if err != nil {
285285
utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %+v: %v", obj, err))
@@ -290,7 +290,7 @@ func (e *EndpointController) onServiceDelete(obj interface{}) {
290290
e.queue.Add(key)
291291
}
292292

293-
func (e *EndpointController) onEndpointsDelete(obj interface{}) {
293+
func (e *Controller) onEndpointsDelete(obj interface{}) {
294294
key, err := controller.KeyFunc(obj)
295295
if err != nil {
296296
utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %+v: %v", obj, err))
@@ -303,12 +303,12 @@ func (e *EndpointController) onEndpointsDelete(obj interface{}) {
303303
// marks them done. You may run as many of these in parallel as you wish; the
304304
// workqueue guarantees that they will not end up processing the same service
305305
// at the same time.
306-
func (e *EndpointController) worker() {
306+
func (e *Controller) worker() {
307307
for e.processNextWorkItem() {
308308
}
309309
}
310310

311-
func (e *EndpointController) processNextWorkItem() bool {
311+
func (e *Controller) processNextWorkItem() bool {
312312
eKey, quit := e.queue.Get()
313313
if quit {
314314
return false
@@ -321,7 +321,7 @@ func (e *EndpointController) processNextWorkItem() bool {
321321
return true
322322
}
323323

324-
func (e *EndpointController) handleErr(err error, key interface{}) {
324+
func (e *Controller) handleErr(err error, key interface{}) {
325325
if err == nil {
326326
e.queue.Forget(key)
327327
return
@@ -343,7 +343,7 @@ func (e *EndpointController) handleErr(err error, key interface{}) {
343343
utilruntime.HandleError(err)
344344
}
345345

346-
func (e *EndpointController) syncService(key string) error {
346+
func (e *Controller) syncService(key string) error {
347347
startTime := time.Now()
348348
defer func() {
349349
klog.V(4).Infof("Finished syncing service %q endpoints. (%v)", key, time.Since(startTime))
@@ -550,7 +550,7 @@ func (e *EndpointController) syncService(key string) error {
550550
// do this once on startup, because in steady-state these are detected (but
551551
// some stragglers could have been left behind if the endpoint controller
552552
// reboots).
553-
func (e *EndpointController) checkLeftoverEndpoints() {
553+
func (e *Controller) checkLeftoverEndpoints() {
554554
list, err := e.endpointsLister.List(labels.Everything())
555555
if err != nil {
556556
utilruntime.HandleError(fmt.Errorf("Unable to list endpoints (%v); orphaned endpoints will not be cleaned up. (They're pretty harmless, but you can restart this component if you want another attempt made.)", err))

pkg/controller/endpoint/endpoints_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import (
4242
featuregatetesting "k8s.io/component-base/featuregate/testing"
4343
endptspkg "k8s.io/kubernetes/pkg/api/v1/endpoints"
4444
api "k8s.io/kubernetes/pkg/apis/core"
45-
"k8s.io/kubernetes/pkg/controller"
45+
controllerpkg "k8s.io/kubernetes/pkg/controller"
4646
"k8s.io/kubernetes/pkg/features"
4747
utilnet "k8s.io/utils/net"
4848
utilpointer "k8s.io/utils/pointer"
@@ -203,15 +203,15 @@ func makeBlockingEndpointDeleteTestServer(t *testing.T, controller *endpointCont
203203
}
204204

205205
type endpointController struct {
206-
*EndpointController
206+
*Controller
207207
podStore cache.Store
208208
serviceStore cache.Store
209209
endpointsStore cache.Store
210210
}
211211

212212
func newController(url string, batchPeriod time.Duration) *endpointController {
213213
client := clientset.NewForConfigOrDie(&restclient.Config{Host: url, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
214-
informerFactory := informers.NewSharedInformerFactory(client, controller.NoResyncPeriodFunc())
214+
informerFactory := informers.NewSharedInformerFactory(client, controllerpkg.NoResyncPeriodFunc())
215215
endpoints := NewEndpointController(informerFactory.Core().V1().Pods(), informerFactory.Core().V1().Services(),
216216
informerFactory.Core().V1().Endpoints(), client, batchPeriod)
217217
endpoints.podsSynced = alwaysReady

0 commit comments

Comments
 (0)