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

172 commits

Author SHA1 Message Date
Feruzjon Muyassarov
b296bdf0b3 update test functions according to upstream deprecated/removed methods
Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@intel.com>
2022-12-13 12:12:50 +02:00
Feruzjon Muyassarov
409312e111 Bump go.mod k8s.io to 1.26
Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@intel.com>
2022-12-13 12:12:46 +02:00
Markus Lehtonen
f13ed2d91c nfd-topology-updater: update NodeResourceTopology objects directly
Drop the gRPC communication to nfd-master and connect to the Kubernetes
API server directly when updating NodeResourceTopology objects.
Topology-updater already has connection to the API server for listing
Pods so this is not that dramatic change. It also simplifies the code
a lot as there is no need for the NFD gRPC client and no need for
managing TLS certs/keys.

This change aligns nfd-topology-updater with the future direction of
nfd-worker where the gRPC API is being dropped and replaced by a
CRD-based API.

This patch also update deployment files and documentation to reflect
this change.
2022-12-08 11:03:22 +02:00
Markus Lehtonen
42ae216284 test/e2e: no pod restart policy of nfd-worker by default
Fixes stricter API check on daemonset pod spec that started to cause e2e
test failures. RestartPolicyNever that we previously set (by defaylt)
isn't compatible with DaemonSets.
2022-12-01 16:14:11 +02:00
Talor Itzhak
0a06562930 e2e: simplify sleeper pod
Make it more flexiable by allowing modifying both
CPU and memory values, using functional options

Signed-off-by: Talor Itzhak <titzhak@redhat.com>
2022-11-29 14:39:54 +02:00
Talor Itzhak
9c725c378f e2e: separate daemonset functions from pod
The new package should provide pod-related utilities,
hence let's move all the daemonset-related utilities
to their own package as well.

Signed-off-by: Talor Itzhak <titzhak@redhat.com>
2022-11-29 14:39:52 +02:00
Talor Itzhak
6364803b0c e2e: move pod utils to a seperate package
By moving those utils in to a seperate package,
we can make the functions names shorter and clearer.

For example, instead of:
```
testutils.NFDWorkerPod(opts...)
testutils.NFDMasterPod(opts...)
testutils.SpecWithContainerImage(...)
```
we'll have:
```
testpod.NFDWorker(opts...)
testpod.NFDMaster(opts...)
testpod.SpecWithContainerImage(...)
```

It will also make the package more isolated and portable.

Signed-off-by: Talor Itzhak <titzhak@redhat.com>
2022-11-29 13:47:00 +02:00
Markus Lehtonen
6f02ef92de test/e2e: remove dropped -sleep-interval arg
Replace with a ConfigMap-based configuration.
2022-11-29 10:22:48 +02:00
Kubernetes Prow Robot
ef2c498a6f
Merge pull request #966 from k8stopologyawareschedwg/sc_for_master
e2e: add SecurityContext to master
2022-11-24 22:18:04 -08:00
Talor Itzhak
f31b70dce4 e2e: add SecurityContext to master
The master pod need these `SecurityContext` configurations
In order to run inside a namespace with restricted policy

Signed-off-by: Talor Itzhak <titzhak@redhat.com>
2022-11-24 14:48:01 +02:00
Markus Lehtonen
0174a6405b test/e2e: add helper for creating new configmaps
Implement a simple helper for creating a configmap with one key. One key
(one config file) is enough for our current tests.
2022-11-24 10:56:15 +02:00
Markus Lehtonen
1719ce6736 test/e2e: more flexible pod spec generation
Change the pod spec generator functions to accept parameterization in
the form of more generic "mutator functions". This makes the addition of
new test specific pod spec customizations a lot cleaner. Plus, hopefully
makes the code a bit more readable as well.

Also, slightly simplify the SpecWithConfigMap() but dropping one
redundant argument.

Inspired by latest contributions by Talor Itzhak (titzhak@redhat.com).
2022-11-23 09:36:14 +02:00
Talor Itzhak
2896541bf1 e2e: topology-updater: add e2e test for exclude-list feature
Signed-off-by: Talor Itzhak <titzhak@redhat.com>
2022-11-21 21:30:53 +02:00
Talor Itzhak
1385d50222 e2e: topology-updater: decouple configuration from creation
Different tests requires different configuration
of the topology-updater DaemonSet.
Here, we decouple the configuration from the creation part
using `JustBeforeEach` so that each test container
will has its own configuration.

Additional reading:
https://onsi.github.io/ginkgo/#separating-creation-and-configuration-justbeforeeach

