Skip to content

Commit 25914ec

Browse files
committed
nfd-worker: drop the gRPC health port
To be replaced with plain http.
1 parent 837d0cf commit 25914ec

File tree

6 files changed

+8
-69
lines changed

6 files changed

+8
-69
lines changed

cmd/nfd-worker/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ func initFlags(flagset *flag.FlagSet) (*worker.Args, *worker.ConfigOverrideArgs)
110110
"Do not publish feature labels")
111111
flagset.IntVar(&args.MetricsPort, "metrics", 8081,
112112
"Port on which to expose metrics.")
113-
flagset.IntVar(&args.GrpcHealthPort, "grpc-health", 8082,
114-
"Port on which to expose the grpc health endpoint.")
115113
flagset.StringVar(&args.Options, "options", "",
116114
"Specify config options from command line. Config options are specified "+
117115
"in the same format as in the config file (i.e. json or yaml). These options")

deployment/base/worker-daemonset/worker-daemonset.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,9 @@ spec:
2020
image: gcr.io/k8s-staging-nfd/node-feature-discovery:master
2121
imagePullPolicy: Always
2222
livenessProbe:
23-
grpc:
24-
port: 8082
2523
initialDelaySeconds: 10
2624
periodSeconds: 10
2725
readinessProbe:
28-
grpc:
29-
port: 8082
3026
initialDelaySeconds: 5
3127
periodSeconds: 10
3228
failureThreshold: 10

deployment/helm/node-feature-discovery/templates/worker.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ spec:
4747
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
4848
imagePullPolicy: {{ .Values.image.pullPolicy }}
4949
livenessProbe:
50-
grpc:
51-
port: {{ .Values.worker.healthPort | default "8082" }}
5250
{{- with .Values.worker.livenessProbe.initialDelaySeconds }}
5351
initialDelaySeconds: {{ . }}
5452
{{- end }}
@@ -62,8 +60,6 @@ spec:
6260
timeoutSeconds: {{ . }}
6361
{{- end }}
6462
readinessProbe:
65-
grpc:
66-
port: {{ .Values.worker.healthPort | default "8082" }}
6763
{{- with .Values.worker.readinessProbe.initialDelaySeconds }}
6864
initialDelaySeconds: {{ . }}
6965
{{- end }}
@@ -105,15 +101,12 @@ spec:
105101
- "-feature-gates={{ $key }}={{ $value }}"
106102
{{- end }}
107103
- "-metrics={{ .Values.worker.metricsPort | default "8081"}}"
108-
- "-grpc-health={{ .Values.worker.healthPort | default "8082" }}"
109104
{{- with .Values.worker.extraArgs }}
110105
{{- toYaml . | nindent 8 }}
111106
{{- end }}
112107
ports:
113108
- containerPort: {{ .Values.worker.metricsPort | default "8081"}}
114109
name: metrics
115-
- containerPort: {{ .Values.worker.healthPort | default "8082" }}
116-
name: health
117110
volumeMounts:
118111
- name: host-boot
119112
mountPath: "/host-boot"

deployment/helm/node-feature-discovery/values.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ worker:
419419
### <NFD-WORKER-CONF-END-DO-NOT-REMOVE>
420420

421421
metricsPort: 8081
422-
healthPort: 8082
423422
daemonsetAnnotations: {}
424423
podSecurityContext: {}
425424
# fsGroup: 2000
@@ -433,15 +432,11 @@ worker:
433432
# runAsUser: 1000
434433

435434
livenessProbe:
436-
grpc:
437-
port: 8082
438435
initialDelaySeconds: 10
439436
# failureThreshold: 3
440437
# periodSeconds: 10
441438
# timeoutSeconds: 1
442439
readinessProbe:
443-
grpc:
444-
port: 8082
445440
initialDelaySeconds: 5
446441
failureThreshold: 10
447442
# periodSeconds: 10

