1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-28 02:37:11 +00:00

nfd-master: do nfd API scheme registration in an init function

Prevents (rare) races on nfd-master reconfigurartion. Previously the
scheme was registered at nfd API controller creation/startup time. This
caused a race with some lister/informer goroutines of the previous
(stoppped) controller still running and accessing (reading) the sceme
while we were updating (writing) it.
This commit is contained in:
Markus Lehtonen 2024-03-27 15:26:16 +02:00
parent 137f18b5b3
commit c4e010eafd

View file

@ -49,6 +49,10 @@ type nfdApiControllerOptions struct {
ResyncPeriod time.Duration
}
func init() {
utilruntime.Must(nfdv1alpha1.AddToScheme(nfdscheme.Scheme))
}
func newNfdController(config *restclient.Config, nfdApiControllerOptions nfdApiControllerOptions) (*nfdController, error) {
c := &nfdController{
stopChan: make(chan struct{}, 1),
@ -118,7 +122,6 @@ func newNfdController(config *restclient.Config, nfdApiControllerOptions nfdApiC
// Start informers
informerFactory.Start(c.stopChan)
utilruntime.Must(nfdv1alpha1.AddToScheme(nfdscheme.Scheme))
return c, nil
}