Signed-off-by: Talor Itzhak <titzhak@redhat.com>
2022-11-21 14:08:25 +02:00
Talor Itzhak
546d0c3a1b e2e: topologyupdater: wait for deletion
It might take time for the CRD to get deleted
and it might cause some falkiness in the tests.

Now before we create the CRD, we make sure to delete
the old object, wait for it deletion to complete
and only then create a new CRD object.

Signed-off-by: Talor Itzhak <titzhak@redhat.com>
2022-11-21 12:26:42 +02:00
Talor Itzhak
1b6fad6427 e2e: topologyupdater: insert condition check into eventually
We might not get the most updated node topology
resource on the first `GET` call.
Hence, put the whole check inside `Eventually`,
and check for the most updated node topology resource on every
iteration.

Signed-off-by: Talor Itzhak <titzhak@redhat.com>
2022-11-21 12:26:42 +02:00
Talor Itzhak
a65278d890 e2e: podSecurity: adapt PodSecurity constraints
The tested pods have some lax spec wrt security,
hence a restrict podSecurity namespace won't allow running those pods.

In topology-updater tests, the topology-updater pod
needs to run the container as root
so change the namespace podSecurity from restricted to priviliged.

In node-feature-discovery tests, we don't need root access,
so add the required security context configuration.

Signed-off-by: Talor Itzhak <titzhak@redhat.com>
2022-11-21 12:26:36 +02:00
Markus Lehtonen
a32ed5ecb1 test/e2e: fix topologu-updater cmdline args
The -kubelet-config-file flag got renamed to -kubelet-config-uri and the
expected format changed from plain filepath to URI.
2022-11-17 13:53:41 +02:00
Feruzjon Muyassarov
71434a1392 Standardize "k8s.io/api/core/v1" package short name
Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@intel.com>
2022-10-15 02:22:41 +03:00
Feruzjon Muyassarov
e79f09deb2 Error strings should not be capitalized
Error strings should not be capitalized (ST1005) & remove the
redundancy from array, slice or map composite literals.
Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@intel.com>
2022-10-14 15:43:18 +03:00
Markus Lehtonen
6ef6112d58 test/e2e: add tests for NodeFeatureRules
Add tests covering the basic functionality of NodeFeatureRule objects,
covering different feature types ("flag features", "attribute features"
and "instance features") as well as backreferencing (using the output of
previously run rules) and templating. The test relies on the "fake"
feature source and its default configuration.
2022-10-11 17:23:52 +03:00
Kubernetes Prow Robot
37e21bfd37
Merge pull request #891 from marquiz/fixes/e2e-no-config
test/e2e: fix segfault in case no e2e config file is specified
2022-10-10 04:09:20 -07:00
Markus Lehtonen
c1e6b41e56 apis/nfd: move annotation and label consts from nfd-master
Move consts related to NFD annotations and labels from nfd-master to the
api. Makes them more logically accessible for clients.
2022-10-06 11:23:56 +03:00
Markus Lehtonen
02955b57c7 test/e2e: fix segfault in case no e2e config file is specified 2022-09-14 11:00:16 +03:00
Kubernetes Prow Robot
15f0cea172
Merge pull request #888 from marquiz/devel/k8s-1.25
Update kubernetes to v1.25.0
2022-09-13 08:17:05 -07:00
Markus Lehtonen
f21315d85f Update kubernetes registry to registry.k8s.io
Update registry location for non-nfd images.
2022-09-12 11:23:04 +03:00
Markus Lehtonen
c09225f75c test/e2e: drop utils/kubeletconfig.go
The required fix is in kubernetes v1.25.0 so we can drop this local
copy.
2022-09-09 10:55:03 +03:00
Markus Lehtonen
449b0b2199 go.mod: update kubernetes to v1.25.0 2022-09-09 10:55:03 +03:00
Francesco Romani
d70f8c65af test: utils: borrow fixed GetKubeletConfig from k/k
We need this fix https://github.com/kubernetes/kubernetes/pull/110875
to have reliable tests, but up until we can bump the k/k deps to 1.25+,
we can't consume it.

So borrow it from k/k repo for the time being.

Signed-off-by: Francesco Romani <fromani@redhat.com>
2022-08-11 08:53:01 +02:00
Francesco Romani
7d37f72480 e2e: add basic topology updater test
Co-authored-by: Swati Sehgal <swsehgal@redhat.com>
Co-authored-by: Francesco Romani <fromani@redhat.com>
Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2022-08-11 08:53:01 +02:00
Francesco Romani
622adf3863 test: e2e: configurable pull policy
In some cases (CI) it is useful to run NFD e2e tests using
ephemeral clusters. To save time and bandwidth, it is also useful
to prime the ephemeral cluster with the images under test.

