1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00
Commit graph

1095 commits

Author SHA1 Message Date
Markus Lehtonen
773280de65 nfd-worker: provide deprecated core.sources config option
Provide backwards compatibility via a deprecated 'core.sources' config
file option. This will override 'core.labelSources'. A warning is
printed in the log if this option is detected.
2021-12-01 17:11:49 +02:00
Markus Lehtonen
ad9c7dfa1e nfd-worker: rename config option 'sources' to 'labelSources'
The goal is to make the name more descriptive. Also keeping in mind a
possible future addition a 'featureSources' option (or similar) for
controlling the feature discovery.
2021-12-01 17:11:49 +02:00
Kubernetes Prow Robot
5ae7b8bb7a
Merge pull request #683 from marquiz/devel/kconfig-regexp
source/kernel: ditch regexp in kconfig parsing
2021-12-01 06:53:15 -08:00
Kubernetes Prow Robot
86bfe74cd7 Merge pull request #671 from marquiz/fixes/single-dash-flags
Use single-dash format of cmdline flags
2021-12-01 06:45:15 -08:00
Kubernetes Prow Robot
4bb2311b5e
Merge pull request #667 from ArangoGutierrez/devel/clean-lables
Add deploy-prune makefile rule to ease devel processes
2021-12-01 06:09:16 -08:00
Kubernetes Prow Robot
4e6e730d28
Merge pull request #687 from marquiz/fixes/lint
Lint fixes to pkg/apis
2021-12-01 05:49:16 -08:00
Kubernetes Prow Robot
14e07401d8
Merge pull request #672 from marquiz/documentation/cmdline-help
docs: drop cmdline help from developer guide
2021-12-01 05:03:15 -08:00
Kubernetes Prow Robot
fb5e1b6424
Merge pull request #679 from ArangoGutierrez/devel/deploy_make
Makefile: Add make deploy rule
2021-12-01 04:49:15 -08:00
Markus Lehtonen
1765a37c6a pkg/apis/nfd: drop unnecessary else statements 2021-12-01 10:55:50 +02:00
Markus Lehtonen
3f225be081 pkg/apis/nfd: use consistent receiver name for methods of templateHelper 2021-12-01 10:51:47 +02:00
Markus Lehtonen
d07400206f pkg/apis/nfd/v1alpha1: document exported symbols
Add missing comments and fix some existing ones.
2021-12-01 10:46:56 +02:00
Markus Lehtonen
c4f7ab0abe pkg/api/feature: document exported functions 2021-12-01 10:30:17 +02:00
Kubernetes Prow Robot
6f69b67708
Merge pull request #686 from spiffxp/fix-gcb-image
images: fix invalid k8s-staging-test-infra/gcb-docker-gcloud tag
2021-11-30 23:57:17 -08:00
Aaron Crickenberger
ae223e4de8 images: fix invalid k8s-staging-test-infra/gcb-docker-gcloud tag 2021-11-30 13:37:12 -08:00
Kubernetes Prow Robot
36d55629ef
Merge pull request #685 from spiffxp/use-k8s-infra-for-gcb-image
images: use k8s-staging-test-infra/gcb-docker-gcloud
2021-11-30 11:27:03 -08:00
Aaron Crickenberger
01c86b0521 images: use k8s-staging-test-infra/gcb-docker-gcloud 2021-11-30 11:16:01 -08:00
Kubernetes Prow Robot
a86318fb92
Merge pull request #675 from jschintag/s390x-new-cpu-flags
source/cpu: add additional IBM Z CPU Flags
2021-11-30 04:52:56 -08:00
Markus Lehtonen
d4efc2ce0b source/kernel: ditch regexp in kconfig parsing
Regexp is just a resource hog here and does not simplify the code.
2021-11-30 14:43:05 +02:00
Carlos Eduardo Arango Gutierrez
f718379ba0
makefile: Add make deploy rule
After https://github.com/kubernetes-sigs/node-feature-discovery/pull/667
adding a rule for also deploying NFD is encouraged.

Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
2021-11-29 15:11:08 -05:00
Carlos Eduardo Arango Gutierrez
4791bd3a42
Add clean-labels makefile rule to ease devel processes
Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
2021-11-29 15:01:41 -05:00
Kubernetes Prow Robot
ffe12cb1e4
Merge pull request #663 from marquiz/devel/rule-backrefs
Add variables to feature rule spec and support backrefs
2021-11-29 09:29:23 -08:00
Markus Lehtonen
a57a25f63c Use single-dash format of cmdline flags
Use the single-dash (i.e. '-option' instead of '--option') format
consistently accross log messages and documentation. This is the format
that was mostly used, already, and shown by command line help of the
binaries, for example.
2021-11-25 18:03:54 +02:00
Jan Schintag
c545cfb0dc source/cpu: add additional IBM Z CPU Flags
Add the newly supported s390x CPU Flags for the 5.15 Kernel

