Files
app-intel-device-plugins/intel-device-plugins-images/files/0002-fix-version-string-parsing-error.patch
Md Irshad Sheikh 642489b1a5 Fix version string parsing error
Applying the app-intel-device-plugins application fails with the
following error when using a custom image version stx.11.0-v0.32.1:
invalid resource: could not parse "stx.11.0-v0.32.1" as version

This error occurs because the upstream code expects a plain upstream
release version, rather than the custom STX image version, during
plugin image validation.

This commit introduces a patch that resolves the issue by extracting
the actual upstream release version (0.32.1) from the STX image
version (stx.11.0-v0.32.1) prior to validating the plugin images.

TEST PLAN:
PASS: ./build-stx-images.sh <..> --only intel-deviceplugin-operator
PASS: Compare the app apply results with 24.09 image and new custom
      image. Parsing error should not occur.

Story: 2011407
Task: 52555

Change-Id: I2ec8f64e9e2dc20a73980fc225a56bb30b92bc9f
Signed-off-by: Md Irshad Sheikh <mdirshad.sheikh@windriver.com>
2025-07-21 14:14:59 -04:00

36 lines
1.4 KiB
Diff

From 7d5237093a6f3a8c1bddbc0070ec60712b1ac0df Mon Sep 17 00:00:00 2001
From: Md Irshad Sheikh <mdirshad.sheikh@windriver.com>
Date: Mon, 21 Jul 2025 09:07:42 -0400
Subject: [PATCH] Fix version string parsing error
Parsing error occurs because the upstream code expects a plain upstream
release version, rather than the custom STX image version, during
plugin image validation.
This patch resolves the issue by extracting the actual upstream release
version (0.32.1) from the STX image version (stx.11.0-v0.32.1) prior to
validating the plugin images.
---
pkg/apis/deviceplugin/v1/webhook_common.go | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/pkg/apis/deviceplugin/v1/webhook_common.go b/pkg/apis/deviceplugin/v1/webhook_common.go
index e175f11e..939af077 100644
--- a/pkg/apis/deviceplugin/v1/webhook_common.go
+++ b/pkg/apis/deviceplugin/v1/webhook_common.go
@@ -168,6 +168,12 @@ func validatePluginImage(image, expectedImageName string, expectedMinVersion *ve
return fmt.Errorf("%w: incorrect image name %q. Make sure you use '<vendor>/%s'", errValidation, imageName, expectedImageName)
}
+ re := regexp.MustCompile(`(\d+\.\d+\.\d+)`)
+ matches := re.FindStringSubmatch(versionStr)
+ if len(matches) >= 2 {
+ versionStr = matches[1]
+ }
+
ver, err := version.ParseSemantic(versionStr)
if err != nil {
return fmt.Errorf("%w: %w: Make sure it's either valid SHA digest or semver tag", errValidation, err)
--
2.34.1