In these circumstances there is no risk of running a stale image,
and having a `Always` PullPolicy hardcoded actually makes
the whole exercise null.

So we add a new option, disabled by default, to make the e2e
manifest use the `IfNotPresent` pull policy, to effectively
cover this use case.

Signed-off-by: Francesco Romani <fromani@redhat.com>
2022-08-10 15:06:59 +02:00
Markus Lehtonen
190e3200b1 test/e2e: refactor setup and cleanup 2022-08-09 20:14:41 +03:00
Artyom Lukianov
e169edcb9f Move helpers method to the separate package
Co-Authored-By Francesco Romani <fromani@redhat.com>
Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2022-08-09 13:47:52 +02:00
Kubernetes Prow Robot
3df81d1ace
Merge pull request #827 from marquiz/devel/drop-iommu
Drop the iommu source
2022-07-08 02:01:47 -07:00
Markus Lehtonen
380936e417 test/e2e: change node-specific config to a list
Change the part of the e2e-test configuration that contains
node-specific expected labels and annotations to a list, instead of a
map. This makes the parsing order deterministic and makes it possible to
e.g. have a default at the end of the list that captures "all the rest".
2022-06-30 23:34:22 +03:00
Markus Lehtonen
b8ab0d8a9e test/e2e: update e2e-test example config
Add feature labels that have been added lately.
2022-06-30 14:21:38 +03:00
Markus Lehtonen
60fdad684b test/e2e: fix checking of nfd-master annotation
The test was broken twofold: Firstly, the annotation was not checked at
all because the name of the node where nfd-master is running was not
set. Secondly, the annotation prefix was used incorrectly.
2022-06-29 20:51:26 +03:00
Markus Lehtonen
136c036d4d Drop the iommu source
It was deprecated in v0.10.0.
2022-06-14 15:00:29 +03:00
Markus Lehtonen
d1bd603052 go.mod: bump kubernetes to v1.23.1
Update k/k to the latest release and sync all related dependencies.

Align e2e-tests with changes in the k8s e2e test framework.
2022-01-12 16:43:21 +02:00
Markus Lehtonen
3468e65387 test/e2e: revise usage of nfd command line flags
Use the "single-dash" notation of flags and replace deprecated -sources
with -label-sources.
2021-12-03 10:18:57 +02:00
Markus Lehtonen
f7b2bcc457 Revert "test/e2e: drop /boot mount"
This reverts commit 261ab113bf.
2021-11-23 10:50:20 +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
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
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
c3760fbbab nfd-master: rename LabelNs to FeatureLabelNs 2021-08-10 19:13:08 +03:00
Markus Lehtonen
34050596d7 test/e2e: adapt e2e tests to kubernetes v1.21.2
Mimic SIGDescribe() from upstream k8s e2e tests.
2021-07-06 14:40:29 +03: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
7e6f740c9f test/e2e: make openshift bits optional
Only enabled if OPENSHIFT is specified in the environment when running
make e2e-test, for example:

  $ OPENSHIFT=y make e2e-test
2021-02-25 17:54:07 +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
e52ec3480f nfd-master: implement --instance flag
This can be used to help running multiple parallel NFD deployments in
the same cluster. The flag changes the node annotation namespace to
<instance>.nfd.node.kubernetes.io allowing different nfd-master intances
to store metadata in separate annotations.
2021-02-10 13:48:31 +02:00
Markus Lehtonen
bb1e4c60fb nfd-master: use namespaced label and annotation names internally
For historical reasons the labels in the default nfd namespace have been
internally represented without the namespace part. I.e. instead of
"feature.node.kubernetes.io/foo" we just use "foo". NFD worker uses this
representation, too, both internally and over the gRPC requests. The
same scheme has been used for annotations.

This patch changes NFD master to use fully namespaced label and
annotation names internally. This hopefully makes the code a bit more
understandable. It also addresses some corner cases making the handling
of label names consistent, making it possible to use both "truncated"
and fully namespaced names over the gRPC interface (and in the
annotations).
2020-11-24 12:45:06 +02:00
Markus Lehtonen
0512b06027 test/e2e: fix e2e-config node matching
Pick the correct rule when multiple node rules are present.
2020-11-24 11:35:35 +02:00
Carlos Eduardo Arango Gutierrez
f18884d6fb
Fix a thing or two under test
This patch fix typo in a file name
Updates default image on e2e tests
Adds an extra file that should be ignored to gitignore