Signed-off-by: Jan Schintag <jan.schintag@de.ibm.com>
2021-11-25 13:41:57 +01:00
Jan Schintag
476756ab0c source/cpu: Fix compile error for non-amd64 arches
Signed-off-by: Jan Schintag <jan.schintag@de.ibm.com>
2021-11-25 13:41:57 +01:00
Markus Lehtonen
0d21b3d720 docs: drop cmdline help from developer guide
These just keep getting out of sync and do not provide much value. Also,
we do have dedicated cmdline reference for all the executables.
2021-11-25 13:56:09 +02:00
Markus Lehtonen
b648d005e1 pkg/apis/nfd: support templating of "vars"
Support templating of var names in a similar manner as labels. Add
support for a new 'varsTemplate' field to the feature rule spec which is
treated similarly to the 'labelsTemplate' field. The value of the field
is processed through the golang "text/template" template engine and the
expanded value must contain variables in <key>=<value> format, separated
by newlines i.e.:

  - name: <rule-name>
    varsTemplate: |
      <label-1>=<value-1>
      <label-2>=<value-2>
      ...

Similar rules as for 'labelsTemplate' apply, i.e.

1. In case of matchAny is specified, the template is executed separately
   against each individual matchFeatures matcher.
2. 'vars' field has priority over 'varsTemplate'
2021-11-25 12:50:47 +02:00
Markus Lehtonen
f75303ce43 pkg/apis/nfd: add variables to rule spec and support backreferences
Support backreferencing of output values from previous rules. Enables
complex rule setups where custom features are further combined together
to form even more sophisticated higher level labels. The labels created
by preceding rules are available as a special 'rule.matched' feature
(for matchFeatures to use).

If referencing rules accross multiple configs/CRDs care must be taken
with the ordering. Processing order of rules in nfd-worker:

1. Static rules
2. Files from /etc/kubernetes/node-feature-discovery/custom.d/
   in alphabetical order. Subdirectories are processed by reading their
   files in alphabetical order.
3. Custom rules from main nfd-worker.conf

In nfd-master, NodeFeatureRule objects are processed in alphabetical
order (based on their metadata.name).

This patch also adds new 'vars' fields to the rule spec. Like 'labels',
it is a map of key-value pairs but no labels are generated from these.
The values specified in 'vars' are only added for backreferencing into
the 'rules.matched' feature. This may by desired in schemes where the
output of certain rules is only used as intermediate variables for other
rules and no labels out of these are wanted.

An example setup:

  - name: "kernel feature"
    labels:
      kernel-feature:
    matchFeatures:
      - feature: kernel.version
        matchExpressions:
          major: {op: Gt, value: ["4"]}

  - name: "intermediate var feature"
    vars:
      nolabel-feature: "true"
    matchFeatures:
      - feature: cpu.cpuid
        matchExpressions:
          AVX512F: {op: Exists}
      - feature: pci.device
        matchExpressions:
          vendor: {op: In, value: ["8086"]}
          device: {op: In, value: ["1234", "1235"]}

  - name: top-level-feature
    matchFeatures:
      - feature: rule.matched
        matchExpressions:
          kernel-feature: "true"
          nolabel-feature: "true"
2021-11-25 12:50:47 +02:00
Kubernetes Prow Robot
0b4050af7f
Merge pull request #668 from marquiz/fixes/rule-template
pkg/apis/nfd: stricter format checking for template labels
2021-11-25 02:48:33 -08:00
Markus Lehtonen
8a4d3161cf pkg/apis/nfd: stricter format checking for template labels
Require that the expanded LabelsTemplate has values. That is, the
(expanded) template must consist of key=value pairs separated by
newlines. No default value will be assigned and we now return an error
if a (non-empty) line not conforming with the key=value format is
encountered.

Commit c8d73666d described that the value defaults to "true" if not
specified. That was not the case and we defaulted to an empty string,
instead.

An example:

  - name: "my rule"
    labelsTemplate: |
      my.label.1=foo
      my.label.2=

Would create these labels:

  "my.label.1": "foo"
  "my.label.2": ""

Further, the following:

  - name: "my failing rule"
    labelsTemplate: |
      my.label.3

