Skip to content

Commit 927f451

Browse files
authored
Merge pull request kubernetes#81527 from yastij/move-controller-util
move WaitForCacheSync to the sharedInformer package
2 parents ead8e0c + 7e4c309 commit 927f451

File tree

61 files changed

+72
-96
lines changed

Some content is hidden

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

61 files changed

+72
-96
lines changed

pkg/controller/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ go_library(
7474
"//staging/src/k8s.io/apimachinery/pkg/util/clock:go_default_library",
7575
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
7676
"//staging/src/k8s.io/apimachinery/pkg/util/rand:go_default_library",
77-
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
7877
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
7978
"//staging/src/k8s.io/apimachinery/pkg/util/strategicpatch:go_default_library",
8079
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",

pkg/controller/bootstrap/bootstrapsigner.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import (
3737
bootstrapapi "k8s.io/cluster-bootstrap/token/api"
3838
jws "k8s.io/cluster-bootstrap/token/jws"
3939
api "k8s.io/kubernetes/pkg/apis/core"
40-
"k8s.io/kubernetes/pkg/controller"
4140
"k8s.io/kubernetes/pkg/util/metrics"
4241
)
4342

@@ -159,7 +158,7 @@ func (e *Signer) Run(stopCh <-chan struct{}) {
159158
defer utilruntime.HandleCrash()
160159
defer e.syncQueue.ShutDown()
161160

162-
if !controller.WaitForCacheSync("bootstrap_signer", stopCh, e.configMapSynced, e.secretSynced) {
161+
if !cache.WaitForNamedCacheSync("bootstrap_signer", stopCh, e.configMapSynced, e.secretSynced) {
163162
return
164163
}
165164

pkg/controller/bootstrap/tokencleaner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (tc *TokenCleaner) Run(stopCh <-chan struct{}) {
117117
klog.Infof("Starting token cleaner controller")
118118
defer klog.Infof("Shutting down token cleaner controller")
119119

120-
if !controller.WaitForCacheSync("token_cleaner", stopCh, tc.secretSynced) {
120+
if !cache.WaitForNamedCacheSync("token_cleaner", stopCh, tc.secretSynced) {
121121
return
122122
}
123123

pkg/controller/certificates/certificate_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (cc *CertificateController) Run(workers int, stopCh <-chan struct{}) {
113113
klog.Infof("Starting certificate controller")
114114
defer klog.Infof("Shutting down certificate controller")
115115

116-
if !controller.WaitForCacheSync("certificate", stopCh, cc.csrsSynced) {
116+
if !cache.WaitForNamedCacheSync("certificate", stopCh, cc.csrsSynced) {
117117
return
118118
}
119119

pkg/controller/certificates/rootcacertpublisher/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ go_library(
66
importpath = "k8s.io/kubernetes/pkg/controller/certificates/rootcacertpublisher",
77
visibility = ["//visibility:public"],
88
deps = [
9-
"//pkg/controller:go_default_library",
109
"//pkg/util/metrics:go_default_library",
1110
"//staging/src/k8s.io/api/core/v1:go_default_library",
1211
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",

pkg/controller/certificates/rootcacertpublisher/publisher.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"reflect"
2222
"time"
2323

24-
"k8s.io/api/core/v1"
24+
v1 "k8s.io/api/core/v1"
2525
apierrs "k8s.io/apimachinery/pkg/api/errors"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -32,7 +32,6 @@ import (
3232
"k8s.io/client-go/tools/cache"
3333
"k8s.io/client-go/util/workqueue"
3434
"k8s.io/klog"
35-
"k8s.io/kubernetes/pkg/controller"
3635
"k8s.io/kubernetes/pkg/util/metrics"
3736
)
3837

@@ -98,7 +97,7 @@ func (c *Publisher) Run(workers int, stopCh <-chan struct{}) {
9897
klog.Infof("Starting root CA certificate configmap publisher")
9998
defer klog.Infof("Shutting down root CA certificate configmap publisher")
10099

101-
if !controller.WaitForCacheSync("crt configmap", stopCh, c.cmListerSynced) {
100+
if !cache.WaitForNamedCacheSync("crt configmap", stopCh, c.cmListerSynced) {
102101
return
103102
}
104103

pkg/controller/clusterroleaggregation/clusterroleaggregation_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (c *ClusterRoleAggregationController) Run(workers int, stopCh <-chan struct
148148
klog.Infof("Starting ClusterRoleAggregator")
149149
defer klog.Infof("Shutting down ClusterRoleAggregator")
150150

151-
if !controller.WaitForCacheSync("ClusterRoleAggregator", stopCh, c.clusterRolesSynced) {
151+
if !cache.WaitForNamedCacheSync("ClusterRoleAggregator", stopCh, c.clusterRolesSynced) {
152152
return
153153
}
154154

pkg/controller/controller_utils.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"k8s.io/apimachinery/pkg/types"
3636
"k8s.io/apimachinery/pkg/util/clock"
3737
"k8s.io/apimachinery/pkg/util/rand"
38-
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3938
"k8s.io/apimachinery/pkg/util/sets"
4039
"k8s.io/apimachinery/pkg/util/strategicpatch"
4140
"k8s.io/apimachinery/pkg/util/wait"
@@ -1022,21 +1021,6 @@ func PatchNodeTaints(c clientset.Interface, nodeName string, oldNode *v1.Node, n
10221021
return err
10231022
}
10241023

1025-
// WaitForCacheSync is a wrapper around cache.WaitForCacheSync that generates log messages
1026-
// indicating that the controller identified by controllerName is waiting for syncs, followed by
1027-
// either a successful or failed sync.
1028-
func WaitForCacheSync(controllerName string, stopCh <-chan struct{}, cacheSyncs ...cache.InformerSynced) bool {
1029-
klog.Infof("Waiting for caches to sync for %s controller", controllerName)
1030-
1031-
if !cache.WaitForCacheSync(stopCh, cacheSyncs...) {
1032-
utilruntime.HandleError(fmt.Errorf("unable to sync caches for %s controller", controllerName))
1033-
return false
1034-
}
1035-
1036-
klog.Infof("Caches are synced for %s controller", controllerName)
1037-
return true
1038-
}
1039-
10401024
// ComputeHash returns a hash value calculated from pod template and
10411025
// a collisionCount to avoid hash collision. The hash will be safe encoded to
10421026
// avoid bad words.

pkg/controller/daemon/daemon_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func (dsc *DaemonSetsController) Run(workers int, stopCh <-chan struct{}) {
267267
klog.Infof("Starting daemon sets controller")
268268
defer klog.Infof("Shutting down daemon sets controller")
269269

270-
if !controller.WaitForCacheSync("daemon sets", stopCh, dsc.podStoreSynced, dsc.nodeStoreSynced, dsc.historyStoreSynced, dsc.dsStoreSynced) {
270+
if !cache.WaitForNamedCacheSync("daemon sets", stopCh, dsc.podStoreSynced, dsc.nodeStoreSynced, dsc.historyStoreSynced, dsc.dsStoreSynced) {
271271
return
272272
}
273273

pkg/controller/deployment/deployment_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (dc *DeploymentController) Run(workers int, stopCh <-chan struct{}) {
152152
klog.Infof("Starting deployment controller")
153153
defer klog.Infof("Shutting down deployment controller")
154154

155-
if !controller.WaitForCacheSync("deployment", stopCh, dc.dListerSynced, dc.rsListerSynced, dc.podListerSynced) {
155+
if !cache.WaitForNamedCacheSync("deployment", stopCh, dc.dListerSynced, dc.rsListerSynced, dc.podListerSynced) {
156156
return
157157
}
158158

0 commit comments

Comments
 (0)