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

276 commits

Author SHA1 Message Date
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
4cfb3203f6 source: fix gofmt errors
The tool got pickier with golang v1.17.
2021-10-22 12:01:31 +03:00
David Gray
3d9b18b087 Trim single quotes in parseOSRelease
Signed-off-by: David Gray <dagray@redhat.com>
2021-09-22 15:04:44 -04:00
Kubernetes Prow Robot
9cf732b64e
Merge pull request #602 from marquiz/devel/go-generate
Utilize go generate
2021-09-21 06:16:24 -07:00
Kubernetes Prow Robot
064391f310
Merge pull request #601 from marquiz/devel/feature-source-interface
source: introduce FeatureSource interface
2021-09-21 05:48:25 -07:00
Markus Lehtonen
51c0d70383 Update auto-generated code
Generated by running "make generate".
2021-09-21 13:37:36 +03:00
Markus Lehtonen
9487fbeb18 Utilize go generate
Use 'go generate' for auto-generating code. Drop the old 'mock' and
'apigen' makefile targets. Those are replaced with a single
  make generate

which (re-)generates everything.
2021-09-21 13:36:37 +03:00
Francesco Romani
b4c92e4eed topologyupdater: Bootstrap nfd-topology-updater in NFD
- This patch allows to expose Resource Hardware Topology information
  through CRDs in Node Feature Discovery.
- In order to do this we introduce another software component called
  nfd-topology-updater in addition to the already existing software
  components nfd-master and nfd-worker.
- nfd-master was enhanced to communicate with nfd-topology-updater
  over gRPC followed by creation of CRs corresponding to the nodes
  in the cluster exposing resource hardware topology information
  of that node.
- Pin kubernetes dependency to one that include pod resource implementation
- This code is responsible for obtaining hardware information from the system
  as well as pod resource information from the Pod Resource API in order to
  determine the allocatable resource information for each NUMA zone. This
  information along with Costs for NUMA zones (obtained by reading NUMA distances)
  is gathered by nfd-topology-updater running on all the nodes
  of the cluster and propagate NUMA zone costs to master in order to populate
  that information in the CRs corresponding to the nodes.
- We use GHW facilities for obtaining system information like CPUs, topology,
  NUMA distances etc.
- This also includes updates made to Makefile and Dockerfile and Manifests for
  deploying nfd-topology-updater.
- This patch includes unit tests
- As part of the Topology Aware Scheduling work, this patch captures
  the configured Topology manager scope in addition to the Topology manager policy.
  Based on the value of both attribues a single string will be populated to the CRD.
  The string value will be on of the following {SingleNUMANodeContainerLevel,
  SingleNUMANodePodLevel, BestEffort, Restricted, None}

Co-Authored-by: Artyom Lukianov <alukiano@redhat.com>
Co-Authored-by: Francesco Romani <fromani@redhat.com>
Co-Authored-by: Talor Itzhak <titzhak@redhat.com>
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2021-09-21 10:47:39 +01:00
Markus Lehtonen
852cf4b61d source: introduce FeatureSource interface
Specify a new interface for managing "raw" feature data. This is the
first step to separate raw feature data from node labels. None of the
feature sources implement this interface, yet.

This patch unifies the data format of "raw" features by dividing them
into three different basic types.
- keys, a set of names without any associated values, e.g. CPUID flags
  or loaded kernel modules
- values, a map of key-value pairs, for features with a single value,
  e.g. kernel config flags or os version
- instances, a list of instances each of which has multiple attributes
  (key-value pairs of their own), e.g. PCI or USB devices

The new feature data types are defined in a new "pkg/api/feature"
package, catering decoupling and re-usability of code e.g. within future
extentions of the NFD gRPC API.

Rename the Discover() method of LabelSource interface to GetLabels().
2021-09-20 09:58:07 +03:00
Markus Lehtonen
81378a3235 source: make sources register themselves
Implement new registration infrastructure under the "source" package.
This change loosens the coupling between label sources and the
nfd-worker, making it easier to refactor and move the code around.

Also, create a separate interface (ConfigurableSource) for configurable
feature sources in order to eliminate boilerplate code.

Add safety checks to the sources that they actually implement the
interfaces they should.

In sake of consistency and predictability (of behavior) change all
methods of the sources to use pointer receivers.

Add simple unit tests for the new functionality and include source/...
into make test target.
2021-09-15 18:41:37 +03:00
Markus Lehtonen
befa7e9796 source: rename FeatureSource to LabelSource
Prepare for separating feature detection from label creation.
2021-09-13 22:48:33 +03:00
Markus Lehtonen
bd5ee9c616 source/network: silence annoying/useless log message
However, log an error if something unexpected happens, i.e. the file to
read maximum number of vfs exists (sriov_totalvfs) but read fails.
2021-09-13 09:40:06 +03:00
Kubernetes Prow Robot
e16d4c9b20
Merge pull request #543 from marquiz/devel/custom-kconfig-refactor
source/custom: refactor kconfig rule internal representation
2021-08-24 06:45:14 -07:00
Jan Schintag
ac0e5b1b52 cstate/pstate: Skip check on non intel arches
Intel driver is not available on other arches, skip check.

