mirror of
https://github.com/intel/intel-device-plugins-for-kubernetes.git
synced 2025-06-03 03:59:37 +00:00
Merge pull request #771 from ozhuraki/idxd-kmod
idxd-initcontainer: Drop libkmod, libudev
This commit is contained in:
commit
5d8259e8d4
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
@ -85,7 +85,7 @@ jobs:
|
||||
- intel-sgx-plugin
|
||||
- intel-sgx-initcontainer
|
||||
- intel-dsa-plugin
|
||||
- intel-idxd-initcontainer
|
||||
- intel-idxd-config-initcontainer
|
||||
- intel-dlb-plugin
|
||||
|
||||
# Demo images
|
||||
|
@ -12,38 +12,49 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM debian:unstable AS builder
|
||||
FROM debian:unstable-slim AS builder
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential autoconf automake autotools-dev libtool \
|
||||
pkgconf asciidoc xmlto uuid-dev libjson-c-dev libkmod-dev \
|
||||
libudev-dev libkeyutils-dev curl
|
||||
RUN echo "deb-src http://deb.debian.org/debian unstable main" >> \
|
||||
/etc/apt/sources.list.d/deb-src.list && \
|
||||
apt update && apt install -y --no-install-recommends \
|
||||
gcc make patch autoconf automake libtool pkg-config \
|
||||
libjson-c-dev uuid-dev curl ca-certificates && \
|
||||
mkdir -p /usr/local/share/package-sources && \
|
||||
cd /usr/local/share/package-sources && \
|
||||
apt --download-only source uuid libjson-c5 && cd /
|
||||
|
||||
ARG ACCEL_CONFIG_VERSION="3.4.2"
|
||||
ARG ACCEL_CONFIG_DOWNLOAD_URL="https://github.com/intel/idxd-config/archive/accel-config-v$ACCEL_CONFIG_VERSION.tar.gz"
|
||||
ARG ACCEL_CONFIG_SHA256="9cb2151e86f83949a28f06a885be3bf3100906f9e3af667fa01b56e7666a3c1c"
|
||||
|
||||
RUN curl -fsSL "$ACCEL_CONFIG_DOWNLOAD_URL" -o accel-config.tar.gz \
|
||||
&& echo "$ACCEL_CONFIG_SHA256 accel-config.tar.gz" | sha256sum -c - \
|
||||
&& tar -xzf accel-config.tar.gz \
|
||||
&& rm accel-config.tar.gz
|
||||
RUN curl -fsSL "$ACCEL_CONFIG_DOWNLOAD_URL" -o accel-config.tar.gz && \
|
||||
echo "$ACCEL_CONFIG_SHA256 accel-config.tar.gz" | sha256sum -c - && \
|
||||
tar -xzf accel-config.tar.gz
|
||||
|
||||
ADD demo/idxd-config-kmod.patch /
|
||||
|
||||
RUN cd idxd-config-accel-config-v$ACCEL_CONFIG_VERSION && \
|
||||
mkdir m4 && \
|
||||
./autogen.sh && \
|
||||
./configure CFLAGS='-g -O2' --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib64 --disable-test --disable-docs && \
|
||||
patch -p1 < ../idxd-config-kmod.patch && \
|
||||
./git-version-gen && \
|
||||
autoreconf -i && \
|
||||
./configure -q --libdir=/usr/lib64 --disable-test --disable-docs && \
|
||||
make && \
|
||||
make install
|
||||
|
||||
FROM debian:unstable-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y uuid libjson-c5 kmod udev jq
|
||||
RUN apt update && apt install -y uuid libjson-c5 jq
|
||||
|
||||
COPY --from=builder /usr/lib64/libaccel-config.so.1.0.0 /lib/x86_64-linux-gnu/
|
||||
RUN ldconfig
|
||||
|
||||
COPY --from=builder /usr/bin/accel-config /usr/bin/
|
||||
|
||||
COPY --from=builder /usr/local/share/package-sources/ \
|
||||
/usr/local/share/package-sources/
|
||||
COPY --from=builder /accel-config.tar.gz /usr/local/share/package-sources/
|
||||
COPY --from=builder /idxd-config-kmod.patch /usr/local/share/package-sources/
|
||||
|
||||
ADD demo/idxd-init.sh /idxd-init/
|
||||
ADD demo/dsa.conf /idxd-init/
|
||||
|
@ -56,7 +56,7 @@ There's a sample [DSA initcontainer](https://github.com/intel/intel-device-plugi
|
||||
$ kubectl apply -k deployments/dsa_plugin/overlays/dsa_initcontainer/
|
||||
```
|
||||
|
||||
The provisioning [script](https://github.com/intel/intel-device-plugins-for-kubernetes/blob/main/demo/dsa-init.sh) and [template](https://github.com/intel/intel-device-plugins-for-kubernetes/blob/master/demo/dsa.conf) are available for customization.
|
||||
The provisioning [script](https://github.com/intel/intel-device-plugins-for-kubernetes/blob/main/demo/idxd-init.sh) and [template](https://github.com/intel/intel-device-plugins-for-kubernetes/blob/master/demo/dsa.conf) are available for customization.
|
||||
|
||||
### Deploy with initcontainer and provisioning config in the ConfigMap
|
||||
|
||||
|
158
demo/idxd-config-kmod.patch
Normal file
158
demo/idxd-config-kmod.patch
Normal file
@ -0,0 +1,158 @@
|
||||
From 58038bf811e9942aebd6a812c7b0abceee66fc0c Mon Sep 17 00:00:00 2001
|
||||
From: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
|
||||
Date: Mon, 29 Nov 2021 20:49:25 +0200
|
||||
Subject: [PATCH] accel-config: Make libkmod, libudev optional
|
||||
|
||||
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
|
||||
---
|
||||
accfg/accel-config.c | 15 +++++++++++++--
|
||||
accfg/lib/libaccfg.c | 1 +
|
||||
accfg/lib/private.h | 9 +++++++++
|
||||
configure.ac | 11 +++++++++--
|
||||
4 files changed, 32 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/accfg/accel-config.c b/accfg/accel-config.c
|
||||
index 0840e0b..c5ee687 100644
|
||||
--- a/accfg/accel-config.c
|
||||
+++ b/accfg/accel-config.c
|
||||
@@ -7,7 +7,9 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
+#ifdef HAVE_KMOD
|
||||
#include <libkmod.h>
|
||||
+#endif
|
||||
#include <builtin.h>
|
||||
#include <accfg/libaccel_config.h>
|
||||
#include <ccan/array_size/array_size.h>
|
||||
@@ -75,6 +77,7 @@ static struct cmd_struct commands[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
+#ifdef HAVE_KMOD
|
||||
static int idxd_kmod_init(struct kmod_ctx **ctx, struct kmod_module **mod)
|
||||
{
|
||||
int rc;
|
||||
@@ -97,12 +100,15 @@ static int idxd_kmod_init(struct kmod_ctx **ctx, struct kmod_module **mod)
|
||||
|
||||
return rc;
|
||||
}
|
||||
+#endif
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
struct accfg_ctx *ctx;
|
||||
+#ifdef HAVE_KMOD
|
||||
struct kmod_ctx *kmod_ctx;
|
||||
struct kmod_module *mod;
|
||||
+#endif
|
||||
unsigned int last_error;
|
||||
int rc;
|
||||
|
||||
@@ -122,16 +128,19 @@ int main(int argc, const char **argv)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
+#ifdef HAVE_KMOD
|
||||
rc = idxd_kmod_init(&kmod_ctx, &mod);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Failed initializing kernel module\n");
|
||||
goto error_exit;
|
||||
}
|
||||
-
|
||||
+#endif
|
||||
rc = accfg_new(&ctx);
|
||||
if (rc) {
|
||||
+#ifdef HAVE_KMOD
|
||||
kmod_module_unref(mod);
|
||||
kmod_unref(kmod_ctx);
|
||||
+#endif
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
@@ -161,9 +170,11 @@ int main(int argc, const char **argv)
|
||||
printf(": %s\n", accfg_ctx_get_last_error_str(ctx));
|
||||
}
|
||||
accfg_unref(ctx);
|
||||
+
|
||||
+#ifdef HAVE_KMOD
|
||||
kmod_module_unref(mod);
|
||||
kmod_unref(kmod_ctx);
|
||||
-
|
||||
+#endif
|
||||
if (!rc)
|
||||
return EXIT_SUCCESS;
|
||||
error_exit:
|
||||
diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
|
||||
index f4fc17e..7897091 100644
|
||||
--- a/accfg/lib/libaccfg.c
|
||||
+++ b/accfg/lib/libaccfg.c
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <unistd.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include <errno.h>
|
||||
+#include <inttypes.h>
|
||||
#include <ctype.h>
|
||||
#include <libgen.h>
|
||||
#include <string.h>
|
||||
diff --git a/accfg/lib/private.h b/accfg/lib/private.h
|
||||
index 57aa1ed..ecb9bd7 100644
|
||||
--- a/accfg/lib/private.h
|
||||
+++ b/accfg/lib/private.h
|
||||
@@ -8,8 +8,12 @@
|
||||
#include <stdbool.h>
|
||||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
+#ifdef HAVE_UDEV
|
||||
#include <libudev.h>
|
||||
+#endif
|
||||
+#ifdef HAVE_KMOD
|
||||
#include <libkmod.h>
|
||||
+#endif
|
||||
#include <util/log.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include <ccan/list/list.h>
|
||||
@@ -160,13 +164,18 @@ struct accfg_ctx {
|
||||
struct accfg_error_ctx *error_ctx;
|
||||
};
|
||||
|
||||
+#ifdef HAVE_UDEV
|
||||
static inline int check_udev(struct udev *udev)
|
||||
{
|
||||
return udev ? 0 : -ENXIO;
|
||||
}
|
||||
+#endif
|
||||
|
||||
+#ifdef HAVE_KMOD
|
||||
static inline int check_kmod(struct kmod_ctx *kmod_ctx)
|
||||
{
|
||||
return kmod_ctx ? 0 : -ENXIO;
|
||||
}
|
||||
+#endif
|
||||
+
|
||||
#endif /* _LIBACCFG_PRIVATE_H_ */
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index b2ef6d0..b3c2ede 100755
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -97,8 +97,15 @@ AM_CONDITIONAL([ENABLE_TEST], [test "x$enable_test" = "xyes"])
|
||||
PKG_CHECK_MODULES([UUID], [uuid],
|
||||
[AC_DEFINE([HAVE_UUID], [1], [Define to 1 if using libuuid])])
|
||||
PKG_CHECK_MODULES([JSON], [json-c])
|
||||
-PKG_CHECK_MODULES([KMOD], [libkmod])
|
||||
-PKG_CHECK_MODULES([UDEV], [libudev])
|
||||
+PKG_CHECK_MODULES([KMOD], [libkmod],
|
||||
+ [AC_DEFINE([HAVE_KMOD], [1], [Defined if using libkmod])],
|
||||
+ KMOD_CFLAGS=""
|
||||
+ KMOD_LIBS="")
|
||||
+
|
||||
+PKG_CHECK_MODULES([UDEV], [libudev],
|
||||
+ [AC_DEFINE([HAVE_UDEV], [1], [Defined if using libudev])],
|
||||
+ UDEV_CFLAGS=""
|
||||
+ UDEV_LIBS="")
|
||||
|
||||
AC_ARG_WITH([bash-completion-dir],
|
||||
AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
|
||||
--
|
||||
2.34.1
|
||||
|
@ -6,7 +6,7 @@ spec:
|
||||
template:
|
||||
spec:
|
||||
initContainers:
|
||||
- name: intel-dsa-initcontainer
|
||||
- name: intel-idxd-config-initcontainer
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
|
@ -53,7 +53,8 @@ spec:
|
||||
properties:
|
||||
InitImage:
|
||||
description: InitImage is an initcontainer image to configure and
|
||||
enable DSA devices and workqueues with accel-config utility
|
||||
enable DSA devices and workqueues with idxd-config (accel-config)
|
||||
utility
|
||||
type: string
|
||||
image:
|
||||
description: Image is a container image with DSA device plugin executable.
|
||||
@ -69,8 +70,8 @@ spec:
|
||||
plugin pods to nodes with particular labels.
|
||||
type: object
|
||||
provisioningConfig:
|
||||
description: ProvisioningConfig is a ConfigMap used to pass the configuration
|
||||
into DSA initcontainer.
|
||||
description: ProvisioningConfig is a ConfigMap used to pass the DSA
|
||||
devices and workqueues configuration into idxd-config initcontainer.
|
||||
type: string
|
||||
sharedDevNum:
|
||||
description: SharedDevNum is a number of containers that can share
|
||||
|
@ -31,10 +31,10 @@ type DsaDevicePluginSpec struct {
|
||||
// Image is a container image with DSA device plugin executable.
|
||||
Image string `json:"image,omitempty"`
|
||||
|
||||
// InitImage is an initcontainer image to configure and enable DSA devices and workqueues with accel-config utility
|
||||
// InitImage is an initcontainer image to configure and enable DSA devices and workqueues with idxd-config (accel-config) utility
|
||||
InitImage string `json:"InitImage,omitempty"`
|
||||
|
||||
// ProvisioningConfig is a ConfigMap used to pass the configuration into DSA initcontainer.
|
||||
// ProvisioningConfig is a ConfigMap used to pass the DSA devices and workqueues configuration into idxd-config initcontainer.
|
||||
ProvisioningConfig string `json:"provisioningConfig,omitempty"`
|
||||
|
||||
// SharedDevNum is a number of containers that can share the same DSA device.
|
||||
|
@ -95,7 +95,7 @@ func (r *DsaDevicePlugin) validatePlugin() error {
|
||||
}
|
||||
|
||||
if len(r.Spec.InitImage) > 0 {
|
||||
return validatePluginImage(r.Spec.InitImage, "intel-idxd-initcontainer", dsaMinVersion)
|
||||
return validatePluginImage(r.Spec.InitImage, "intel-idxd-config-initcontainer", dsaMinVersion)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -82,7 +82,7 @@ func setInitContainer(spec *v1.PodSpec, imageName string) {
|
||||
{
|
||||
Image: imageName,
|
||||
ImagePullPolicy: "IfNotPresent",
|
||||
Name: "intel-idxd-initcontainer",
|
||||
Name: "intel-idxd-config-initcontainer",
|
||||
Env: []v1.EnvVar{
|
||||
{
|
||||
Name: "NODE_NAME",
|
||||
@ -149,7 +149,7 @@ func (c *controller) NewDaemonSet(rawObj client.Object) *apps.DaemonSet {
|
||||
})
|
||||
|
||||
for i, initcontainer := range daemonSet.Spec.Template.Spec.InitContainers {
|
||||
if initcontainer.Name == "intel-idxd-initcontainer" {
|
||||
if initcontainer.Name == "intel-idxd-config-initcontainer" {
|
||||
daemonSet.Spec.Template.Spec.InitContainers[i].VolumeMounts = append(daemonSet.Spec.Template.Spec.InitContainers[i].VolumeMounts, v1.VolumeMount{
|
||||
Name: "intel-dsa-config-volume",
|
||||
MountPath: "/idxd-init/conf",
|
||||
|
@ -177,7 +177,7 @@ func (c *controller) newDaemonSetExpected(rawObj client.Object) *apps.DaemonSet
|
||||
})
|
||||
|
||||
for i, initcontainer := range daemonSet.Spec.Template.Spec.InitContainers {
|
||||
if initcontainer.Name == "intel-idxd-initcontainer" {
|
||||
if initcontainer.Name == "intel-idxd-config-initcontainer" {
|
||||
daemonSet.Spec.Template.Spec.InitContainers[i].VolumeMounts = append(daemonSet.Spec.Template.Spec.InitContainers[i].VolumeMounts, v1.VolumeMount{
|
||||
Name: "intel-dsa-config-volume",
|
||||
MountPath: "/idxd-init/conf",
|
||||
|
Loading…
Reference in New Issue
Block a user