Commit Graph

75 Commits

Author SHA1 Message Date
Krisztian Litkey b64a64d758
Merge pull request #158 from klihub/fixes/logger-default-event-mask
plugins/logger: fix default event subscription mask.
2025-09-30 14:56:43 +03:00
Markus Lehtonen 00fa1a124e Add and fix comments for exported types
Mixed bag of comments for exported types. Makes revive happier.

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
2025-08-29 13:34:22 +03:00
Sascha Grunert d26e910702
Downgrade go to require 1.24.0
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2025-08-26 09:27:56 +02:00
Markus Lehtonen d92ebd6692 Makefile: unconditionally build plugins
Changes the build targets of plugins to always unconditionally execute
without trying to check dependencies. The previous make targets were
faulty, e.g. changing something in the library didn't rebuild the
plugins. This is a simple and stupid fix that I believe is good enough -
building the plugins is really fast and go compiler caching makes it
super fast for "unnecessary" builds.

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
2025-08-15 14:46:49 +03:00
Markus Lehtonen 43e98eee13 Add minimal documentation for plugin images
Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
2025-08-15 10:01:51 +03:00
Krisztian Litkey b382750eac
Merge pull request #205 from marquiz/devel/hook-injector-example
plugins/hook-injector: correct the hook configs
2025-08-13 20:08:13 +03:00
Krisztian Litkey 27523d0e8c
Merge pull request #204 from marquiz/devel/plugin-exit-code
plugins: consistent exit behavior on ttrpc close
2025-08-13 20:07:50 +03:00
Markus Lehtonen ced3ebee0c Bump dependencies
Update outdated deps.

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
2025-08-13 11:31:27 +03:00
Markus Lehtonen 3b1cbdb3fd plugins/hook-injector: correct the hook configs
In the OCI hook configureation args[0] will not be passed to the hook
script as an arg (by convention args[0] is the command).

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
2025-08-12 12:18:16 +03:00
Markus Lehtonen 8429b178ef plugins: consistent exit behavior on ttrpc close
Make those sample plugins which have OnClose defined exit in a similar
fashion, with a log message and exit status 1. This is consistent with
the rest of the sample plugins which also exit with status 1 in this
case (but a different log output).

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
2025-08-12 11:58:59 +03:00
Markus Lehtonen ab267c20ff plugins: drop -name flag from most of the plugins
Drop the -name command line flag from most of the sample plugins.
Exceptions are the template plugin and the ulimit-adjuster plugin where
the name is inserted into the log context.

Also, the differ plugin now takes it name the standard way, dropping the
WithPluginName() opt.

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
2025-08-11 16:05:25 +03:00
Krisztian Litkey 8c53e55b03
Merge pull request #201 from marquiz/devel/hooks-injector-debug
plugins/hook-injector: more verbosity on -verbose
2025-08-09 11:53:43 +03:00
Krisztian Litkey b1b0c0223f
Merge pull request #199 from marquiz/devel/fix-plugin-differ
plugins/differ: fix possible crash at plugin startup
2025-08-09 11:53:27 +03:00
Markus Lehtonen 1cd00b6de2 plugins: add Dockerfile for building images
Add a generic dockerfile for building container images of the sample
plugins. The build command creates statically linked binaries and the
resulting images are minimal, based on scratch base image.

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
2025-08-08 15:37:02 +03:00
Markus Lehtonen 835b0a4f84 plugins/hook-injector: more verbosity on -verbose
Provides debug logs from the hooks manager, too.

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
2025-08-08 14:32:19 +03:00
Krisztian Litkey 2340862b19
Merge pull request #195 from marquiz/devel/fix-logger-plugin
plugins/logger: handle missing events
2025-08-08 10:42:03 +03:00
Markus Lehtonen 6acaca9758 plugins/differ: fix possible crash at plugin startup
Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
2025-08-08 10:36:56 +03:00
Markus Lehtonen 782a7dcc40 readme: list all sample plugins
Also add minimal readme for the template and wasm plugins.

The default-validator plugin is left out as it cannot be built as an
external plugin (without changes).

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
2025-08-07 21:44:10 +03:00
Markus Lehtonen e80ca292f7 plugins/logger: handle missing events
Fix crash with error "Plugin subscribed for unhandled events..." when
started with -events=all.

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
2025-08-07 15:57:55 +03:00
Krisztian Litkey 6347e7e754
default-validator: allow restricting namespace adjustment.
Implement configurable restriction of namespace adjustment in
the default validator.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-07-16 17:19:13 +03:00
Krisztian Litkey bfb171d2be
default-validator: allow restricting seccomp policy adjustment.
Implement configurable restrictions for linux seccomp policy
adjustment in the default validator.