Signed-off-by: Jan Schintag <jan.schintag@de.ibm.com>
2021-08-19 16:37:54 +02:00
Markus Lehtonen
43e0f83940 source/cpu: better error reporting
Drop confusing errors in the log when intel pstate or cstate driver is
not enabled in the system. However, we still log an error if sysfs is
not available at all, in which case we're not able to detect these
correctly.
2021-08-13 09:16:03 +03:00
Markus Lehtonen
73704e2e11 source/kernel: better error reporting
Get rid of distracting error in the log in case selinux is not enabled
in the kernel. Still print an error only if sysfs/fs directory is not
available, though, which indicates that we're not able to correctly
detect the presence of selinux.
2021-08-13 09:13:19 +03:00
Markus Lehtonen
a55783d533 Straighten wrinkles in lint fixes
Fix small mistakes that slipped through with lint fixes (in
1230945564).
2021-07-07 14:32:11 +03:00
Markus Lehtonen
aca9e3efb8 source/custom: refactor kconfig rule internal representation
Use a more well-defined form with separate key and value fields.
2021-07-07 10:43:25 +03:00
Kubernetes Prow Robot
6e039818eb
Merge pull request #538 from ArangoGutierrez/devel/go_report
make go report happy
2021-07-06 23:50:43 -07:00
Markus Lehtonen
31bd91988f cpuid: correct the name of SSE4* cpuid flags
The naming was changed in when with cpuid v2
(github.com/klauspost/cpuid/v2) and we didn't catch this in NFD. No
issue reports of the inadvertent naming change so let's just adapt to
the updated naming in NFD configuration. The SSE4* labels are disabled
by default so they're not widely used, if at all.
2021-07-06 11:54:55 +03:00
Carlos Eduardo Arango Gutierrez
1230945564
make golint happy
Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
2021-06-14 12:27:58 -05:00
Carlos Eduardo Arango Gutierrez
894b7901ff
make gofmt happy by running gofmt -s
Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
2021-06-14 12:24:44 -05:00
Markus Lehtonen
610b1c696c source: define source names as consts
Paves the way for future work on more general representation of
feature data and looser coupling of the data and feature source
interface.
2021-06-11 15:29:57 +03:00
Jorik Jonker
d857f88d2d Add support for using USB device serial number
In my homelab, I have different FTDI serial converters connected to
several utility meters. They all have identical vendor/device, but
different serials.

In order to detect a specific FTDI unit (eg.  the one connected to my
electricity meter), I'd like feature labels triggered by a specific USB
serial.

Signed-off-by: Jorik Jonker <jorik@kippendief.biz>
2021-05-06 13:34:39 +00:00
Jan Schintag
5871207588 Mount /usr/lib and /usr/src inside the Pod
Mount /usr/lib and /usr/src as /host-usr/lib and /host-usr/src inside the pod
to allow NFD to search for the kernel configuration file inside /usr.
This solves the problem of the kernel config file not being present in /boot
on s390x RHCOS.

Signed-off-by: Jan Schintag <jan.schintag@de.ibm.com>
2021-04-26 16:47:37 +02:00
Markus Lehtonen
011954e4c4 source/custom: dump config in more human-readable form
Also, increase the verbosity level to 2 because this can produce quite a
bunch of log message lines.
2021-03-16 07:06:28 +02:00
Kubernetes Prow Robot
e0d700d378
Merge pull request #463 from bfournie/new_cpu_features
Support for additional cpu features
2021-03-11 07:30:21 -08:00
Bob Fournier
a65f73e834 Support for additional cpu features
This adds additional cpu features:
- pstate status from status of intel_pstate driver
- pstate scaling settings from scaling_governor
- cstate enable from max_cstates in intel_idle driver
2021-03-05 13:15:49 -05:00
Kubernetes Prow Robot
f8ad566e91
Merge pull request #459 from marquiz/fixes/cleanup
source: drop stale BoolFeatureValue type
2021-03-01 08:17:26 -08:00
Carlos Eduardo Arango Gutierrez
389a8f87cf
logging: start log messages with lower case
Standarize logs to be lower case.

Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
2021-03-01 10:07:21 -05:00
Markus Lehtonen
1f819173d0 source: drop stale BoolFeatureValue type 2021-03-01 13:51:04 +02:00
Markus Lehtonen
5e6f0779e9 nfd-worker: stop masking crashes in feature discovery
The code should be stable enough. If there are fatal bugs causing the
discovery to panic/segfault that should be made visible instead of
semi-siently hiding it. Also, this caused one (negative) test case to
fail undetected which is now fixed.
2021-03-01 09:14:19 +02:00
Markus Lehtonen
7da7fde8f6 nfd-worker: switch to klog
Greatly expands logging capabilities and flexibility with verbosity
options, among other things.
2021-02-25 16:10:43 +02:00
Marc Sluiter
7038e49d02
source/custom: Add nodename rule
There are cases when the only available metadata for discovering
features is the node's name. The "nodename" rule extends the custom
source and matches when the node's name matches one of the given
nodename regexp patterns.
It is also possible now to set an optional "value" on custom rules,
which overrides the default "true" label value in case the rule matches.
In order to allow more dynamic configurations without having to modify
the complete worker configuration, custom rules are additionally read
from a "custom.d" directory now. Typically that directory will be filled
by mounting one or more ConfigMaps.

