Skip to content

Commit

Permalink
nfd-master: add -disable-featurerules flag
Browse files Browse the repository at this point in the history
Implements a flag for disabling the processing of NodeFeatureRule CRs.
In practice, this currently completely disables the CR controller.
  • Loading branch information
marquiz committed Nov 18, 2021
1 parent 917201f commit 93223b1
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 16 deletions.
2 changes: 2 additions & 0 deletions cmd/nfd-master/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ func initFlags(flagset *flag.FlagSet) *master.Args {
"NB: the label namespace is omitted i.e. the filter is only applied to the name part after '/'.")
flagset.BoolVar(&args.NoPublish, "no-publish", false,
"Do not publish feature labels")
flagset.BoolVar(&args.DisableFeatureRules, "disable-featurerules", false,
"Disable processing of NodeFeatureRule CRs")
flagset.IntVar(&args.Port, "port", 8080,
"Port on which to listen for connections.")
flagset.BoolVar(&args.Prune, "prune", false,
Expand Down
3 changes: 3 additions & 0 deletions deployment/helm/node-feature-discovery/templates/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ spec:
{{- if .Values.master.extraLabelNs | empty | not }}
- "--extra-label-ns={{- join "," .Values.master.extraLabelNs }}"
{{- end }}
{{- if .Values.master.disableFeatureRules }}
- "-disable-featurerules"
{{- end }}
## Enable TLS authentication
## The example below assumes having the root certificate named ca.crt stored in
## a ConfigMap named nfd-ca-cert, and, the TLS authentication credentials stored
Expand Down
1 change: 1 addition & 0 deletions deployment/helm/node-feature-discovery/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ nodeFeatureRule:
master:
instance:
extraLabelNs: []
disableFeatureRules: false

replicaCount: 1

Expand Down
14 changes: 14 additions & 0 deletions docs/advanced/master-commandline-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,20 @@ Example:
nfd-master -no-publish
```

### -disable-featurerules

The `-disable-featurerules` flag disables processing of NodeFeatureRule
objects, effectively disabling/removing labels from these custom labeling
rules.

Default: *false*

Example:

```bash
nfd-master -disable-featurerules
```

### -label-whitelist

The `-label-whitelist` specifies a regular expression for filtering feature
Expand Down
1 change: 1 addition & 0 deletions docs/get-started/deployment-and-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ We have introduced the following Chart parameters.
| `master.*` | dict | | NFD master deployment configuration |
| `master.instance` | string | | Instance name. Used to separate annotation namespaces for multiple parallel deployments |
| `master.extraLabelNs` | array | [] | List of allowed extra label namespaces |
| `master.disableFeatureRules`| bool | False | Disable processing of NodeFeatureRule CRs |
| `master.replicaCount` | integer | 1 | Number of desired pods. This is a pointer to distinguish between explicit zero and not specified |
| `master.podSecurityContext` | dict | {} | SecurityContext holds pod-level security attributes and common container settings |
| `master.service.type` | string | ClusterIP | NFD master service type |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func setupTest(args *nfdmaster.Args) testContext {
// Fixed port and no-publish, for convenience
args.NoPublish = true
args.Port = 8192
args.DisableFeatureRules = true
m, err := nfdmaster.NewNfdMaster(args)
if err != nil {
fmt.Printf("Test setup failed: %v\n", err)
Expand Down
1 change: 1 addition & 0 deletions pkg/nfd-client/worker/nfd-worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type testContext struct {
func setupTest(args *master.Args) testContext {
// Fixed port and no-publish, for convenience
args.NoPublish = true
args.DisableFeatureRules = true
args.Port = 8192
args.LabelWhiteList.Regexp = *regexp.MustCompile("")
m, err := master.NewNfdMaster(args)
Expand Down
35 changes: 19 additions & 16 deletions pkg/nfd-master/nfd-master.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,19 @@ type Annotations map[string]string

// Args holds command line arguments
type Args struct {
CaFile string
CertFile string
ExtraLabelNs utils.StringSetVal
Instance string
KeyFile string
Kubeconfig string
LabelWhiteList utils.RegexpVal
NoPublish bool
Port int
Prune bool
VerifyNodeName bool
ResourceLabels utils.StringSetVal
CaFile string
CertFile string
ExtraLabelNs utils.StringSetVal
Instance string
KeyFile string
Kubeconfig string
LabelWhiteList utils.RegexpVal
DisableFeatureRules bool
NoPublish bool
Port int
Prune bool
VerifyNodeName bool
ResourceLabels utils.StringSetVal
}

type NfdMaster interface {
Expand Down Expand Up @@ -174,11 +175,13 @@ func (m *nfdMaster) Run() error {
return m.prune()
}

kubeconfig, err := m.getKubeconfig()
if err != nil {
return err
if !m.args.DisableFeatureRules {
kubeconfig, err := m.getKubeconfig()
if err != nil {
return err
}
m.nfdController = newNfdController(kubeconfig)
}
m.nfdController = newNfdController(kubeconfig)

if !m.args.NoPublish {
err := m.updateMasterNode()
Expand Down

0 comments on commit 93223b1

Please sign in to comment.