will cause an error in the rule processing.
2021-11-24 21:31:35 +02:00
Kubernetes Prow Robot
b46a95f7ed
Merge pull request #666 from marquiz/fixes/memory
source/memory: fix memory.numa label
2021-11-24 06:34:20 -08:00
Kubernetes Prow Robot
7e4dd6c8d2
Merge pull request #665 from marquiz/fixes/selinux
source/kernel: don't advertise selinux.enabled=false
2021-11-24 06:26:20 -08:00
Kubernetes Prow Robot
9fbb9383f2
Merge pull request #647 from mythi/sgx
source/cpu: detect Intel SGX
2021-11-24 05:30:21 -08:00
Kubernetes Prow Robot
da484b7bd3
Merge pull request #550 from marquiz/devel/custom-templating
Templating of custom label names
2021-11-23 12:02:51 -08:00
Markus Lehtonen
c8d73666d6 pkg/apis/nfd: support label name templating
Support templating of label names in feature rules. It is available both
in NodeFeatureRule CRs and in custom rule configuration of nfd-worker.

This patch adds a new 'labelsTemplate' field to the rule spec, making it
possible to dynamically generate multiple labels per rule based on the
matched features. The feature relies on the golang "text/template"
package.  When expanded, the template must contain labels in a raw
<key>[=<value>] format (where 'value' defaults to "true"), separated by
newlines i.e.:

  - name: <rule-name>
    labelsTemplate: |
      <label-1>[=<value-1>]
      <label-2>[=<value-2>]
      ...

All the matched features of 'matchFeatures' directives are available for
templating engine in a nested data structure that can be described in
yaml as:

.
  <domain-1>:
      <key-feature-1>:
        - Name: <matched-key>
        - ...

      <value-feature-1:
        - Name: <matched-key>
          Value: <matched-value>
        - ...

      <instance-feature-1>:
        - <attribute-1-name>: <attribute-1-value>
          <attribute-2-name>: <attribute-2-value>
          ...
        - ...

  <domain-2>:
     ...

That is, the per-feature data available for matching depends on the type
of feature that was matched:

- "key features": only 'Name' is available
- "value features": 'Name' and 'Value' can be used
- "instance features": all attributes of the matched instance are
   available

NOTE: In case of matchAny is specified, the template is executed
separately against each individual matchFeatures matcher and the
eventual set of labels is a superset of all these expansions.  Consider
the following:

  - name: <name>
    labelsTemplate: <template>
    matchAny:
      - matchFeatures: <matcher#1>
      - matchFeatures: <matcher#2>
    matchFeatures: <matcher#3>

In the example above (assuming the overall result is a match) the
template would be executed on matcher#1 and/or matcher#2 (depending on
whether both or only one of them match), and finally on matcher#3, and
all the labels from these separate expansions would be created (i.e. the
end result would be a union of all the individual expansions).

NOTE 2: The 'labels' field has priority over 'labelsTemplate', i.e.
labels specified in the 'labels' field will override any labels
originating from the 'labelsTemplate' field.

A special case of an empty match expression set matches everything (i.e.
matches/returns all existing keys/values). This makes it simpler to
write templates that run over all values. Also, makes it possible to
later implement support for templates that run over all _keys_ of a
feature.

Some example configurations:

  - name: "my-pci-template-features"
    labelsTemplate: |
      {{ range .pci.device }}intel-{{ .class }}-{{ .device }}=present
      {{ end }}
    matchFeatures:
      - feature: pci.device
        matchExpressions:
          class: {op: InRegexp, value: ["^06"]}
          vendor: ["8086"]

  - name: "my-system-template-features"
    labelsTemplate: |
      {{ range .system.osrelease }}system-{{ .Name }}={{ .Value }}
      {{ end }}
    matchFeatures:
      - feature: system.osRelease
        matchExpressions:
          ID: {op: Exists}
          VERSION_ID.major: {op: Exists}

Imaginative template pipelines are possible, of course, but care must be
taken in order to produce understandable and maintainable rule sets.
2021-11-23 21:03:22 +02:00
Markus Lehtonen
17b094d8d6 source/memory: fix memory.numa label 2021-11-23 20:35:17 +02:00
Markus Lehtonen
d60fcb98e4 source/kernel: don't advertise selinux.enabled=false
Commit 0945019161 changed the behavior so
that NFD started to advertise also "false" status of selinux.enabled
label. This patch reverts this behavior (i.e. we only have
selinux.enabled=true). The rationale behind is avoiding any excess
labels - selinux.enabled=false label would be pointless noise in most
deployments.
2021-11-23 20:12:20 +02:00
Mikko Ylinen
8a39434659 source/cpu: detect Intel SGX
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2021-11-23 15:57:31 +02:00
Kubernetes Prow Robot
c4af8a1229
Merge pull request #661 from marquiz/devel/memory-feature-source
source/memory: implement FeatureSource
2021-11-23 05:12:17 -08:00
Markus Lehtonen
085af7c2c7 pkg/apis/nfd: helpers for handling templates in Rule names
Implement a private helper type (nameTemplateHelper) for handling
(executing and caching) of templated names. DeepCopy methods are
manually implemented as controller-gen is not able to help with that.
2021-11-23 15:08:53 +02:00
Markus Lehtonen
c3da439d21 source/memory: implement FeatureSource
Separate feature discovery and creation of feature labels.