Co-authored-by: Mike Brown <brownwm@us.ibm.com>
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-07-14 18:51:09 +03:00
Krisztian Litkey 3ad35fad2a
device-injector: add I/O priority adjustment.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-07-14 16:50:57 +03:00
Sascha Grunert f6f8d03795
Drop tinygo requirement
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2025-07-02 12:29:32 +02:00
Krisztian Litkey 33b1db1add
logger: fix default event subscription mask.
Let the stub determine which events the logger plugin subscribes
to. This should fix startup errors about trying to subscribe to
{Post,}UpdatePodSandbox events without handlers. Once the runtimes
start delivering those events we can add handlers for them and
that will get us subscribed to them automatically.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-06-11 18:45:30 +03:00
Samuel Karp 559caa25e9
Revert "move packages related to v0.1.0 to the plugins/v010-adapter"
This reverts commit eb6476a3fd.

The old NRI client and types are still imported by containerd for the
podsandbox sandbox controller and plugins are still invoked as part of
setting up the pause container.

Signed-off-by: Samuel Karp <samuelkarp@google.com>
2025-05-30 15:01:26 -07:00
Samuel Karp eca0d2c8ec
Merge pull request #171 from klihub/devel/pluggable-validation/add-default-validator
[pluggable-validation / 3]: implement default validator.
2025-05-30 13:51:49 -07:00
Iceber Gu eb6476a3fd move packages related to v0.1.0 to the plugins/v010-adapter
Signed-off-by: Iceber Gu <caiwei95@hotmail.com>
2025-05-29 18:23:58 +08:00
Samuel Karp df6013880c
network-device-injector: adopt noderesource.dev
The nri.io domain is not owned or controlled by CNCF and its use should
be discouraged.  This commit adds support for the new noderesource.dev
domain, which is a CNCF-owned domain.

Signed-off-by: Samuel Karp <samuelkarp@google.com>
2025-05-28 16:00:02 -07:00
Samuel Karp dbc916a8a9
ulimit-adjuster: adopt noderesource.dev domain
The nri.io domain is not owned or controlled by CNCF and its use should
be discouraged.  This commit adds support for the new noderesource.dev
domain, which is a CNCF-owned domain.

Signed-off-by: Samuel Karp <samuelkarp@google.com>
2025-05-28 15:59:31 -07:00
Samuel Karp b0a6411d46
device-injector: adopt noderesource.dev domain
The nri.io domain is not owned or controlled by CNCF and its use should
be discouraged.  This commit adds support for the new noderesource.dev
domain, which is a CNCF-owned domain.

Signed-off-by: Samuel Karp <samuelkarp@google.com>
2025-05-28 15:58:58 -07:00
Krisztian Litkey 5a006df3c9
adaptation: add default validator tests.
Add default validator tests to verify
  - proper rejection of OCI Hooks
  - proper validation of required plugins
  - allowed toleration of missing required plugins
  - proper validation of annotated extra required plugins

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-05-23 23:46:55 +03:00
Krisztian Litkey c485d5fbdd
adaptation, plugins: implement default validation.
Implement default (container creation/adjustment) validation
as a builtin plugin. The default validator can be configured
to reject OCI hook injection. Additionally, containers can be
annotated with a set of required plugins. If annotated, these
plugins must be present during container creation or else the
creation of the container is rejected by the validator.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-05-23 23:34:26 +03:00
Krisztian Litkey e9f95d08ea
api,adaptation,stub: implement adjustment validation.
Implement pluggable container adjustment validation. When validator
plugins are present, use them to validate the collected adjustments,
failing container creation if any validation fails.

For adjustment validation plugins receive the pod, the pristing un-
adjusted container, the collected container adjustments, information
about which plugins adjusted what container parameters, and the list
of plugins consulted for the adjustments. The plugin can then choose
to accept or reject the adjustments.

