From 9b3171bce2b6e78e82a4c496a276e83675712480 Mon Sep 17 00:00:00 2001
From: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
Date: Mon, 16 Jan 2023 18:00:09 +0100
Subject: [PATCH] nfd-master: always start gRPC server

Don't register gRPC LabelServer when using the NodeFeature option, only
turn the gRPC server on for Health and Readiness probes.
---
 pkg/nfd-master/nfd-master.go | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/pkg/nfd-master/nfd-master.go b/pkg/nfd-master/nfd-master.go
index 4d7c3d13c..33549f9b4 100644
--- a/pkg/nfd-master/nfd-master.go
+++ b/pkg/nfd-master/nfd-master.go
@@ -174,9 +174,7 @@ func (m *nfdMaster) Run() error {
 
 	// Run gRPC server
 	grpcErr := make(chan error, 1)
-	if !m.args.EnableNodeFeatureApi {
-		go m.runGrpcServer(grpcErr)
-	}
+	go m.runGrpcServer(grpcErr)
 
 	// Run updater that handles events from the nfd CRD API.
 	if m.nfdController != nil {
@@ -228,7 +226,13 @@ func (m *nfdMaster) runGrpcServer(errChan chan<- error) {
 		serverOpts = append(serverOpts, grpc.Creds(credentials.NewTLS(tlsConfig)))
 	}
 	m.server = grpc.NewServer(serverOpts...)
-	pb.RegisterLabelerServer(m.server, m)
+
+	// If the NodeFeature API is enabled, don'tregister the labeler API
+	// server. Otherwise, register the labeler server.
+	if !m.args.EnableNodeFeatureApi {
+		pb.RegisterLabelerServer(m.server, m)
+	}
+
 	grpc_health_v1.RegisterHealthServer(m.server, health.NewServer())
 	klog.Infof("gRPC server serving on port: %d", m.args.Port)