99 "context"
1010 "fmt"
1111
12+ "go.uber.org/zap"
1213 corev1 "k8s.io/api/core/v1"
1314 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1415 "k8s.io/apimachinery/pkg/fields"
@@ -17,6 +18,7 @@ import (
1718 "k8s.io/client-go/tools/cache"
1819
1920 "github.com/siderolabs/talos/pkg/kubernetes"
21+ "github.com/siderolabs/talos/pkg/machinery/constants"
2022)
2123
2224// NodeWatcher defines a NodeWatcher-based node watcher.
@@ -46,10 +48,12 @@ func (r *NodeWatcher) Get() (*corev1.Node, error) {
4648}
4749
4850// Watch starts watching Node state and notifies on updates via notify channel.
49- func (r * NodeWatcher ) Watch (ctx context.Context ) (<- chan struct {}, <- chan error , func (), error ) {
51+ func (r * NodeWatcher ) Watch (ctx context.Context , logger * zap.Logger ) (<- chan struct {}, <- chan error , func (), error ) {
52+ logger .Debug ("starting node watcher" , zap .String ("nodename" , r .nodename ))
53+
5054 informerFactory := informers .NewSharedInformerFactoryWithOptions (
5155 r .client .Clientset ,
52- 0 ,
56+ constants . KubernetesInformerDefaultResyncPeriod ,
5357 informers .WithTweakListOptions (
5458 func (opts * metav1.ListOptions ) {
5559 opts .FieldSelector = fields .OneTermEqualSelector (metav1 .ObjectNameField , r .nodename ).String ()
@@ -88,7 +92,11 @@ func (r *NodeWatcher) Watch(ctx context.Context) (<-chan struct{}, <-chan error,
8892
8993 informerFactory .Start (ctx .Done ())
9094
95+ logger .Debug ("waiting for node cache sync" )
96+
9197 informerFactory .WaitForCacheSync (ctx .Done ())
9298
99+ logger .Debug ("node cache sync done" )
100+
93101 return notifyCh , watchErrCh , informerFactory .Shutdown , nil
94102}
0 commit comments