docs/deployment/helm.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ API's you need to install the prometheus operator in your cluster.
234234
| `worker.enable` | bool | true | Specifies whether nfd-worker should be deployed |
235235
| `worker.hostNetwork` | bool | false | Specifies whether to enable or disable running the container in the host's network namespace |
236236
| `worker.metricsPort` | int | 8081 | Port on which to expose metrics from components to prometheus operator. **DEPRECATED**: will be replaced by `worker.port` in NFD v0.18. |
237-
| `worker.healthPort` | int | 8082 | Port on which to expose the grpc health endpoint, will be also used for the probes. **DEPRECATED**: will be replaced by `worker.port` in NFD v0.18. |
238237
| `worker.config` | dict | | NFD worker [configuration](../reference/worker-configuration-reference) |
239238
| `worker.podSecurityContext` | dict | {} | [PodSecurityContext](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod) holds pod-level security attributes and common container settins |
240239
| `worker.securityContext` | dict | {} | Container [security settings](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |

pkg/nfd-worker/nfd-worker.go

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package nfdworker
1919
import (
2020
"encoding/json"
2121
"fmt"
22-
"net"
2322
"os"
2423
"path/filepath"
2524
"regexp"
@@ -29,9 +28,6 @@ import (
2928

3029
"golang.org/x/exp/maps"
3130
"golang.org/x/net/context"
32-
"google.golang.org/grpc"
33-
"google.golang.org/grpc/health"
34-
"google.golang.org/grpc/health/grpc_health_v1"
3531
"k8s.io/apimachinery/pkg/api/errors"
3632
"k8s.io/apimachinery/pkg/types"
3733
"k8s.io/apimachinery/pkg/util/validation"
@@ -93,14 +89,13 @@ type Labels map[string]string
9389

9490
// Args are the command line arguments of NfdWorker.
9591
type Args struct {
96-
ConfigFile string
97-
Klog map[string]*utils.KlogFlagVal
98-
Kubeconfig string
99-
Oneshot bool
100-
Options string
101-
MetricsPort int
102-
GrpcHealthPort int
103-
NoOwnerRefs bool
92+
ConfigFile string
93+
Klog map[string]*utils.KlogFlagVal
94+
Kubeconfig string
95+
Oneshot bool
96+
Options string
97+
MetricsPort int
98+
NoOwnerRefs bool
10499

105100
Overrides ConfigOverrideArgs
106101
}
@@ -118,7 +113,6 @@ type nfdWorker struct {
118113
configFilePath string
119114
config *NFDConfig
120115
kubernetesNamespace string
121-
healthServer *grpc.Server
122116
k8sClient k8sclient.Interface
123117
nfdClient nfdclient.Interface
124118
stop chan struct{} // channel for signaling stop
@@ -217,29 +211,6 @@ func (i *infiniteTicker) Reset(d time.Duration) {
217211
}
218212
}
219213

220-
func (w *nfdWorker) startGrpcHealthServer(errChan chan<- error) error {
221-
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", w.args.GrpcHealthPort))
222-
if err != nil {
223-
return fmt.Errorf("failed to listen: %w", err)
224-
}
225-
226-
s := grpc.NewServer()
227-
grpc_health_v1.RegisterHealthServer(s, health.NewServer())
228-
klog.InfoS("gRPC health server serving", "port", w.args.GrpcHealthPort)
229-
230-
go func() {
231-
defer func() {
232-
lis.Close()
233-
}()
234-
if err := s.Serve(lis); err != nil {
235-
errChan <- fmt.Errorf("gRPC health server exited with an error: %w", err)
236-
}
237-
klog.InfoS("gRPC health server stopped")
238-
}()
239-
w.healthServer = s
240-
return nil
241-
}
242-
243214
// Run feature discovery.
244215
func (w *nfdWorker) runFeatureDiscovery() error {
245216
discoveryStart := time.Now()
@@ -344,20 +315,10 @@ func (w *nfdWorker) Run() error {
344315
return nil
345316
}
346317

347-
grpcErr := make(chan error)
348-
349-
// Start gRPC server for liveness probe (at this point we're "live")
350-
if w.args.GrpcHealthPort != 0 {
351-
if err := w.startGrpcHealthServer(grpcErr); err != nil {
352-
return fmt.Errorf("failed to start gRPC health server: %w", err)
353-
}
354-
}
318+
// Start readiness probe (at this point we're "ready and live")
355319

356320
for {
357321
select {
358-
case err := <-grpcErr:
359-
return fmt.Errorf("error in serving gRPC: %w", err)
360-
361322
case <-labelTrigger.C:
362323
err = w.runFeatureDiscovery()
363324
if err != nil {
@@ -366,9 +327,6 @@ func (w *nfdWorker) Run() error {
366327

367328
case <-w.stop:
368329
klog.InfoS("shutting down nfd-worker")
369-
if w.healthServer != nil {
370-
w.healthServer.GracefulStop()
371-
}
372330
return nil
373331
}
374332
}

0 commit comments

Comments
 (0)