1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

Merge pull request #988 from marquiz/devel/nfd-master-errcheck

nfd-master: add error checking for CRD controller creation
This commit is contained in:
Kubernetes Prow Robot 2022-12-13 14:57:33 -08:00 committed by GitHub
commit 877c4ce560
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View file

@ -37,7 +37,7 @@ type nfdController struct {
stopChan chan struct{} stopChan chan struct{}
} }
func newNfdController(config *restclient.Config) *nfdController { func newNfdController(config *restclient.Config) (*nfdController, error) {
c := &nfdController{ c := &nfdController{
stopChan: make(chan struct{}, 1), stopChan: make(chan struct{}, 1),
} }
@ -46,7 +46,7 @@ func newNfdController(config *restclient.Config) *nfdController {
informerFactory := nfdinformers.NewSharedInformerFactory(nfdClient, 5*time.Minute) informerFactory := nfdinformers.NewSharedInformerFactory(nfdClient, 5*time.Minute)
ruleInformer := informerFactory.Nfd().V1alpha1().NodeFeatureRules() ruleInformer := informerFactory.Nfd().V1alpha1().NodeFeatureRules()
_, _ = ruleInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ if _, err := ruleInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(object interface{}) { AddFunc: func(object interface{}) {
key, _ := cache.MetaNamespaceKeyFunc(object) key, _ := cache.MetaNamespaceKeyFunc(object)
klog.V(2).Infof("NodeFeatureRule %v added", key) klog.V(2).Infof("NodeFeatureRule %v added", key)
@ -59,14 +59,16 @@ func newNfdController(config *restclient.Config) *nfdController {
key, _ := cache.MetaNamespaceKeyFunc(object) key, _ := cache.MetaNamespaceKeyFunc(object)
klog.V(2).Infof("NodeFeatureRule %v deleted", key) klog.V(2).Infof("NodeFeatureRule %v deleted", key)
}, },
}) }); err != nil {
return nil, err
}
informerFactory.Start(c.stopChan) informerFactory.Start(c.stopChan)
utilruntime.Must(nfdv1alpha1.AddToScheme(nfdscheme.Scheme)) utilruntime.Must(nfdv1alpha1.AddToScheme(nfdscheme.Scheme))
c.ruleLister = ruleInformer.Lister() c.ruleLister = ruleInformer.Lister()
return c return c, nil
} }
func (c *nfdController) stop() { func (c *nfdController) stop() {

View file

@ -155,7 +155,10 @@ func (m *nfdMaster) Run() error {
return err return err
} }
klog.Info("starting nfd api controller") 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 { if !m.args.NoPublish {