Signed-off-by: Marc Sluiter <msluiter@redhat.com>
2021-02-24 16:26:35 +01:00
Markus Lehtonen
278ccdb997 source/fake: make the fake source configurable
Enables more flexible testing.
2021-02-17 21:50:58 +02:00
Mikko Ylinen
07bc50d5a8 go.mod: update to klauspost/cpuid/v2@v2.02
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2020-12-15 15:56:15 +02:00
Mikko Ylinen
94f49b9418 go.mod: update klauspost/cpuid
The latest changes in klauspost/cpuid add detection for Sapphire Rapids
new instructions.

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2020-11-30 19:04:41 +02:00
Markus Lehtonen
ba4ecfe7dc kernel: more agressively sanitize full kernel version
Trim illegal characters from the beginning and end of the kernel version
string. Label values must start and end with an alphanumeric and we want
to have some 'version.full' label, even if a sanitized one.
2020-11-23 19:04:12 +02:00
Mikko Ylinen
e2ee7c6fca source/custom: add rules for cpuid and kconfig
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2020-09-14 12:07:35 +03:00
Mikko Ylinen
d1cce3ba29 source/custom: do not return on rule errors
Skip to the next rule instead of returning immediately on
rule errors. For instance, if the static rules failed, user
provided rules would never be processed.

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2020-09-14 12:07:35 +03:00
Mikko Ylinen
8b156d49fc source/kernel: add internal helper to get kernel version
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2020-09-14 12:07:35 +03:00
Mikko Ylinen
aeb7583315 source/kernel: move kconfig to a shared internal package
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2020-09-14 12:07:33 +03:00
Mikko Ylinen
3fd314b600 source/kernel: add more search paths
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2020-09-14 12:06:23 +03:00
Mikko Ylinen
109da6c980 source/cpu: move cpuid code to a shared internal package
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2020-09-14 10:32:04 +03:00
Kubernetes Prow Robot
59a88b07e1
Merge pull request #322 from adaptant-labs/cpuid-arm
cpu: Add support for ARM/Aarch32 cpuid
2020-05-24 23:35:11 -07:00
Paul Mundt
4d5b5974df cpu: Add support for ARM/Aarch32 cpuid
This provides support for 32-bit ARM cpuid capabilities based on
the HWCAP flags, and enables the build of NFD on the 32-bit ARM
userland - notably, this also applies to ARM64 systems that are
running userspace in Aarch32 mode, which is where this problem
was first encountered.

Signed-off-by: Paul Mundt <paul.mundt@adaptant.io>
2020-05-21 19:42:44 +02:00
Markus Lehtonen
d216fca1c0 source/network: run discovery under host sysfs
Instead of relying on golang "net" package, use the configured host
sysfs for all discovery. No need to use hostNetwork after that so drop
it from the worker deployment templates.
2020-05-21 20:33:30 +03:00
Markus Lehtonen
a2b9df5cd3 nfd-worker: rework configuration handling
Extend the FeatureSource interface with new methods for configuration
handling. This enables easier on-the fly reconfiguration of the
feature sources. Further, it simplifies adding config support to feature
sources in the future. Stub methods are added to sources that do not
currently have any configurability.

The patch fixes some (corner) cases with the overrides (--options)
handling, too:
- Overrides were not applied if config file was missing or its parsing
  failed
- Overrides for a certain source did not have effect if an empty config
  for the source was specified in the config file. This was caused by
  the first pass of parsing (config file) setting a nil pointer to the
  source-specific config, effectively detaching it from the main config.
  The second pass would then create a new instance of the source
  specific config, but, this was not visible in the feature source, of
  course.
