Skip to content

Commit

Permalink
Merge pull request #1941 from ArangoGutierrez/I/856
Browse files Browse the repository at this point in the history
Drop support for hooks
  • Loading branch information
k8s-ci-robot authored Nov 4, 2024
2 parents 65b5e0c + 62f4edd commit 566a945
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 234 deletions.
6 changes: 0 additions & 6 deletions deployment/components/common/worker-mounts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
- name: host-lib
hostPath:
path: "/lib"
- name: source-d
hostPath:
path: "/etc/kubernetes/node-feature-discovery/source.d/"
- name: features-d
hostPath:
path: "/etc/kubernetes/node-feature-discovery/features.d/"
Expand Down Expand Up @@ -50,9 +47,6 @@
- name: host-lib
mountPath: "/host-lib"
readOnly: true
- name: source-d
mountPath: "/etc/kubernetes/node-feature-discovery/source.d/"
readOnly: true
- name: features-d
mountPath: "/etc/kubernetes/node-feature-discovery/features.d/"
readOnly: true
Expand Down
2 changes: 0 additions & 2 deletions deployment/components/worker-config/nfd-worker.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@
# - "class"
# - "vendor"
# - "device"
# local:
# hooksEnabled: false
# custom:
# # The following feature demonstrates the capabilities of the matchFeatures
# - name: "my custom rule"
Expand Down
6 changes: 0 additions & 6 deletions deployment/helm/node-feature-discovery/templates/worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ spec:
mountPath: "/host-usr/src"
readOnly: true
{{- end }}
- name: source-d
mountPath: "/etc/kubernetes/node-feature-discovery/source.d/"
readOnly: true
- name: features-d
mountPath: "/etc/kubernetes/node-feature-discovery/features.d/"
readOnly: true
Expand Down Expand Up @@ -174,9 +171,6 @@ spec:
hostPath:
path: "/usr/src"
{{- end }}
- name: source-d
hostPath:
path: "/etc/kubernetes/node-feature-discovery/source.d/"
- name: features-d
hostPath:
path: "/etc/kubernetes/node-feature-discovery/features.d/"
Expand Down
2 changes: 0 additions & 2 deletions deployment/helm/node-feature-discovery/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@ worker:
# - "class"
# - "vendor"
# - "device"
# local:
# hooksEnabled: false
# custom:
# # The following feature demonstrates the capabilities of the matchFeatures
# - name: "my custom rule"
Expand Down
4 changes: 2 additions & 2 deletions docs/deployment/image-variants.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ For backwards compatibility a container image tag with suffix `-minimal`
## Full

