Skip to content

Commit

Permalink
nfd-master: rename -featurerules-controller flag to -crd-controller
Browse files Browse the repository at this point in the history
Deprecate the '-featurerules-controller' command line flag as the name
does not describe the functionality anymore: in practice it controls the
CRD controller handling both NodeFeature and NodeFeatureRule objects.
The patch introduces a duplicate, more generally named, flag
'-crd-controller'. A warning is printed in the log if
'-featurerules-controller' flag is encountered.
  • Loading branch information
marquiz committed Dec 14, 2022
1 parent 8a153c1 commit 9f08065
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 27 deletions.
14 changes: 12 additions & 2 deletions cmd/nfd-master/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ func main() {
os.Exit(2)
}

// Check deprecated flags
flags.Visit(func(f *flag.Flag) {
switch f.Name {
case "featurerules-controller":
klog.Warningf("-featurerules-controller is deprecated, use '-crd-controller' flag instead")
}
})

if *printVersion {
fmt.Println(ProgramName, version.Get())
os.Exit(0)
Expand Down Expand Up @@ -100,8 +108,10 @@ func initFlags(flagset *flag.FlagSet) *master.Args {
"Do not publish feature labels")
flagset.BoolVar(&args.EnableTaints, "enable-taints", false,
"Enable node tainting feature")
flagset.BoolVar(&args.FeatureRulesController, "featurerules-controller", true,
"Enable controller for NodeFeatureRule objects. Generates node labels based on the rules in these CRs.")
flagset.BoolVar(&args.CrdController, "featurerules-controller", true,
"Enable NFD CRD API controller. DEPRECATED: use -crd-controller instead")
flagset.BoolVar(&args.CrdController, "crd-controller", true,
"Enable NFD CRD API controller for processing NodeFeature and NodeFeatureRule objects.")
flagset.IntVar(&args.Port, "port", 8080,
"Port on which to listen for connections.")
flagset.BoolVar(&args.Prune, "prune", false,
Expand Down
9 changes: 6 additions & 3 deletions deployment/helm/node-feature-discovery/templates/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@ spec:
{{- if .Values.master.resourceLabels | empty | not }}
- "--resource-labels={{- join "," .Values.master.resourceLabels }}"
{{- end }}
{{- if .Values.master.featureRulesController | kindIs "invalid" | not }}
- "-featurerules-controller={{ .Values.master.featureRulesController }}"
{{- if .Values.master.crdController | kindIs "invalid" | not }}
- "-crd-controller={{ .Values.master.crdController }}"
{{- else }}
## By default, disable NodeFeatureRules controller for other than the default instances
## By default, disable crd controller for other than the default instances
- "-featurerules-controller={{ .Values.master.instance | empty }}"
{{- end }}
{{- if .Values.master.featureRulesController | kindIs "invalid" | not }}
- "-featurerules-controller={{ .Values.master.featureRulesController }}"
{{- end }}
{{- if .Values.tls.enable }}
- "--ca-file=/etc/kubernetes/node-feature-discovery/certs/ca.crt"
- "--key-file=/etc/kubernetes/node-feature-discovery/certs/tls.key"
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 @@ -17,6 +17,7 @@ master:
featureApi:
extraLabelNs: []
resourceLabels: []
crdController: null
featureRulesController: null
deploymentAnnotations: {}
replicaCount: 1
Expand Down
3 changes: 2 additions & 1 deletion docs/deployment/helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ We have introduced the following Chart parameters.
| `master.instance` | string | | Instance name. Used to separate annotation namespaces for multiple parallel deployments |
| `master.extraLabelNs` | array | [] | List of allowed extra label namespaces |
| `master.resourceLabels` | array | [] | List of labels to be registered as extended resources |
| `master.featureRulesController` | bool | null | Specifies whether the controller for processing of NodeFeatureRule objects is enabled. If not set, controller will be enabled if `master.instance` is empty. |
| `master.crdController` | bool | null | Specifies whether the NFD CRD API controller is enabled. If not set, controller will be enabled if `master.instance` is empty. |
| `master.featureRulesController` | bool | null | DEPRECATED: use `master.crdController` instead |
| `master.replicaCount` | integer | 1 | Number of desired pods. This is a pointer to distinguish between explicit zero and not specified |
| `master.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 settings |
| `master.securityContext` | dict | {} | Container [security settings](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container)|
Expand Down
14 changes: 9 additions & 5 deletions docs/reference/master-commandline-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,24 @@ Example:
nfd-master -no-publish
```

### -featurerules-controller
### -crd-controller

The `-featurerules-controller` flag controlers the processing of
NodeFeatureRule objects, effectively enabling/disabling labels from these
custom labeling rules.
The `-crd-controller` flag specifies whether the NFD CRD API controller is
enabled or not. The controller is responsible for processing NodeFeature and
NodeFeatureRule objects.

Default: *true*

Example:

```bash
nfd-master -featurerules-controller=false
nfd-master -crd-controller=false
```

### -featurerules-controller

**DEPRECATED**: use [`-crd-controller`](#-crd-controller) instead.

### -label-whitelist

The `-label-whitelist` specifies a regular expression for filtering feature
Expand Down
32 changes: 16 additions & 16 deletions pkg/nfd-master/nfd-master.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ 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
FeatureRulesController bool
EnableNodeFeatureApi bool
NoPublish bool
EnableTaints 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
CrdController bool
EnableNodeFeatureApi bool
NoPublish bool
EnableTaints bool
Port int
Prune bool
VerifyNodeName bool
ResourceLabels utils.StringSetVal
}

type NfdMaster interface {
Expand Down Expand Up @@ -154,7 +154,7 @@ func (m *nfdMaster) Run() error {
return m.prune()
}

if m.args.FeatureRulesController {
if m.args.CrdController {
kubeconfig, err := m.getKubeconfig()
if err != nil {
return err
Expand Down

0 comments on commit 9f08065

Please sign in to comment.