2020-05-21 00:59:37 +03:00
Markus Lehtonen
67d7887949 source: perform all sysfs discovery under host sysfs
Be consistent and do all sysfs based feature discovery under the same
sysfs directory.
2020-05-20 22:15:41 +03:00
Markus Lehtonen
248859c64d source: parametrise host directory paths
Specify and handle system paths we use for discovery in a unified way.
2020-05-20 22:15:41 +03:00
Markus Lehtonen
640dc9fbf3 source: miscellaneous lint fixes 2020-05-20 21:48:06 +03:00
Markus Lehtonen
057f31d7e3 fsource/local: lint fixes 2020-05-20 21:48:06 +03:00
Markus Lehtonen
a65d05bd9c source/panic_fake: rename module to make lint happy 2020-05-20 21:48:06 +03:00
Markus Lehtonen
80becea590 source/custom: make linter happy
Might not agree with all that naming arbitrariness but it's easier just
to bend over.
2020-05-20 21:48:06 +03:00
Kubernetes Prow Robot
67b3da2f31
Merge pull request #314 from marquiz/devel/gofmt
Check gofmt
2020-05-20 09:42:19 -07:00
Kubernetes Prow Robot
1ba75bfd7c
Merge pull request #310 from adaptant-labs/usb-discovery
Add support for USB device discovery
2020-05-20 08:26:19 -07:00
Paul Mundt
c0ea69411b usb: Add support for USB device discovery
This builds on the PCI support to enable the discovery of USB devices.

This is primarily intended to be used for the discovery of Edge-based
heterogeneous accelerators that are connected via USB, such as the Coral
USB Accelerator and the Intel NCS2 - our main motivation for adding this
capability to NFD, and as part of our work in the SODALITE H2020
project.

USB devices may define their base class at either the device or
interface levels. In the case where no device class is set, the
per-device interfaces are enumerated instead. USB devices may
furthermore have multiple interfaces, which may or may not use the
identical class across each interface. We therefore report device
existence for each unique class definition to enable more fine-grained
labelling and node selection.

The default labelling format includes the class, vendor and device
(product) IDs, as follows:

	feature.node.kubernetes.io/usb-fe_1a6e_089a.present=true

As with PCI, a subset of device classes are whitelisted for matching.
By default, there are only a subset of device classes under which
accelerators tend to be mapped, which is used as the basis for
the whitelist. These are:

	- Video
	- Miscellaneous
	- Application Specific
	- Vendor Specific

For those interested in matching other classes, this may be extended
by using the UsbId rule provided through the custom source. A full
list of class codes is provided by the USB-IF at:

	https://www.usb.org/defined-class-codes

For the moment, owing to a lack of a demonstrable use case, neither
the subclass nor the protocol information are exposed. If this
becomes necessary, support for these attributes can be trivially
added.

Signed-off-by: Paul Mundt <paul.mundt@adaptant.io>
2020-05-20 16:18:39 +02:00
Markus Lehtonen
1a2f54367e source/cpu: mangle through gofmt 2020-05-19 14:28:07 +03:00
Pablo Rodriguez
3c81ff9d80 kernel.go: Replace forbidden symbols
Some Kernel versions include symbols such as "+".
Yocto L4T kernel is an example of this behaviour.
To fix this error all unknown symbols are replaced by an underscore.

Signed-off-by: Pablo Rodriguez <paroque28@gmail.com>
2020-05-15 17:58:08 +00:00
Kubernetes Prow Robot
b8a7a6c927
Merge pull request #299 from marquiz/devel/os-release
source/system: do not publish empty version labels
2020-04-23 05:45:45 -07:00
Markus Lehtonen
674c9f71ed source/cpu: drop leftover debug print 2020-04-22 21:29:19 +03:00
Markus Lehtonen
fbf0b07525 source/custom: gofmt fix 2020-04-22 21:28:02 +03:00
Markus Lehtonen
9eb98040e9 source/system: do not publish empty version labels
Do not publish non-existing version components as empty labels.
2020-03-20 10:16:01 +02:00
Adrian Chiris
e4e3a9f68e Implement the 'custom' feature Source
- Implement the 'custom' feature source utilizing the
  match rules implemented in previous commit.

- Add a static custom feature list for:
  1. rdma.capable - marks a node where devices that support
     RDMA are present.
  2. rdma.enabled - marks a node where rdma modules have
     been loaded.
  A user may extend these features with additional match rules via
  NFD configuration file.
2020-03-19 09:31:59 +02:00
Adrian Chiris
b9ab93559b Add Match Rules package to be used in Custom Source
- Add a Rule interface to help describe the contract
  between a match rule and the Custom source that uses it.

- Add PciIdRule - a rule that matches on the PCI attributes:
  class, vendor, device. Each is provided as a list of elements(strings).
  Match operation: OR will be performed per element and AND will be
  performed per attribute.
  An empty attribute will not be included in the matching process.
  Example:
  {
    "class": ["0200"]
    "vendor": ["15b3"]
    "device": ["1014", "1016"]
  }

- Add LoadedKmodRule - a rule that matches a list of kernel
  modules with the kernel modules currently loaded in the node.
  Example:
  {
    ["rdma_cm", "ib_core"]
  }
2020-03-17 18:00:05 +02:00
Adrian Chiris
0cfe03012b Add new feature Source - Custom with stubbed implementation 2020-03-12 15:15:16 +02:00
Adrian Chiris
a1a2429df1 Move PCI introspection logic to its own internal package
This will enable code reuse across sources while preventing
packages which are not under 'source' to import it.

