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

936 commits

Author SHA1 Message Date
Kubernetes Prow Robot
ec57057d3c
Merge pull request #659 from vaibhav2107/contri-slack
Update the link of slack channel
2021-11-18 00:19:04 -08:00
Vaibhav
e4385d2402 Update the link of slack channel 2021-11-18 11:39:18 +05:30
Kubernetes Prow Robot
15c4d4c894
Merge pull request #657 from marquiz/devel/crd-fix
pkg/apis/nfd: drop excess field from the CRD
2021-11-17 06:47:54 -08:00
Markus Lehtonen
b96b86bc6c pkg/apis/nfd: drop excess field from the CRD
Drop stale leftover "LabelsTemplate" field from the rule spec.
2021-11-17 16:40:28 +02:00
Kubernetes Prow Robot
d3bd0edabb
Merge pull request #654 from marquiz/devel/api-rule-processing
source/custom: move rule matching to pkg/apis/nfd
2021-11-17 04:23:54 -08:00
Markus Lehtonen
8b9df3cf31 source/custom: move rule matching to pkg/apis/nfd
Move the rule processing of matchFeatures and matchAny from
source/custom package over to pkg/apis/nfd, aiming for better integrity
and re-usability of the code. Does not change the CRD API as such, just
adds more supportive functions.
2021-11-17 14:02:00 +02:00
Kubernetes Prow Robot
55ea049ed7
Merge pull request #653 from marquiz/devel/nodefeaturerule-crd
specify CRD for custom labeling rules
2021-11-17 03:45:54 -08:00
Markus Lehtonen
3765ae24d6 pkg/apis/nfd: specify a dedicated type for regexp cache
Having a dedicated type makes it possible to specify deepcopy functions
for it. We need to do this manually as deepcopy-gen doesn't know how to
create copies of regexps.
2021-11-17 13:40:43 +02:00
Markus Lehtonen
f3cc109f99 pkg/apis/nfd: work around issues with k8s deepcopy-gen
Without this hack the generated code does not compile.
2021-11-17 13:40:43 +02:00
Markus Lehtonen
c3e2315834 pkg/apis/nfd: specify CRD for custom labeling rules
Add a cluster-scoped Custom Resource Definition for specifying labeling
rules. Nodes (node features, node objects) are cluster-level objects and
thus the natural and encouraged setup is to only have one NFD deployment
per cluster - the set of underlying features of the node stays the same
independent of how many parallel NFD deployments you have. Our extension
points (hooks, feature files and now CRs) can be be used by multiple
actors (depending on us) simultaneously. Having the CRD cluster-scoped
hopefully drives deployments in this direction. It also should make
deployment of vendor-specific labeling rules easy as there is no need to
worry about the namespace.

This patch virtually replicates the source.custom.FeatureSpec in a CRD
API (located in the pkg/apis/nfd/v1alpha1 package) with the notable
exception that "MatchOn" legacy rules are not supported. Legacy rules
are left out in order to keep the CRD simple and clean.

The duplicate functionality in source/custom will be dropped by upcoming
patches.

This patch utilizes controller-gen (from sigs.k8s.io/controller-tools)
for generating the CRD and deepcopy methods. Code can be (re-)generated
with "make generate". Install controller-gen with:

  go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.7.0

Update kustomize and helm deployments to deploy the CRD.
2021-11-17 13:40:23 +02:00
Markus Lehtonen
0757248055 source/custom: move rule expressions to pkg/apis/nfd/v1alpha1
Create a new package pkg/apis/nfd/v1alpha1 and migrate the custom rule
expressions over there. This is the first step in creating a new CRD API
for custom rules.
2021-11-16 18:12:16 +02:00
Kubernetes Prow Robot
389ff52ede
Merge pull request #646 from marquiz/devel/grpc-raw-features
grpc: extend the API to send raw features
2021-11-16 07:39:27 -08:00
Markus Lehtonen
47e7c47594 Send raw features over gRPC
Enable transfer of raw features between nfd-worker and nfd-master.
2021-11-16 17:32:28 +02:00
Markus Lehtonen
d4d9a03732 grpc: extend the API to send raw features
Enable transmitting the discovered "raw" features over the gRPC API.