This image is based on [debian:bookworm-slim](https://hub.docker.com/_/debian)
and contains a full Linux system for running shell-based nfd-worker hooks and
doing live debugging and diagnosis of the NFD images.
and contains a full Linux system for doing live debugging and diagnosis
of the NFD images.

The container image tag has suffix `-full`
(e.g. `{{ site.container_image }}-full`).
2 changes: 1 addition & 1 deletion docs/get-started/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Feature discovery is divided into domain-specific feature sources:
- System
- USB
- Custom (rule-based custom features)
- Local (hooks for user-specific features)
- Local (features files)

Each feature source is responsible for detecting a set of features which. in
turn, are turned into node feature labels. Feature labels are prefixed with
Expand Down
26 changes: 0 additions & 26 deletions docs/reference/worker-configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,32 +304,6 @@ sources:

### sources.local

### sources.local.hooksEnabled

**DEPRECATED**: Hooks are DEPRECATED since v0.12.0 release and support (and
this configuration option) will be removed in NFD v0.17. Use
[feature files](../usage//customization-guide.md#feature-files) instead.

Configuration option to disable/enable hooks execution. Disabled by default.

> **NOTE:** The default NFD container image only supports statically linked
> binaries. Use the [full](../deployment/image-variants.md#full) image variant
> for a slightly more extensive environment that additionally supports bash and
> perl runtimes.

GitHub tracking issue:
[Drop support for hooks (#856)](https://github.com/kubernetes-sigs/node-feature-discovery/issues/856).

Default: false

Example:

```yaml
sources:
local:
hooksEnabled: true
```

### sources.pci

#### sources.pci.deviceClassWhitelist
Expand Down
70 changes: 13 additions & 57 deletions docs/usage/customization-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ labeling:
- [`NodeFeatureRule`](#nodefeaturerule-custom-resource) objects provide a way to
deploy custom labeling rules via the Kubernetes API.
- [`local`](#local-feature-source) feature source of nfd-worker creates
labels by reading text files and executing hooks.
labels by reading text files.
- [`custom`](#custom-feature-source) feature source of nfd-worker creates
labels based on user-specified rules.

Expand Down Expand Up @@ -232,13 +232,12 @@ point for external feature detectors. It provides a mechanism for pluggable
extensions, allowing the creation of new user-specific features and even
overriding built-in labels.

The `local` feature source has two methods for detecting features, feature
files and hooks (hooks are deprecated and slated for removal in NFD v0.17). The
features discovered by the `local` source can further be used in label rules
specified in [`NodeFeatureRule`](#nodefeaturerule-custom-resource) objects and
The `local` feature source uses feature files. The features discovered by the
`local` source can further be used in label rules specified in
[`NodeFeatureRule`](#nodefeaturerule-custom-resource) objects and
the [`custom`](#custom-feature-source) feature source.

> **NOTE:** Be careful when creating and/or updating hook or feature files
> **NOTE:** Be careful when creating and/or updating feature files
> while NFD is running. To avoid race conditions you should write
> into a temporary file, and atomically create/update the original file by
> doing a file rename operation. NFD ignores dot files,
Expand All @@ -250,9 +249,7 @@ the [`custom`](#custom-feature-source) feature source.

Consider a plaintext file
`/etc/kubernetes/node-feature-discovery/features.d/my-features`
having the following contents (or alternatively a shell script
`/etc/kubernetes/node-feature-discovery/source.d/my-hook.sh` having the
following stdout output):
having the following contents:

```plaintext
feature.node.kubernetes.io/my-feature.1
Expand All @@ -274,47 +271,9 @@ The `local` source reads files found in
`/etc/kubernetes/node-feature-discovery/features.d/`. File content is parsed
and translated into node labels, see the [input format below](#input-format).

### Hooks

**DEPRECATED** Hooks are deprecated and will be completely removed in NFD
v0.17.

The `local` source executes hooks found in
`/etc/kubernetes/node-feature-discovery/source.d/`. The hook files must be
executable and they are supposed to print all discovered features in `stdout`.
Since NFD v0.13 the default container image only supports statically linked ELF
binaries.

`stderr` output of hooks is propagated to NFD log so it can be used for
debugging and logging.

NFD tries to execute any regular files found from the hooks directory.
Any additional data files the hook might need (e.g. a configuration file)
should be placed in a separate directory to avoid NFD unnecessarily
trying to execute them. A subdirectory under the hooks directory can be used,
for example `/etc/kubernetes/node-feature-discovery/source.d/conf/`.

> **NOTE:** Starting from release v0.14 hooks are disabled by default and can
> be enabled via `sources.local.hooksEnabled` field in the worker
> configuration.

```yaml
sources:
local:
hooksEnabled: true # true by default at this point
```

> **NOTE:** NFD will blindly run any executables placed/mounted in the hooks
> directory. It is the user's responsibility to review the hooks for e.g.
> possible security implications.
>
> **NOTE:** The [full](../deployment/image-variants.md#full) image variant
> provides backwards-compatibility with older NFD versions by including a more
> expanded environment, supporting bash and perl runtimes.

### Input format

The hook stdout and feature files are expected to contain features in simple
The feature files are expected to contain features in simple
key-value pairs, separated by newlines:

```plaintext
Expand Down Expand Up @@ -410,19 +369,16 @@ vendor.io/my-feature=value
### Mounts

The standard NFD deployments contain `hostPath` mounts for
`/etc/kubernetes/node-feature-discovery/source.d/` and
`/etc/kubernetes/node-feature-discovery/features.d/`, making these directories
from the host available inside the nfd-worker container.

#### Injecting labels from other pods

One use case for the feature files and hooks is detecting features in other
One use case for the feature files is detecting features in other
Pods outside NFD, e.g. in Kubernetes device plugins. By using the same
`hostPath` mounts for `/etc/kubernetes/node-feature-discovery/source.d/` and
`/etc/kubernetes/node-feature-discovery/features.d/` in the side-car (e.g.
device plugin) creates a shared area for deploying feature files and hooks to
NFD. NFD periodically scans the directories and reads any feature files and
runs any hooks it finds.
`hostPath` mounts `/etc/kubernetes/node-feature-discovery/features.d/`
in the side-car (e.g. device plugin) creates a shared area for
deploying feature files to NFD.

## Custom feature source

Expand Down Expand Up @@ -1000,8 +956,8 @@ The following features are available for matching:
| | | **`major`** | int | First component of the kernel version (e.g. ‘4') |
| | | **`minor`** | int | Second component of the kernel version (e.g. ‘5') |
| | | **`revision`** | int | Third component of the kernel version (e.g. ‘6') |
| **`local.label`** | attribute | | | Labels from feature files and hooks, i.e. labels from the [*local* feature source](#local-feature-source) |
| **`local.feature`** | attribute | | | Features from feature files and hooks, i.e. features from the [*local* feature source](#local-feature-source) |
| **`local.label`** | attribute | | | Labels from feature files, i.e. labels from the [*local* feature source](#local-feature-source) |
| **`local.feature`** | attribute | | | Features from feature files, i.e. features from the [*local* feature source](#local-feature-source) |
| | | **`<label-name>`** | string | Label `<label-name>` created by the local feature source, value equals the value of the label |
| **`memory.nv`** | instance | | | NVDIMM devices present in the system |
| | | **`<sysfs-attribute>`** | string | Value of the sysfs device attribute, available attributes: `devtype`, `mode` |
Expand Down
2 changes: 1 addition & 1 deletion pkg/nfd-worker/nfd-worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ func getFeatureLabels(source source.LabelSource, labelWhiteList regexp.Regexp) (
name := k
switch sourceName := source.Name(); sourceName {
case "local", "custom":
// No mangling of labels from the custom rules, hooks or feature files
// No mangling of labels from the custom rules or feature files
default:
// Prefix for labels from other sources
if !strings.Contains(name, "/") {
Expand Down
Loading

0 comments on commit 566a945

Please sign in to comment.