subsequent commits will introduce the 'custom' source which
will use the logic.
2020-03-12 15:09:27 +02:00
Mikko Ylinen
24c3a98303 pci: add sriov.capable attribute
SR-IOV is a PCI attribute and also non-NIC PCI devices can have it. Therefore,
it is useful to label all PCI devices with that capability.

After this commit the following labels for Intel NICs are overlapping:
feature.node.kubernetes.io/pci-0200_8086.sriov.capable=true
feature.node.kubernetes.io/network-sriov.capable=true

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2020-02-18 20:09:32 +02:00
Antti Kervinen
d3d13347f8 vendor: update klauspost/cpuid
Update cpuid from v1.2.2 to v1.2.3. Brings in SGX improvements and
CPUID leaf 7 feature detection (VBMI2, VPOPCNTDQ, GFNI, VAES,
AVX512BITALG, VPCLMULQDQ, AVX512BF16, AVX512VP2INTERSECT). Blacklist
cpuid-SGX* (issue #130).

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
2020-01-29 14:51:44 +02:00
Markus Lehtonen
882bbeea3f source/cpu: support 'false' status of cpu-pstate.turbo
Some workloads may benefit from Intel Turbo Boost technology being
disabled. This patch sets the
'feature.node.kubernetes.io/cpu-pstate.turbo' label to 'false' if we can
detect that it has been disabled. If detection fails no label is
published.
2019-08-29 16:18:12 +03:00
Yaakov Selkowitz
8d97ad9cad source/cpu: disable intel_pstate detection on non-x86 architectures 2019-08-28 07:53:31 -04:00
Yaakov Selkowitz
fe4421af65 source/cpu: add IBM Z CPU support to cpuid 2019-08-28 07:53:22 -04:00
Yaakov Selkowitz
81494f1883 source/cpu: add IBM Power CPU support to cpuid 2019-08-28 07:53:10 -04:00
Markus Lehtonen
012f7e4946 source/memory: detect NVDIMM DAX mode
Extend NVDIMM (non-volatile DIMM) discovery by adding detection of DAX
mode, i.e. detection of regions in DAX/AppDirect mode.
The new label is:
    feature.node.kubernetes.io/memory-nv.dax: true
2019-06-11 09:58:30 +03:00
Markus Lehtonen
6002a00750 kernel: fix undefined symbol error
Fix a build failure that slipped through when adding support for
non-binary kconfig options in #197,
2019-06-10 15:25:41 +03:00
Kubernetes Prow Robot
8c666cbdc2
Merge pull request #197 from marquiz/devel/kconfig
Support non-binary kconfig options in kernel feature source
2019-06-07 11:44:00 -07:00
Kubernetes Prow Robot
8996be7e09
Merge pull request #231 from Ethyling/change-label-prefix
Allow to change labels namespace
2019-05-14 07:43:13 -07:00
Markus Lehtonen
88f694a177 cpu: remove unused import from cpuid_arm64 2019-05-13 17:17:02 +03:00
Markus Lehtonen
7c5f7d600e source/cpu: make cpuid configurable
Add 'cpuid/attributeBlacklist' and 'cpuid/attributeWhitelist' config
options for the cpu feature source. These can be used to filter the set
of cpuid capabilities that get published. The intention is to reduce
clutter in the NFD label space, getting rid of "obvious" or misleading
cpuid labels. Whitelisting has higher priority, i.e.  only whitelist
takes effect if both attributeWhitelist and attributeBlacklist are
specified.
2019-05-13 17:17:02 +03:00
Jordan Jacobelli
40918827f6
Allow to change labels namespace
The aim here is to allow to override the default namespace
of NFD. The allowed namespaces are whitelisted.
See https://github.com/kubernetes-sigs/node-feature-discovery/issues/227

Signed-off-by: Jordan Jacobelli <jjacobelli@nvidia.com>
2019-05-09 13:17:52 -07:00
Markus Lehtonen
655f5c5555 sources: move all cpu related features under the cpu source
Remove 'cpuid', 'pstate' and 'rdt' feature sources and move their
functionality under the 'cpu' source. The goal is to have a more
systematic organization of feature sources and labels. After this change
we now basically have one source per type of hw, one for kernel and one
for userspace sw.

Related feature labels are changed, correspondingly, new labels being:
    feature.node.k8s.io/cpu-cpuid.<cpuid flag>
    feature.node.k8s.io/cpu-pstate.turbo
    feature.node.k8s.io/cpu-rdt.<rdt feature>
2019-05-09 20:18:36 +03:00
Markus Lehtonen
d4cb0e742b Use standard logger for all feature sources 2019-04-25 17:17:41 +03:00
Markus Lehtonen
0c8fe34163 Drop glog based logging
Simplify logging of feature sources. Glog was used in some feature
sources, but, it was too complicated for the simple logging needs of
NFD.
2019-04-25 17:14:58 +03:00
Markus Lehtonen
ad17e5088b source/cpu: detect SST-BF
Detect of the Intel SST-BF (Speed Select Technology - Base Frequency)
has been enabled.

Adds one new feature label:
  feature.node.kubernetes.io/cpu-power.sst_bf.enabled=true

Based on a patch from kuralamudhan.ramakrishnan@intel.com
2019-04-12 15:11:55 +03:00
Markus Lehtonen
86382afe56 Re-factor cpuid functionality out of source/rdt
Move the cpuid functionality into a separate library package so that it
can be easily re-used by other sources.
2019-04-12 14:36:08 +03:00
Markus Lehtonen
12d6c2410e Re-generate mock sources
Add a new Makefile target for regenerating these files.  Also, add a
note that the files are auto-generated, including instructions how to
re-generate them.

Renames the mock files, using the defaults provided by the mockery tool,
in order to make their generation easier.
2019-04-04 22:40:24 +03:00
Jordan Jacobelli
00f96c69d7 Allow to get labels by reading files in local source
The aim here is to add another way to specify labels using the local
source by reading files in a specific directory. That avoids us to
execute a hook when we just need to get the content of a file.
See https://github.com/kubernetes-sigs/node-feature-discovery/issues/226

Signed-off-by: Jordan Jacobelli <jjacobelli@nvidia.com>
2019-04-03 09:26:40 -07:00
Markus Lehtonen
3e8217e9ef source/memory: detect presence of NVDIMM devices
Add a new (binary) label indicating the presence of non-volatile DIMM
devices:
  feature.node.kubernetes.io/memory-nv.present
2019-03-19 09:38:30 +02:00
Markus Lehtonen
c52d01a6cb source/memory: refactor numa detection into a separate func 2019-03-19 09:38:30 +02:00
Markus Lehtonen
e866b6ee1c Implement RDT detection in go
Get rid of the dependency on intel-cmt-cat library and rdt helper
binaries written in C. Significantly simplifies the build procedure.

Implements minimal support (in assembler) for getting the raw data from
the CPUID instruction. Also, implement a stub so that the code works on
other architectures than amd64, too.
2019-02-22 22:23:13 +02:00
Markus Lehtonen
eeed6d14b1 Support non-binary kconfig options in kernel feature source
Discover other than bool or tristate kconfig options, too. For bool and
tristate the node label is still binary (i.e. set to "true" if the
kconfig option has been enabled). For other kconfig types (e.g. string
or int) the value of the label directly corresponds to the value of the
kconfig flag, e.g. "32", "elf64-x86-64" etc.
2019-02-22 22:15:25 +02:00
Markus Lehtonen
af22702b93 source/system: advertise major and minor OS version
Add two new attributes 'VERSION_ID.major' and 'VERSION_ID.minor' to the
os_release feature. These represent the first two components of
the OS version (version components are assumed to be separated by a
dot). E.g. if VERSION_ID would be 1.2.rc3 major and minor versions would
be 1 and 2, respectively:
  feature.node.kubernetes.io/system-os_release.VERSION_ID=1.2.rc3
  feature.node.kubernetes.io/system-os_release.VERSION_ID.major=1
  feature.node.kubernetes.io/system-os_release.VERSION_ID.minor=2

The version components must be purely numerical in order for them to be
advertised. This way they can be fully (and reliably) utilized in
nodeAffinity, including relative (Gt and Lt) operators.
2019-02-13 20:45:13 +02:00
Markus Lehtonen
e8249e6fa3 Move selinux detection to kernel feature source
Remove the 'selinux' feature source and move the functionality under the
'kernel' feature source. The selinux feature label is changed to
  feature.node.kubernetes.io/selinux.enabled

The selinux feature source was rather narrow in scope, and, the sole
feature it advertised naturally falls under the kernel feature source.
2019-01-03 10:08:28 +02:00
Markus Lehtonen
da2cb07c64 Implement cpu feature source
Currently, it only detects one feature, i.e. hardware multithreading
(such as Intel hyper-threading technology). The corresponding feature
label is:
  feature.node.kubernetes.io/cpu-hardware_multithreading=true

However, this (architecture/platform dependent) feature is not detected
directly, and, the heuristics can be mislead. Detection works by
checking the thread siblings of each logical (and online) cpu in the
system. If any cpu has any thread siblings the feature label is set to
true. Thus, hardware multithreading could be effectively disabled e.g.
by putting all sibling cpus offline (even if the technology would be
enabled in hardware).
2018-12-07 16:58:09 +02:00
Markus Lehtonen
649d8a3ae1 Implement OS release detection
Implement new 'system' feature source. It now detects OS release
information from the os-release file, assumed to be available at
/host-etc/os-release. It currently creates two labels (assuming that the
corresponding fields are found in the os-release file), with example
values:
  feature.node.kubernetes.io/system-os_release.ID=opensuse
  feature.node.kubernetes.io/system-os_release.VERSION_ID=42.3

Also, update the template spec to mount /etc/os-release file from the
host inside the container.
2018-12-05 14:42:38 +02:00
Bin Lu
1ccd69e6e3 Add ARM64 support to cpuid
Signed-off-by: Bin Lu <bin.lu@arm.com>
2018-12-05 10:13:24 +02:00
Markus Lehtonen
47a97db35a Import from sigs.k8s.io/node-feature-discovery 2018-12-04 15:15:46 +02:00
Markus Lehtonen
4053010dd9 Make the kernel feature source configurable
Adding two config options:
- kernel config file to read
- kconfig options that are detected
2018-12-04 09:34:56 +02:00
Markus Lehtonen
ce129aef88 Implement kernel config detection
This implementation only detects kconfig options ("NO_HZ", "NO_HZ_IDLE",
"NO_HZ_FULL" and "PREEMPT"). The corresponding node labels will be
  node.alpha.kubernetes-incubator.io/nfd-kernel-config.<option name>

Currently, only bool and tristate (i.e. '=y' or '=m') kernel config
options are supported. Other kconfig types (e.g. string or int) are
simply ignored. If the kconfig flag is set to '=y' or '=m', the
corresponding node label will be present and it's value will be 'true'.
2018-12-04 09:34:56 +02:00
Markus Lehtonen
5af04ca3f6 source/local: allow full control of label name
Make it possible for the hooks to fully define the label name to be used
(i.e. without the '<hook name>-' prefix) by prefixing the printed
feature names with a slash ('/'). This makes it possible to e.g.
override labels create by other sources.

For example having the following output from a hook:
/override_source-override_bool
/override_source-override_value=my value

will translate into the following feature labels:
feature.node.kubernetes.io/override_source-override_bool = true
feature.node.kubernetes.io/override_source-override_value = my value
2018-11-30 11:51:41 +02:00
Markus Lehtonen
4b066ed815 source/local: support non-binary labels
Make the feature detector hooks, run by the 'local' feature source,
support non-binary label values. Hooks can advertise non-binary value by
using <name>=<value> format.

For example, /etc/kubernetes/node-feature-discovery/source.d/myhook
having the following stdout:
LABEL_1
LABEL_2=foobar

Would translate into the following labels:
feature.node.kubernetes.io/myhook-LABEL_1 = true
feature.node.kubernetes.io/myhook-LABEL_2 = foobar
2018-11-30 11:51:41 +02:00
Markus Lehtonen
a84b5c9d82 Support feature detector hooks
Implement a new feature source named 'local' whose only purpose is to
run feature source hooks found under
/etc/kubernetes/node-feature-discovery/source.d/ It tries to execute all
files found under the directory, in alphabetical order.

This feature source provides users a mechanism to implement custom
feature sources in a pluggable way, without modifying nfd source code or
Docker images.

The hooks are supposed to print all discovered features in stdout, one
feature per line. The output in stdout is used in the node label as is.
Full node label name will have the following format:
  feature.node.kubernetes.io/<hook name>-<feature name>
Stderr from the hooks is propagated to nfd log.
2018-11-30 11:51:41 +02:00
Markus Lehtonen
86947fc16b Implement kernel version detection
Add a new 'kernel' feature source, detecting the kernel version. The
kernel version is split into multiple labels in order to make this more
usable in label selectors. Kernel version in the format X.Y.Z-patch will
be presented as
  node.alpha.kubernetes-incubator.io/nfd-kernel-version.full=X.Y.Z-patch
  node.alpha.kubernetes-incubator.io/nfd-kernel-version.major=X
  node.alpha.kubernetes-incubator.io/nfd-kernel-version.minor=Y
  node.alpha.kubernetes-incubator.io/nfd-kernel-version.revision=Z

The '.full' label will always be avaiable. The other labels if these
components can be parsed from the kernel version number.
2018-10-10 13:21:49 +03:00
Markus Lehtonen
56c2ab3d58 Support for non-binary labels
Make it possible to advertise also other than simple 'true' values for
feature labels.
2018-10-10 13:21:49 +03:00
Markus Lehtonen
b0fedab786 sources/pci: make device label format configurable
Add new config option for specifying the device label, i.e. the
<device-label> part in
    node.alpha.kubernetes-incubator.io/nfd-pci-<device label>.present

The option is a list of field names:
    "class"             PCI device class
    "vendor"            Vendor ID
    "device"            Device ID
    "subsystem_vendor"  Subsystem vendor ID
    "subsystem_device"  Subsystem device ID

E.g. the following command line flag can be used to use all of the
above:
  --options='{"sources": {"pci": {"deviceLabelFields": ["class", "vendor", "device", "subsystem_vendor", "subsystem_device"] } } }'
2018-10-10 12:36:20 +03:00
Markus Lehtonen
b0d0797936 Add config support for the pci feature source
User can now configure the list of device classes to detect, either via
a configuration file or by using the --options command line flag.

An example of a command line flag to detect all network controllers and
("main class 0x02) and VGA display controllers ("main" class 0x03 and
subclass 0x00) would be:
  --options='{"sources": {"pci": {"deviceClassWhitelist": ["02", "0300"] } } }'
2018-10-10 12:36:20 +03:00
Markus Lehtonen
74d6993e9b Implement PCI feature source
This feature source detects the presence of PCI devices. At the moment,
it only advertises GPUs and accelerator cards, i.e. device classes 0x03,
0x0b40 and 0x12.

The label format is:
  node.alpha.kubernetes-incubator.io/nfd-pci-<device label>.present
where <device label> is composed of raw PCI IDs:
  <class id>_<vendor id>
2018-10-10 12:36:20 +03:00
Markus Lehtonen
4fa7ae38e3 network: rename sriov labels
Introduce a new scheme where features may have logical sub-components.
Rename sriov labels from the network source according to the new
pattern:
  sriov            -> sriov.capable
  sriov-configured -> sriov.configured

Also, document this new labeling scheme in the README.

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
2018-10-03 15:25:58 +03:00
Rui Cao
4bab607b82 Fix typo: suppported -> supported
Signed-off-by: Rui Cao <ruicao@alauda.io>
2018-10-02 17:14:03 +03:00
Bin Lu
db929b878b Skip pstate detection on Arm
Signed-off-by: Bin Lu <bin.lu@arm.com>
2018-08-17 11:10:18 +03:00
Markus Lehtonen
175305b1ad Implement detection of IOMMU (#136) (#137)
* Arrange feature sources alphabetically

Just a cosmetic change, but, a small readability improvement.

* Implement detection of IOMMU (#136)

Add a new feature source, i.e. 'iommu', which detects if an IOMMU is
present and enabled in the kernel. The new node label is
  node.alpha.kubernetes-incubator.io/nfd-iommu-present
2018-07-24 08:24:45 -07:00
Olev Kartau
e984154090 Added more Intel RDT capability discovery: CMT,MBM,MBA (#120)
Added Memory Bandwith Allocation (MBA) capability discovery.
Refined RDT monitoring capability detection;
Cache Monitoring Technology (CMT) and
Memory Bandwidth Monitoring (MBM)
capabilities can be detected separately.
2018-05-24 16:49:00 -07:00
Naga Ravi Chaitanya Elluri
60de66fc03 Advertise selinux status by adding labels
This commit:
- enables node-feature-dicovery to advertise selinux status
  on the node by adding a label.

- update the template to mount /sys into the container, this is
  needed to know about the selinux status on the host

- adds selinux source for unit tests
2018-04-09 16:13:45 -04:00
Olev Kartau
00615be083 Add memory source and NUMA detection.
If multiple nodes are marked online in
/sys/devices/system/node/online, it's a sign of NUMA
architecture. Mark it using nfd-memory-numa label.
2018-03-29 09:43:42 +03:00
Olev Kartau
e22ae236cd Added nonrotational storage detection
This change adds feature source "storage".
Add label if any non-rotational block device is present in the node.
The label will be: nfd-storage-nonrotationaldisk=true
2018-03-27 14:30:27 +03:00
Markus Lehtonen
348f3a7f89 Remove hardcoding of nfd source path (#94)
* Make rdt-discovery buildable outside hardcoded path

Do not assume that nfd sources always reside under hardcoded directory
"/go/src/github.com/kubernetes-incubator/node-feature-discovery/". This
makes it possible e.g. to build nfd locally outside the Docker
container.

* Do not hardcode the path for RDT helper binaries

Utilize the standard PATH env variable, instead.
2018-03-16 09:56:35 -07:00
Olev Kartau
15559903a0 Improve GoReportCard metrics, both gofmt and golint (#90)
* Format main,fake,network go source to improve GoReportCard

Order of import changed in main.go and network.go,
missing ending newline added in fake.go

* Fixed simple golint suggestions in multiple files

Mostly about missing or incomplete comments
2018-03-05 07:51:47 -08:00
Markus Lehtonen
b999a1a6f4 Fix unit tests (#98)
* Update unit tests

Make the unit tests pass, again.

* Update project dependencies

* Enable unittests in travis
2018-03-01 10:49:57 -08:00
swatisehgal
41da99a435 Adding SR-IOV capability discovery to node-feature-discovery (#49)
* Adding SR-IOV capability discovery to node-feature-discovery

* SR-IOV capability discovery in NFD : code update after PR review
- using hostnetwork instead of volume mount in file node-feature-discovery-job.json.template
- iterating through network interfaces that are "up" in sources.go
- inserting logs in sources.go
- change in feature source name from "netid" to "network" in sources.go, README.md and main.go

*  Added code for labels sriov=true (sriov_totalvfs > 0) and sriov-configured=true (sriov_numvfs > 0)

* Code Refactored: Added Network package and network.go
2017-11-28 15:47:11 +01:00
Andy Xie
0ea8ff631e refactor sources to source pkg 2017-09-05 21:35:33 -07:00