Extend pkg/api/feature with protobuf and gRPC code. In this, utilize
go-to-protobuf from k8s code-generator for auto-generating the gRPC
interface from golang code. The tool can be Installed with:

  go install k8s.io/code-generator/cmd/go-to-protobuf@v0.20.7

The auto-generated code is (re-)generated/updated with "make apigen".
2021-11-16 17:32:28 +02:00
Kubernetes Prow Robot
c29ab3bb35
Merge pull request #652 from k8stopologyawareschedwg/consume-cluster-scoped-api
NFD-Topology-Updater: Bump NRT API to version v0.0.12
2021-11-16 07:13:27 -08:00
Swati Sehgal
b444ef95a8 NFD-Topology-Updater: Bump NRT API to version v0.0.12
The NodeResourceTopology API has been made cluster
scoped as in the current context a CR corresponds to
a Node and since Node is a cluster scoped resource it
makes sense to make NRT cluster scoped as well.

Ref: https://github.com/k8stopologyawareschedwg/noderesourcetopology-api/pull/18
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2021-11-16 13:28:23 +00:00
Kubernetes Prow Robot
fd7c7e5d1b
Merge pull request #464 from marquiz/devel/source-refactor
More extensive and expressive custom rules
2021-11-16 05:03:27 -08:00
Markus Lehtonen
52d9aa2244 source/custom: improved logging of expression matching
Print out the result of applying an expression. Also, truncate the
output to max 10 elements (of items matched against) unless '-v 4'
verbosity level is in use.
2021-11-12 16:51:30 +02:00
Markus Lehtonen
6cbed379df source/custom: implement matchAny directive
Implement a new 'matchAny' directive in the new rule format, building on
top of the previously implemented 'matchFeatures' matcher. MatchAny
applies a logical OR over multiple matchFeatures directives. That is, it
allows specifying multiple alternative matchers (at least one of which
must match) in a single label rule.

The configuration format for the new matchers is

  matchAny:
    - matchFeatures:
        - feature: <domain>.<feature>
          matchExpressions:
            <attribute>:
              op: <operator>
              value:
                - <list-of-values>
    - matchFeatures:
      ...

A configuration example. In order to require a cpu feature, kernel
module and one of two specific PCI devices (taking use of the shortform
notation):

  - name: multi-device-test
    labels:
      multi-device-feature: "true"
    matchFeatures:
      - feature: kernel.loadedmodule
        matchExpressions: [driver-module]
      - feature: cpu.cpuid
        matchExpressions: [AVX512F]
    matchAny:
      - matchFeatures:
          - feature; pci.device
            matchExpressions:
              vendor: "8086"
              device: "1234"
      - matchFeatures:
          - feature: pci.device
            matchExpressions:
              vendor: "8086"
              device: "abcd"
2021-11-12 16:51:30 +02:00
Markus Lehtonen
e206f0b86b source/custom: implement generic feature matching
Implement generic feature matchers that cover all feature sources (that
implement the FeatureSource interface). The implementation relies on the
unified data model provided by the FeatureSource interface as well as
the generic expression-based rule processing framework that was added to
the source/custom/expression package.

With this patch any new features added will be automatically available
for custom rules, without any additional work. Rule hierarchy follows
the source/feature hierarchy by design.

This patch introduces a new format for custom rule specifications,
dropping the 'value' field and introducing new 'labels' field which
makes it possible to specify multiple labels per rule. Also, in the new
format the 'name' field is just for reference and no matching label is
created. The new generic rules are available in this new rule format
under a 'matchFeatures. MatchFeatures implements a logical AND over
an array of per-feature matchers - i.e. a match for all of the matchers
is required. The goal of the new rule format is to make it better follow
K8s API design guidelines and make it extensible for future enhancements
(e.g. addition of templating, taints, annotations, extended resources
etc).

