Skip to content

Commit c4e010e

Browse files
committed
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.
1 parent 137f18b commit c4e010e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/nfd-master/nfd-api-controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ type nfdApiControllerOptions struct {
4949
ResyncPeriod time.Duration
5050
}
5151

52+
func init() {
53+
utilruntime.Must(nfdv1alpha1.AddToScheme(nfdscheme.Scheme))
54+
}
55+
5256
func newNfdController(config *restclient.Config, nfdApiControllerOptions nfdApiControllerOptions) (*nfdController, error) {
5357
c := &nfdController{
5458
stopChan: make(chan struct{}, 1),
@@ -118,7 +122,6 @@ func newNfdController(config *restclient.Config, nfdApiControllerOptions nfdApiC
118122
// Start informers
119123
informerFactory.Start(c.stopChan)
120124

121-
utilruntime.Must(nfdv1alpha1.AddToScheme(nfdscheme.Scheme))
122125
return c, nil
123126
}
124127

0 commit comments

Comments
 (0)