Generalize the discovery of nvdimm devices so that they can be matched
in custom label rules in a similar fashion as pci and usb devices.
Available attributes for matching nvdimm devices are limited to:

- devtype
- mode

For numa we now detect the number of numa nodes which can be matched
agains in custom label rules.

Labels created by the memory feature source are unchanged. The new
features being detected are available in custom rules only.

Example custom rule:

  - name: "my memory rule"
    labels:
      my-memory-feature: "true"
    matchFeatures:
      - feature: memory.numa
        matchExpressions:
          "node_count": {op: Gt, value: ["3"]}
      - feature: memory.nv
        matchExpressions:
          "devtype" {op: In, value: ["nd_dax"]}

Also, add minimalist unit test.
2021-11-23 15:08:15 +02:00
Kubernetes Prow Robot
ad933e44b4
Merge pull request #660 from marquiz/devel/network-feature-source
source/network: implement FeatureSource
2021-11-23 04:26:17 -08:00
Kubernetes Prow Robot
aa0074fb76
Merge pull request #553 from marquiz/devel/custom-crd
CRD-based custom node labeling
2021-11-23 04:20:17 -08:00
Kubernetes Prow Robot
bb4cfed88c
Merge pull request #664 from marquiz/devel/e2e-boot-mount
Revert "test/e2e: drop /boot mount"
2021-11-23 03:50:17 -08:00
Markus Lehtonen
f7b2bcc457 Revert "test/e2e: drop /boot mount"
This reverts commit 261ab113bf.
2021-11-23 10:50:20 +02:00
Markus Lehtonen
9a02b544a2 source/network: implement FeatureSource
Separate feature discovery and creation of feature labels. Generalize
the feature discovery so that network devices can be matched in custom
label rules in a similar fashion as pci and usb devices. Available
attributes for matching are:

- operstate
- speed
- sriov_numvfs
- sriov_totalvfs

Labels created by the network feature source are unchanged. The new
features being detected are available in custom rules only.

Example custom rule:

  - name: "my network rule"
    labels:
      my-network-feature: "true"
    matchFeatures:
      - feature: network.device
        matchExpressions:
          "operstate": { op: In, value: ["up"] }
          "sriov_numvfs": { op: Gt, value: ["9"] }

Also, add minimalist unit test.
2021-11-23 10:05:38 +02:00
Markus Lehtonen
0a96359f29 deployment: fix mistake in example worker config 2021-11-23 10:01:41 +02:00
Markus Lehtonen
33fdf75190 nfd-master: process labeling rules from CRs
Enable Custom Resource based label creation in nfd-master. This extends
the previously implemented controller stub for watching NodeFeatureRule
objects. NFD-master watches NodeFeatureRule objects in the cluster and
processes the rules on every incoming labeling request from workers.
The functionality relies on the "raw features" (identical to how
nfd-worker handles custom rules) submitted by nfd-worker, making it
independent of the label source configuration of the worker. This means
that the labeling functions as expected even if all sources in the
worker are disabled.

NOTE: nfd-master is stateless and re-labeling only happens on the
reception of SetLabelsRequest from the worker – i.e. on intervals
specified by the core.sleepInterval configuration option (or
-sleep-interval cmdline flag) of each nfd-worker instance. This means
that modification/creation of NodeFeatureRule objects does not
automatically update the node labels. Instead, the changes only come
visible when workers send their labeling requests.
2021-11-23 09:18:07 +02:00
Kubernetes Prow Robot
99d3251c42
Merge pull request #649 from marquiz/devel/storage-feature-source
source/storage: implement FeatureSource
2021-11-22 11:31:32 -08:00
Kubernetes Prow Robot
116b24697b
Merge pull request #656 from marquiz/devel/crd-controller
nfd-master: implement controller for NodeFeatureRule CRs
2021-11-22 08:33:09 -08:00
Markus Lehtonen
e8872462dc nfd-master: add -featurerules-controller flag
Add a new command line flag for disabling/enabling the controller for
NodeFeatureRule objects. In practice, disabling the controller disables
all labels generated from rules in NodeFeatureRule objects.
2021-11-22 16:57:42 +02:00