Use master instead of versioned tag for default test image
2020-11-20 09:22:29 -05:00
Kubernetes Prow Robot
e850dfce5e
Merge pull request #340 from marquiz/devel/e2e
test/e2e: interpret node names in config as regexps
2020-11-19 13:32:51 -08:00
Markus Lehtonen
0d47a04e3e test/data: update test certs
Make them use SAN (Subject Alternative Name) instead of CN (Common Name)
field. Makes them compatible with golang 1.15 TLS.
2020-11-18 15:54:20 +02:00
Artyom Lukianov
f363ba0e92 Update e2e test to work with updated dependencies
Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
2020-11-18 13:09:13 +02:00
Markus Lehtonen
87c412c48e test/e2e: interpret node names in config as regexps
Interpret node names in the e2e test config as regexps instead of plain
strings. This makes it a lot easier to maintain a config file where
multiple nodes share configuration.
2020-10-22 21:46:29 +03:00
Markus Lehtonen
331f56ecc3 test/e2e: drop hostNetwork from worker pod spec
We don't need or use that anymore.
2020-05-25 16:37:38 +03:00
Markus Lehtonen
ff2c30a63c test/e2e: slightly more informative test output 2020-05-25 16:37:27 +03:00
Markus Lehtonen
00ccbe95bb test/e2e: fail faster waiting on master pod
Reduce timeout from the default 5 minutes to one minute. Error out
faster e.g. if accidentally trying to test a non-existing image.
2020-05-25 13:16:56 +03:00
Markus Lehtonen
2f4e038f10 test/e2e: drop dot imports
Make linter happy.
2020-05-20 21:48:06 +03:00
Markus Lehtonen
73602e8f28 test/e2e: goling fixes 2020-05-20 21:48:06 +03:00
Markus Lehtonen
409dc11389 Switch to sigs.k8s.io/yaml
Replace github.com/ghodss/yaml.
2020-04-23 16:54:14 +03:00
Markus Lehtonen
3d5866a06d test/e2e: more comprehensive per-node testing
Implement an end-to-end test with all feature sources enabled. The new
test runs nfd-worker as a daemonset on all (schedulable) nodes of the
test cluster which makes it possible to cover a wide range features,
assuming the test cluster is heterogenous containing nodes with varying
system configurations.

The features available depends on the node(s) the e2e testa are run on.
Thus, some runtime parameterization of the tests is needed. The patch
adds a new command line test flag 'nfd.e2e-config' that is used to
specify the per-node feature labels and annotations that is expected to
be present in the cluster. An example configuration file is provided
with the patch. The pod spec of nfd-worker deployment is changed to
better correspond the default deployment and thus enable wider feature
discovery. This means using hostnetwork and adding mounts for /sys /boot
and /etc/os-release.

The patch changes node object management so that all nfd-related labels
are removed after each test (not just the ones the test is expected to
add). Also, all nfd-related annotations are now removed.
2020-02-28 10:37:26 +02:00
Markus Lehtonen
54eaf16871 nfd-master: export label and annotation prefixes
In order to be able to use the constants in end-to-end tests.
2020-02-27 14:21:00 +02:00
Markus Lehtonen
974310251c test/e2e: adapt new wireframe to nfd context
Adapt the end-to-end test wireframe (copied from Kubernetes in the
previous commit) to node-feature-discovery.
2020-02-05 19:35:41 +02:00
Markus Lehtonen
e263c95adc test/e2e: re-copy e2e wireframe from Kubernetes
Sync with Kubernetes. Copy a wireframe for end-to-end tests directly
from Kubernetes v1.17.2.
2020-02-05 17:12:11 +02:00
Markus Lehtonen
0911de1978 Add simple e2e test
Tests that nfd master-worker communication works and that the worker is
able to label the node with the labels from the 'fake' source.

An example of running the test suite with a custom image with user's
kubeconfig:
$ go test ./test/e2e/ -args -nfd.repo=<image-repo> -nfd.tag=<image-tag> \
            -kubeconfig=$HOME/.kube/config

Partly based on some previous work done by Balaji Subramaniam.
2019-06-25 09:50:29 +03:00
Markus Lehtonen
9065c7adbe Add empty e2e test stub
Patch the (Kubernetes) e2e wireframe introduced in the previous commit with some minor
modifications, dropping some bits in order to simplify the code.

Also adds a dummy test stub for node feature discovery.
2019-06-25 09:50:29 +03:00
Markus Lehtonen
b284b2f42b Copy e2e wireframe from Kubernetes
Copy E2E wireframe directly from Kubernetes v1.13.5.
2019-06-25 09:50:29 +03:00
Markus Lehtonen
35d26001e4 nfd-worker: extend unit test to cover 'main'
Also, adds new method WaitForReady() into NfdMaster.

In practice, this quite widely tests nfd-master, too, as the tests
create an instance of NfdMaster and verify that the communication
between master and worker works.
2019-05-06 16:26:41 +03:00