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

91 commits

Author SHA1 Message Date
Markus Lehtonen
55bd633425 nfd-master: allow profile.node.kubernetes.io label ns
Add a separate label namespace for profile labels, intended for
user-specified higher level "meta features". Also sub-namespaces of this
(i.e. <sub-ns>.profile.node.kubernetes.io) are allowed.
2021-08-10 19:39:59 +03:00
Markus Lehtonen
c3760fbbab nfd-master: rename LabelNs to FeatureLabelNs 2021-08-10 19:13:08 +03:00
Kubernetes Prow Robot
4a22a39928
Merge pull request #536 from marquiz/devel/label-sub-ns
nfd-master: allow sub-namespaces of the default label ns
2021-08-10 04:19:18 -07:00
Markus Lehtonen
eb666f521d nfd-master: allow sub-namespaces of the default label ns
Allow <sub-ns>.feature.node.kubernetes.io label namespaces. Makes it
possible to have e.g. vendor specific label ns without the need to user
-extra-label-ns.
2021-08-10 11:41:52 +03:00
Markus Lehtonen
d12e62b1fe Makefile: add apigen target
For auto-generating api(s).

Also, re-generate/refresh the gRPC with `make apigen` (with protoc
v3.17.3 and protoc-gen-go from github.com/golang/protobuf v1.5.2) to
sync up things.
2021-07-07 16:01:10 +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
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
99d223b029 utils/dump: do not print empty header line
Makes log output cleaner.
2021-06-11 09:29:49 +03:00
robertdavidsmith
77bd4e4cf6
Accept client certs based on SAN, not just CN (#514)
* first attempt at SAN-based VerifyNodeName

* Update docs on verify-node-name
2021-04-20 01:44:32 -07:00
Kubernetes Prow Robot
c0e1000a7d
Merge pull request #474 from marquiz/devel/worker-log-verbosity
nfd-worker: don't log labels returned by sources by default
2021-03-15 12:52:34 -07:00
Markus Lehtonen
6c6249a599 nfd-worker: don't log labels returned by sources by default
Reduce default log verbosity. Only print out labels if log verbosity is
1 or higher ('core.klog.v: 1' config file option or '-v 1' on command
line). Also, dump the labels in a reproducible (sorted) format.
2021-03-15 21:42:33 +02:00
Kubernetes Prow Robot
03f53d85e9
Merge pull request #475 from marquiz/devel/grpc-klog
pkg/utils: show correct source file in gRPC logs
2021-03-11 06:20:24 -08:00
Markus Lehtonen
fb67a5027b pkg/utils: show correct source file in gRPC logs
Unwind two call frames so that the source (file:line) of the log message
is correctly displayed.
2021-03-11 11:36:55 +02:00
Markus Lehtonen
8d67fc1122 pkg/utils: add dump functions
A simple functions for pretty-printing and logging json-marshallable objects.
2021-03-11 07:12:22 +02:00
Markus Lehtonen
2d20a2ff7c nfd-worker: support certificate rotation
Watch for changes in TLS files and re-connect to nfd-master in the event
of changes.
2021-03-09 14:40:51 +02:00
Markus Lehtonen
e771a35a21 nfd-master: support certificate rotation
Add a helper/wrapper in pkg/utils to handle gRPC server-side certificate
rotation.
2021-03-09 14:40:04 +02:00
Markus Lehtonen
dfc2596a22 pkg/utils: generalize file watcher
Add the capability to watch multiple files. Move it to a separate
package in order to make it reusable.
2021-03-09 14:20:34 +02:00
Markus Lehtonen
8af3a40ca7 logging: set grpc to use klog for logging 2021-03-05 14:44:44 +02:00
Markus Lehtonen
38d493aa67 pkg/utils: fix possible segfault in RegexpVal.Set 2021-03-02 22:46:34 +02:00
Markus Lehtonen
dd7691c486 nfd-worker: improve log messages of config handling 2021-03-02 18:49:58 +02: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
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
3f18e880b4 nfd-worker: dynamic configuration of klog
Make it possible to dynamically (at run-time) alter most of the logging
configuration from the config file.
2021-02-25 16:10:43 +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
Markus Lehtonen
3ffb7b8fc5 nfd-master: switch to klog 2021-02-25 07:50:37 +02:00
Markus Lehtonen
3fd61eacdb nfd-worker: switch to flag in command line parsing 2021-02-24 12:06:16 +02:00
Markus Lehtonen
47033db9c1 nfd-master: use flag for command line parsing 2021-02-24 12:06:16 +02:00
Markus Lehtonen
6b744d4179 nfd-worker: extend unit test coverage of config handling
Add test cases for verifying the core config.

Also, add asynchronous tests for basic verification of dynamic config
file updates.
2021-02-17 21:52:25 +02:00
Markus Lehtonen
2b24ed2c18 nfd-worker: implement Stop() method 2021-02-17 21:50:58 +02:00
Markus Lehtonen
278ccdb997 source/fake: make the fake source configurable
Enables more flexible testing.
2021-02-17 21:50:58 +02:00
Markus Lehtonen
c2c9dff724 nfd-worker: bail out on invalid config file
Changes the behaviour so that if the specified configuration file exists
it must be valid. Error out at startup if the config is invalid.
Similarly, exit with an error at runtime if the config file becomes
invalid. Bailing out, instead of just printing an error, was a
deliberate choice in order to make configuration mistakes evident.

Having no configuration file is tolerated, however. If the specified
configuration file does not exists nfd-worker resorts to default
settings.
2021-02-17 21:42:50 +02:00
Markus Lehtonen
7e88f00e05 nfd-worker: add core.sources config option
Add a config file option for controlling the enabled feature sources,
aimed at replacing the --sources command line flag which is now marked
as deprecated. The command line flag takes precedence over the config
file option.
2021-02-17 21:36:20 +02:00
Markus Lehtonen
ed177350fc nfd-worker: add core.labelWhiteList config option
Add a config file option for label whitelisting. Deprecate the
--label-whitelist command line flag. Note that the command line flag has
higher priority than the config file option.
2021-02-17 21:35:44 +02:00
Markus Lehtonen
d1d8de944e nfd-worker: add core.sleepInterval config option
Add a new config file option for (dynamically) controlling the sleep
interval. At the same time, deprecate the --sleep-interval command line
flag. The command line flag takes precedence over the config file option.
2021-02-17 21:35:13 +02:00
Markus Lehtonen
e6bdc17d8c nfd-worker: add core config
Allows dynamic (re-)configuration of most nfd-worker options. The goal
is to have most configuration parameters specified in the configuration
file and deprecate most of the command line flags. The priority is
intended to be such that command line flags override whatever is
specified in the configuration file. Thus, specifying something on the
command line effectively disables dynamic configurability of that
parameter.

This patch adds core.noPublish config file option to demonstrate how the
new mechanism is supposed to work. The --no-publish command line flag
takes precedence over this config file option.
2021-02-17 21:35:12 +02:00
Kubernetes Prow Robot
85bde7f749
Merge pull request #431 from marquiz/devel/master-instance-flag
nfd-master: implement --instance flag
2021-02-11 02:40:15 -08:00
Markus Lehtonen
29910464a0 nfd-worker: always re-label after a re-config event
Always do re-discovery and re-labeling after a configuration file
change. his way the new config comes into effect immediately, even if
the sleep interval is long (or infinite) # Please enter the commit
message for your changes. Lines starting
2021-02-10 22:09:27 +02:00
Markus Lehtonen
b6ff514853 nfd-worker: use fsnotify for watching for config file changes
Add support for detecting configuration file changes via file system
notifications (fsnotify). Watches are added for the whole directory
chain (up to root directory) so that all changes (even directory
renames) affecting the given configuration file path are captured.

Previously dynamic (re-)configuration of nfd-worker was implemented by
(re-)reading the configuration file on every labeling pass. This was
simple and effective, even if a bit wasteful. However, it didn't provide
asynchronous configuration updates that will be required for e.g.
controlling the "sleep-interval" parameter dynamically which will be
implemented by later patches.
2021-02-10 22:09:27 +02:00
Markus Lehtonen
6958a6677f nfd-worker: use timer channel for sleep interval 2021-02-10 22:09:27 +02: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
705687192d nfd-master: make updateNodeFeatures a method of nfdMaster 2021-02-10 13:46:59 +02:00
Markus Lehtonen
cdca6d667a nfd-master: make nodeName non-global 2021-02-10 13:46:59 +02:00
Markus Lehtonen
b146508e64 nfd-master: drop separate labelerServer type
Simplify code by changing nfdMaster to implement LabelerServer interface
by itself.
2021-02-10 13:46:59 +02:00
Markus Lehtonen
76b95b6c55 Replace improper usage of filepath.Join with path.Join
In JSON and kubernetes API object names we want to use slashes instead
of the OS dependent file path separator.
2021-02-10 12:54:31 +02:00
Markus Lehtonen
19b8f2cd3d nfd-master: more detailed unit testing of extended resources 2020-11-24 12:45:06 +02:00
Markus Lehtonen
d17743a0b9 nfd-master: handle label annotations in the same func
Handle both creation and parsing of the "feature-labels" and
"extended-resources" annotations in the function. I think this is more
logical to keep them together.
2020-11-24 12:45:06 +02:00
Markus Lehtonen
95ff300d74 nfd-master: patch node object instead of rewriting it
When updating node labels and annotations use JSON patches instead of
doing a read-modify-write on the whole node object. Patching is already
being used in managing extended resources so some of the existing code
was re-usable.

This patch should mitigate the problem of node update failures caused by
race conditions (a change in the node object between our read and write)
resulting e.g. in errors/restarts in nfd worker pods.
2020-11-24 12:45:06 +02:00
Markus Lehtonen
1ea301d272 nfd-master: change statusOp to a more generalized JSON patch
Generalize and rename 'statusOp' type to a more flexible 'JsonPatch'.
Move it to the apihelper package.
2020-11-24 12:45:06 +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