Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nfd-master: add error checking for CRD controller creation #988

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pkg/nfd-master/nfd-api-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type nfdController struct {
stopChan chan struct{}
}

func newNfdController(config *restclient.Config) *nfdController {
func newNfdController(config *restclient.Config) (*nfdController, error) {
c := &nfdController{
stopChan: make(chan struct{}, 1),
}
Expand All @@ -46,7 +46,7 @@ func newNfdController(config *restclient.Config) *nfdController {

informerFactory := nfdinformers.NewSharedInformerFactory(nfdClient, 5*time.Minute)
ruleInformer := informerFactory.Nfd().V1alpha1().NodeFeatureRules()
_, _ = ruleInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
if _, err := ruleInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(object interface{}) {
key, _ := cache.MetaNamespaceKeyFunc(object)
klog.V(2).Infof("NodeFeatureRule %v added", key)
Expand All @@ -59,14 +59,16 @@ func newNfdController(config *restclient.Config) *nfdController {
key, _ := cache.MetaNamespaceKeyFunc(object)
klog.V(2).Infof("NodeFeatureRule %v deleted", key)
},
})
}); err != nil {
return nil, err
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's my bad, sorry.

informerFactory.Start(c.stopChan)

utilruntime.Must(nfdv1alpha1.AddToScheme(nfdscheme.Scheme))

c.ruleLister = ruleInformer.Lister()

return c
return c, nil
}

func (c *nfdController) stop() {
Expand Down
5 changes: 4 additions & 1 deletion pkg/nfd-master/nfd-master.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ func (m *nfdMaster) Run() error {
return err
}
klog.Info("starting nfd api controller")
m.nfdController = newNfdController(kubeconfig)
m.nfdController, err = newNfdController(kubeconfig)
if err != nil {
return fmt.Errorf("failed to initialize CRD controller: %w", err)
}
}

if !m.args.NoPublish {
Expand Down