The old rule format (with cpuID, kConfig, loadedKMod, nodename, pciID,
usbID rules) is still supported. The rule format (new vs. old) is
determined at config parsing time based on the existence of the
'matchOn' field.

The new rule format and the configuration format for the new
matchFeatures field is

  - name: <rule-name>
    labels:
      <key>: <value>
      ...
    matchFeatures:
      - feature: <domain>.<feature>
        matchExpressions:
          <attribute>:
            op: <operator>
            value:
              - <list-of-values>
      - feature: <domain>.<feature>
        ...

Currently, "cpu", "kernel", "pci", "system", "usb" and "local" sources
are covered by the matshers/feature selectors. Thus, the following
features are available for matching with this patch:

  - cpu.cpuid:
      <cpuid-flag>: <exists/does-not-exist>
  - cpu.cstate:
      enabled: <bool>
  - cpu.pstate:
      status: <string>
      turbo: <bool>
      scaling_governor: <string>
  - cpu.rdt:
      <rdt-feature>: <exists/does-not-exist>
  - cpu.sst:
      bf.enabled: <bool>
  - cpu.topology:
      hardware_multithreading: <bool>
  - kernel.config:
      <flag-name>: <string>
  - kernel.loadedmodule:
      <module-name>: <exists/does-not-exist>
  - kernel.selinux:
      enabled: <bool>
  - kernel.version:
      major: <int>
      minor: <int>
      revision: <int>
      full: <string>
  - system.osrelease:
      <key-name>: <string>
      VERSION_ID.major: <int>
      VERSION_ID.minor: <int>
  - system.name:
      nodename: <string>
  - pci.device:
      <device-instance>:
        class: <string>
        vendor: <string>
        device: <string>
        subsystem_vendor: <string>
        susbystem_device: <string>
        sriov_totalvfs: <int>
  - usb.device:
      <device-instance>:
        class: <string>
        vendor: <string>
        device: <string>
        serial: <string>
  - local.label:
      <label-name>: <string>

The configuration also supports some "shortforms" for convenience:

   matchExpressions: [<attr-1>, <attr-2>=<val-2>]
   ---
   matchExpressions:
     <attr-3>:
     <attr-4>: <val-4>

is equal to:

   matchExpressions:
     <attr-1>: {op: Exists}
     <attr-2>: {op: In, value: [<val-2>]}
   ---
   matchExpressions:
     <attr-3>: {op: Exists}
     <attr-4>: {op: In, value: [<val-4>]}

In other words:

  - feature: kernel.config
    matchExpressions: ["X86", "INIT_ENV_ARG_LIMIT=32"]
  - feature: pci.device
    matchExpressions:
      vendor: "8086"