Accepting or rejecting adjustments are transactional. Either all or
none of the adjustments are accepted, together with the container
creation request. IOW, rejecting an adjustment results in a failed
container creation request.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-05-17 06:55:01 +03:00
Krisztian Litkey 29270a7e7d
adaptation: rework equality checking in unit tests.
Rework equality checking for unit test results using go-cmp,
aiming for fewer kludges. Define a set of Strip() helpers to
reduce otherwise semantically equivalent adjustments/updates
to a unique canonical form and thus allowing equality checks
using go-cmp/cmp.Equal().

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-05-15 18:00:34 +03:00
Jin Dong e46bcf90fe Bump deps to tagged versions
Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2025-03-09 15:19:36 +00:00
Chris Henzie e4ce8c13ba Add UpdatePodSandbox to NRI plugin API
This API is called by the container runtime to update pod sandbox
resources when they change. This is for the In-place Pod Resize
KEP-1287.

Signed-off-by: Chris Henzie <chrishenzie@google.com>
2025-02-13 09:55:40 -08:00
Sascha Grunert 112fc36b19
Add WASM plugin support
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2024-12-06 09:16:41 +01:00
Antonio Ojea eaf78a9afe api: support Pod IPs
Allow NRI plugins to read the allocated IPs to the pod on the PodSandbox
hooks. This is specially useful for networking daemons that depend on the Pod
IPs assigned via CNI by the container runtime (service mesh, network
policies, ... ) to create seamless integrations without having to modify
the existing environment.

Existing network integrations use techniques like:

- CNI chaining (invasive) as the implementation needs to modify the existing
deployment and can cause disruption due to mutations on the
existing configurations.

- Read Pod Status, that is too late in the process, since the pod
lifecycle does not update the pod status until the containers are
running, but there are applications like network policy
implemetnations or service meshes that needs this information before
the pod is completely created.

- Inspect the host namespaces to gather the information, that is very
intrusive and not portable, creating a tighly coupling between.

Add a nri plugin that can be used as reference implementations for this
integration, the nri plugin just log the interesting networking details
of the pod (ips and network namespace) on the different hooks of the pod lifecucle.

Change-Id: Idb9605c719903d0df51c9a1947e0f838870b5c0b
Signed-off-by: Antonio Ojea <aojea@google.com>
2024-10-26 09:30:50 +00:00
cormick 235aa114df chore: remove unreachable code and fmt files
Signed-off-by: cormick <cormick1080@gmail.com>
2024-10-22 14:39:35 +08:00
Krisztian Litkey 159f5754db
template: dump pod/container count in sync message.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2024-10-10 11:04:38 +03:00
Krisztian Litkey 693d64e256
go.{mod,sum}, plugins: update ttrpc and NRI deps.
Update ttrpc to get sender-side reject of oversized messages.
Although purely a cosmetic change, update sample plugins' NRI
dependecy to our latest tag.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2024-10-10 10:58:20 +03:00
Krisztian Litkey 65781492cc
go.{mod,sum}: bump golang requirement to 1.21.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2024-09-25 15:54:35 +03:00
Krisztian Litkey 442e812394
go.{mod,sum}: update to ginkgo v2.19.1.
Update ginkgo to v2.19.1. This should get us rid of the coverage
collection errors seen in CI.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2024-09-20 17:24:40 +03:00
Krisztian Litkey a03dc9359c
pkg,plugins,.codespellrc: add codespellrc, fix spelling.
Add .codespellrc, fix reported existing spelling errors.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2024-08-27 14:32:29 +03:00
Krisztian Litkey 8783973658
device-injector: clarify precedence of annotations.
Clarify order of preference for the possible annotations.

Co-authored-by: Mike Brown <brownwm@us.ibm.com>
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2024-08-13 14:22:55 +03:00
Krisztian Litkey 4bd8da8cf7
device-injector: add support for CDI injection.
Add support for injecting annotated CDI devices using the
new native NRI CDI injection API.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2024-08-12 17:01:27 +03:00
Fu Wei 22932aa504
Merge pull request #97 from klihub/fixes/typos/device-plugin
plugins/device-injector: fix a small typo in README.md.
2024-07-11 23:27:02 +08:00
Krisztian Litkey f96a550770
device-injector: small grammar fix in README.md.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2024-07-10 17:26:12 +03:00
Krisztian Litkey 5680921a7a
plugins/template: fix typo in a comment.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2024-07-10 17:17:52 +03:00
Krisztian Litkey a9778ad8bf
plugins: bump golang version to 1.20.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2024-06-06 20:18:05 +03:00