@@ -28,7 +28,6 @@ import (
28
28
"k8s.io/apimachinery/pkg/util/sets"
29
29
"k8s.io/client-go/informers"
30
30
"k8s.io/client-go/kubernetes"
31
- restclient "k8s.io/client-go/rest"
32
31
"k8s.io/client-go/tools/cache"
33
32
"k8s.io/klog/v2"
34
33
@@ -50,10 +49,10 @@ type NfdGarbageCollector interface {
50
49
}
51
50
52
51
type nfdGarbageCollector struct {
52
+ args * Args
53
53
stopChan chan struct {}
54
54
nfdClient nfdclientset.Interface
55
55
topoClient topologyclientset.Interface
56
- gcPeriod time.Duration
57
56
factory informers.SharedInformerFactory
58
57
}
59
58
@@ -63,27 +62,14 @@ func New(args *Args) (NfdGarbageCollector, error) {
63
62
return nil , err
64
63
}
65
64
66
- stop := make (chan struct {})
67
-
68
- return newNfdGarbageCollector (kubeconfig , stop , args .GCPeriod )
69
- }
70
-
71
- func newNfdGarbageCollector (config * restclient.Config , stop chan struct {}, gcPeriod time.Duration ) (* nfdGarbageCollector , error ) {
72
- helper := apihelper.K8sHelpers {Kubeconfig : config }
73
- cli , err := helper .GetTopologyClient ()
74
- if err != nil {
75
- return nil , err
76
- }
77
-
78
- clientset := kubernetes .NewForConfigOrDie (config )
79
- factory := informers .NewSharedInformerFactory (clientset , 5 * time .Minute )
65
+ clientset := kubernetes .NewForConfigOrDie (kubeconfig )
80
66
81
67
return & nfdGarbageCollector {
82
- topoClient : cli ,
83
- nfdClient : nfdclientset . NewForConfigOrDie ( config ),
84
- stopChan : stop ,
85
- gcPeriod : gcPeriod ,
86
- factory : factory ,
68
+ args : args ,
69
+ stopChan : make ( chan struct {} ),
70
+ topoClient : topologyclientset . NewForConfigOrDie ( kubeconfig ) ,
71
+ nfdClient : nfdclientset . NewForConfigOrDie ( kubeconfig ) ,
72
+ factory : informers . NewSharedInformerFactory ( clientset , 5 * time . Minute ) ,
87
73
}, nil
88
74
}
89
75
@@ -226,7 +212,7 @@ func (n *nfdGarbageCollector) Run() error {
226
212
return err
227
213
}
228
214
// run periodic GC
229
- n .periodicGC (n .gcPeriod )
215
+ n .periodicGC (n .args . GCPeriod )
230
216
231
217
return nil
232
218
}
0 commit comments