is the same as:

  - feature: kernel.config
    matchExpressions:
      X86: {op: Exists}
      INIT_ENV_ARG_LIMIT: {op: In, values: ["32"]}
  - feature: pci.device
    matchExpressions:
      vendor: {op: In, value: ["8086"]

Some configuration examples below. In order to match a CPUID feature the
following snippet can be used:

  - name: cpu-test-1
    labels:
      cpu-custom-feature: "true"
    matchFeatures:
      - feature: cpu.cpuid
        matchExpressions:
          AESNI: {op: Exists}
          AVX: {op: Exists}

In order to match against a loaded kernel module and OS version:

  - name: kernel-test-1
    labels:
      kernel-custom-feature: "true"
    matchFeatures:
      - feature: kernel.loadedmodule
        matchExpressions:
          e1000: {op: Exists}
      - feature: system.osrelease
        matchExpressions:
          NAME: {op: InRegexp, values: ["^openSUSE"]}
          VERSION_ID.major: {op: Gt, values: ["14"]}

In order to require a kernel module and both of two specific PCI devices:

  - name: multi-device-test
    labels:
      multi-device-feature: "true"
    matchFeatures:
      - feature: kernel.loadedmodule
        matchExpressions:
          driver-module: {op: Exists}
      - pci.device:
          vendor: "8086"
          device: "1234"
      - pci.device:
          vendor: "8086"
          device: "abcd"
2021-11-12 16:51:13 +02:00
Kubernetes Prow Robot
cfc1c82746
Merge pull request #639 from marquiz/devel/matchexpression-rules
source/custom: expression based label rules
2021-11-12 06:20:28 -08:00
Kubernetes Prow Robot
52ba742d69
Merge pull request #648 from uniemimu/yatypofix
More topology updater documentation typo fixes
2021-11-12 04:32:27 -08:00
Ukri Niemimuukko
90598d3b5a More topology updater documentation typo fixes
Signed-off-by: Ukri Niemimuukko <ukri.niemimuukko@intel.com>
2021-11-12 14:25:32 +02:00
Kubernetes Prow Robot
b26a12cc17
Merge pull request #640 from eliaskoromilas/worker-config
deployment: Implicitly generate the worker ConfigMap name
2021-11-12 03:38:28 -08:00
Kubernetes Prow Robot
8351887465
Merge pull request #645 from uniemimu/typofix
Topology-updater introduction typo fix
2021-11-12 02:44:28 -08:00
Ukri Niemimuukko
0a2e3bb18d Topology-updater introduction typo fix
Signed-off-by: Ukri Niemimuukko <ukri.niemimuukko@intel.com>
2021-11-12 12:10:33 +02:00
Markus Lehtonen
689703be48 source/custom: implement 'GtLt' operator
A new operator for checking that an input (integer) is between two
values.
2021-11-11 19:59:34 +02:00
Markus Lehtonen
8b4314bbbb source/custom: expression based label rules
Implement a framework for more flexible rule configuration and matching,
mimicking the MatchExpressions pattern from K8s nodeselector.

The basic building block is MatchExpression which contains an operator
and a list of values. The operator specifies that "function" that is
applied when evaluating a given input agains the list of values.
Available operators are:

- MatchIn
- MatchNotIn
- MatchInRegexp
- MatchExists
- MatchDoesNotExist
- MatchGt
- MatchLt
- MatchIsTrue
- MatchIsFalse

Another building block of the framework is MatchExpressionSet which is a
map of string-MatchExpression pairs. It is a helper for specifying
multiple expressions that can be matched against a set of set of
features.

This patch converts all existing custom rules to utilize the new
expression-based framework.
2021-11-11 19:59:34 +02:00
Kubernetes Prow Robot
5299ca2ab4
Merge pull request #604 from marquiz/devel/feature-source-conversion
source: implement FeatureSource interface
2021-11-11 09:20:08 -08:00
Markus Lehtonen
a91f3325ba source/local: implement FeatureSource
Separate feature discovery (i.e. running hooks and reading feature
files) and creation of feature labels in the local source.

Also, add minimalist unit test.
2021-11-11 18:34:01 +02:00
Markus Lehtonen
e225f4aad0 source/system: implement FeatureSource
Separate feature discovery and creation of feature labels in the system
source.

Also, change the implementation of the nodeName custom rule to utilize
the FeatureSource interface of the system source.

Also, add minimalist unit test.
2021-11-11 18:33:58 +02:00
Markus Lehtonen
5cf25dc4e9 source/custom: move kernel module detection to source/kernel
Move the functionality responsible for detection of loeaded kernel
modules from source/custom over to the source/kernel package. Add a new
"loadedmodule" raw feature to the kernel source to store this
information.

Change loadedKmod custom rule to utilize kernel source.
2021-11-11 18:33:58 +02:00
Markus Lehtonen
df27327f14 source/usb: implement FeatureSource
Separate feature discovery and creation of feature labels in the usb
source.

Move usb_utils from source/internal to the source/usb package. Change
the implementation of the UsbID custom rule to utilize the FeatureSource
interface of the usb source.

Also, add minimalist unit test.
2021-11-11 18:33:53 +02:00
Markus Lehtonen
af0c683f60 source/pci: implement FeatureSource
Separate feature discovery and creation of feature labels in the pci
source.

Move pci_utils from source/internal to the source/pci package. Change
the implementation of the PciID custom rule to utilize the FeatureSource
interface of the pci source.

Also, add minimalist unit test.
2021-11-11 18:33:53 +02:00
Markus Lehtonen
03bf94a8ad source/cpu: implement FeatureSource
Convert the cpu source to do feature discovery and creation of feature
labels separately.

Move cpuidutils from source/internal to the source/cpu package. Change
the cpuid custom rule to utilize GetFeatures of the cpu source.

Also, add minimalist unit test.
2021-11-11 18:33:40 +02:00
Markus Lehtonen
0945019161 source/kernel: implement FeatureSource
Separate feature discovery and creation of feature labels in the kernel
source.

Move kernelutils from source/internal back to the source/kernel package.
Change the kconfig custom rule to rely on the FeatureSource interface
(GetFeatures()) of the kernel source.

Also, add minimalist unit test.
2021-11-11 18:33:40 +02:00
Markus Lehtonen
dd92c9a9ce pkg/api/feature: revert back to structs instead of pointers
Less error prone, as no chance for a nil pointer dereference.
2021-11-11 17:56:55 +02:00
Kubernetes Prow Robot
67330e1441
Merge pull request #644 from marquiz/devel/e2e-boot-mount
test/e2e: drop /boot mount
2021-11-10 11:13:27 -08:00
Kubernetes Prow Robot
54b5e43b2c
Merge pull request #643 from marquiz/devel/e2e-single-node
test/e2e: make e2e tests run on single-node cluster
2021-11-10 11:07:27 -08:00
Markus Lehtonen
261ab113bf test/e2e: drop /boot mount
This is not currently needed by end-to-end tests. Dropping it enables
testing in restricted environments that don't have /boot directory.
2021-11-10 20:58:25 +02:00
Markus Lehtonen
0161bd5ca4 test/e2e: make e2e tests run on single-node cluster
Lift the restriction to run custom rule tests on non-master node. Try to
find one but do not fail if that fails. Makes the end-to-end tests
runnable on single-node clusters such a simple minikube deployments.
2021-11-10 20:33:55 +02:00
Kubernetes Prow Robot
d957a9e4fb
Merge pull request #642 from marquiz/devel/feature-api
pkg/api/feature: small improvements
2021-11-09 05:39:47 -08:00
Markus Lehtonen
9bff4b3185 pkg/api/feature: generator functions with initial values
Flavor the generator helper functions with arguments for specifying the
set of features to put into the generated objects.
2021-11-09 13:40:35 +02:00
Markus Lehtonen
5de4d8857c pkg/api/feature: use pointers of structs
Make it easier to mutate the feature sets.
2021-11-09 12:15:38 +02:00
Kubernetes Prow Robot
30f641847e
Merge pull request #641 from marquiz/fixes/typo
pkg/resourcemonitor: fix typo in comment
2021-11-05 08:07:53 -07:00
Markus Lehtonen
25711799f3 pkg/resourcemonitor: fix typo in comment 2021-11-05 16:42:49 +02:00
Kubernetes Prow Robot
376174ff41
Merge pull request #593 from cynepco3hahue/from_swatisehgal_add_memory_information_under_resource
resourcemonitor: aggregate and provide the memory and hugepages information
2021-11-05 07:27:52 -07:00
Artyom Lukianov
45062754fd resourcemonitor: aggregate and provide the memory and hugepages information
The Kuberenetes pod resource API now exposing the memory and hugepages information
for guaranteed pods. We can use this information to update NodeResourceTopology
resource with memory and hugepages data.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-11-04 10:17:10 +02:00
Artyom Lukianov
a93b660f7c utils: add methods to fetch NUMA nodes hugepages and memory capacity
The methods are used during calculation of reserved memory for system workloads.
The calcualation is `resourceCapacity - resourceAllocatable`.

Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2021-11-04 10:14:51 +02:00
Elias Koromilas
e22b937391 Implicitly generate the worker ConfigMap name
Signed-off-by: Elias Koromilas <elias.koromilas@gmail.com>
2021-11-03 11:21:58 +02:00