From 4f37909602d0abc470d3d9ba4867b63755b4dd7e Mon Sep 17 00:00:00 2001 From: Pawan Pinjarkar Date: Tue, 18 Nov 2025 17:03:35 -0500 Subject: [PATCH 1/2] AGENT-1364: Add IRI extra manifest for OVE --- go.mod | 1 + go.sum | 4 +- pkg/asset/ignition/recovery_ignition.go | 16 +++++ pkg/utils/utils.go | 29 +++++++++ pkg/utils/utils_test.go | 78 +++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 pkg/utils/utils.go create mode 100644 pkg/utils/utils_test.go diff --git a/go.mod b/go.mod index feb3370b..8618496a 100644 --- a/go.mod +++ b/go.mod @@ -224,6 +224,7 @@ require ( github.com/redis/go-redis/extra/rediscmd/v9 v9.0.5 // indirect github.com/redis/go-redis/extra/redisotel/v9 v9.0.5 // indirect github.com/redis/go-redis/v9 v9.1.0 // indirect + github.com/rogpeppe/go-internal v1.14.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c // indirect github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd // indirect diff --git a/go.sum b/go.sum index 2f331aa3..ac738e2b 100644 --- a/go.sum +++ b/go.sum @@ -1064,8 +1064,8 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc= github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= -github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= diff --git a/pkg/asset/ignition/recovery_ignition.go b/pkg/asset/ignition/recovery_ignition.go index 85e707f6..9de29359 100644 --- a/pkg/asset/ignition/recovery_ignition.go +++ b/pkg/asset/ignition/recovery_ignition.go @@ -2,6 +2,7 @@ package ignition import ( "context" + "fmt" "os" "path/filepath" @@ -11,6 +12,7 @@ import ( "github.com/openshift/appliance/pkg/asset/config" "github.com/openshift/appliance/pkg/asset/manifests" "github.com/openshift/appliance/pkg/installer" + "github.com/openshift/appliance/pkg/utils" "github.com/openshift/installer/pkg/asset" "github.com/openshift/installer/pkg/asset/ignition" "github.com/pkg/errors" @@ -83,6 +85,20 @@ func (i *RecoveryIgnition) Generate(_ context.Context, dependencies asset.Parent // (even though disabled by default, the udev rule may require it). noConfigImageFile := ignition.FileFromString("/etc/assisted/no-config-image", "root", 0644, "") unconfiguredIgnition.Storage.Files = append(unconfiguredIgnition.Storage.Files, noConfigImageFile) + + version := utils.GetOCPVersion(installerConfig.ApplianceConfig) + iriContent := fmt.Sprintf(`apiVersion: machineconfiguration.openshift.io/v1alpha1 + kind: InternalReleaseImage + metadata: + name: cluster + spec: + releases: + - name: ocp-release-bundle-%s + `, version) + + // Keep the filepath in sync with openshift/installer#10176 until the installer min storage will be more robust. + iriFile := ignition.FileFromString("/etc/assisted/extra-manifests/internalreleaseimage.yaml", "root", 0644, iriContent) + unconfiguredIgnition.Storage.Files = append(unconfiguredIgnition.Storage.Files, iriFile) } // Remove registries.conf file from unconfiguredIgnition (already added in bootstrapIgnition) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go new file mode 100644 index 00000000..e131e308 --- /dev/null +++ b/pkg/utils/utils.go @@ -0,0 +1,29 @@ +package utils + +import ( + "fmt" + "strings" + + "github.com/openshift/appliance/pkg/asset/config" +) + +// GetOCPVersion returns the OpenShift version string for the InternalReleaseImage. +// If a release URL is provided, it extracts the version tag from the URL. +// Otherwise, it constructs the version from the configured version and architecture. +func GetOCPVersion(applianceConfig *config.ApplianceConfig) string { + if applianceConfig.Config.OcpRelease.URL != nil && *applianceConfig.Config.OcpRelease.URL != "" { + return extractVersionFromURL(*applianceConfig.Config.OcpRelease.URL) + } + ocpVersion := applianceConfig.Config.OcpRelease.Version + arch := *applianceConfig.Config.OcpRelease.CpuArchitecture + return fmt.Sprintf("%s-%s", ocpVersion, arch) +} + +// extractVersionFromURL extracts the version tag from a container image URL. +func extractVersionFromURL(url string) string { + parts := strings.Split(url, ":") + if len(parts) >= 2 { + return parts[len(parts)-1] + } + return "" +} diff --git a/pkg/utils/utils_test.go b/pkg/utils/utils_test.go new file mode 100644 index 00000000..4be5525f --- /dev/null +++ b/pkg/utils/utils_test.go @@ -0,0 +1,78 @@ +package utils + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + "github.com/go-openapi/swag" + "github.com/openshift/appliance/pkg/asset/config" + "github.com/openshift/appliance/pkg/types" +) + + func TestUtils(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Utils Suite") + } + + var _ = Describe("ExtractVersionFromURL", func() { + DescribeTable("should extract version from URL", + func(url string, expectedResult string) { + result := extractVersionFromURL(url) + Expect(result).To(Equal(expectedResult)) + }, + Entry("standard OCP stable release URL", + "quay.io/openshift-release-dev/ocp-release:4.20.4-x86_64", + "4.20.4-x86_64", + ), + Entry("URL with registry port", + "localhost:5000/ocp-release:4.20.4-x86_64", + "4.20.4-x86_64", + ), + ) + }) + + var _ = Describe("GetOCPVersion", func() { + DescribeTable("should get OCP version", + func(applianceConfig *config.ApplianceConfig, expectedResult string) { + result := GetOCPVersion(applianceConfig) + Expect(result).To(Equal(expectedResult)) + }, + Entry("extract version from URL", + &config.ApplianceConfig{ + Config: &types.ApplianceConfig{ + OcpRelease: types.ReleaseImage{ + Version: "4.20.4", + CpuArchitecture: swag.String("x86_64"), + URL: swag.String("quay.io/openshift-release-dev/ocp-release:4.20.4-x86_64"), + }, + }, + }, + "4.20.4-x86_64", + ), + Entry("extract version from URL with registry port", + &config.ApplianceConfig{ + Config: &types.ApplianceConfig{ + OcpRelease: types.ReleaseImage{ + Version: "4.20.4", + CpuArchitecture: swag.String("x86_64"), + URL: swag.String("localhost:5000/openshift-release:4.20.4-x86_64"), + }, + }, + }, + "4.20.4-x86_64", + ), + Entry("construct version from version and architecture", + &config.ApplianceConfig{ + Config: &types.ApplianceConfig{ + OcpRelease: types.ReleaseImage{ + Version: "4.20.4", + CpuArchitecture: swag.String("x86_64"), + }, + }, + }, + "4.20.4-x86_64", + ), + ) + }) From 53aaef7844b4a712b7bbde21e438e8f25c3726d4 Mon Sep 17 00:00:00 2001 From: Pawan Pinjarkar Date: Mon, 26 Jan 2026 18:37:20 -0500 Subject: [PATCH 2/2] AGENT-1313: Fix IRI config format, releaseVersion --- pkg/asset/ignition/recovery_ignition.go | 20 ++++--- pkg/utils/utils.go | 29 --------- pkg/utils/utils_test.go | 78 ------------------------- 3 files changed, 11 insertions(+), 116 deletions(-) delete mode 100644 pkg/utils/utils.go delete mode 100644 pkg/utils/utils_test.go diff --git a/pkg/asset/ignition/recovery_ignition.go b/pkg/asset/ignition/recovery_ignition.go index 9de29359..9a6b836f 100644 --- a/pkg/asset/ignition/recovery_ignition.go +++ b/pkg/asset/ignition/recovery_ignition.go @@ -12,7 +12,6 @@ import ( "github.com/openshift/appliance/pkg/asset/config" "github.com/openshift/appliance/pkg/asset/manifests" "github.com/openshift/appliance/pkg/installer" - "github.com/openshift/appliance/pkg/utils" "github.com/openshift/installer/pkg/asset" "github.com/openshift/installer/pkg/asset/ignition" "github.com/pkg/errors" @@ -86,15 +85,18 @@ func (i *RecoveryIgnition) Generate(_ context.Context, dependencies asset.Parent noConfigImageFile := ignition.FileFromString("/etc/assisted/no-config-image", "root", 0644, "") unconfiguredIgnition.Storage.Files = append(unconfiguredIgnition.Storage.Files, noConfigImageFile) - version := utils.GetOCPVersion(installerConfig.ApplianceConfig) + _, releaseVersion, err := installerConfig.ApplianceConfig.GetRelease() + if err != nil { + return err + } iriContent := fmt.Sprintf(`apiVersion: machineconfiguration.openshift.io/v1alpha1 - kind: InternalReleaseImage - metadata: - name: cluster - spec: - releases: - - name: ocp-release-bundle-%s - `, version) +kind: InternalReleaseImage +metadata: + name: cluster +spec: + releases: + - name: ocp-release-bundle-%s +`, releaseVersion) // Keep the filepath in sync with openshift/installer#10176 until the installer min storage will be more robust. iriFile := ignition.FileFromString("/etc/assisted/extra-manifests/internalreleaseimage.yaml", "root", 0644, iriContent) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go deleted file mode 100644 index e131e308..00000000 --- a/pkg/utils/utils.go +++ /dev/null @@ -1,29 +0,0 @@ -package utils - -import ( - "fmt" - "strings" - - "github.com/openshift/appliance/pkg/asset/config" -) - -// GetOCPVersion returns the OpenShift version string for the InternalReleaseImage. -// If a release URL is provided, it extracts the version tag from the URL. -// Otherwise, it constructs the version from the configured version and architecture. -func GetOCPVersion(applianceConfig *config.ApplianceConfig) string { - if applianceConfig.Config.OcpRelease.URL != nil && *applianceConfig.Config.OcpRelease.URL != "" { - return extractVersionFromURL(*applianceConfig.Config.OcpRelease.URL) - } - ocpVersion := applianceConfig.Config.OcpRelease.Version - arch := *applianceConfig.Config.OcpRelease.CpuArchitecture - return fmt.Sprintf("%s-%s", ocpVersion, arch) -} - -// extractVersionFromURL extracts the version tag from a container image URL. -func extractVersionFromURL(url string) string { - parts := strings.Split(url, ":") - if len(parts) >= 2 { - return parts[len(parts)-1] - } - return "" -} diff --git a/pkg/utils/utils_test.go b/pkg/utils/utils_test.go deleted file mode 100644 index 4be5525f..00000000 --- a/pkg/utils/utils_test.go +++ /dev/null @@ -1,78 +0,0 @@ -package utils - -import ( - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "github.com/go-openapi/swag" - "github.com/openshift/appliance/pkg/asset/config" - "github.com/openshift/appliance/pkg/types" -) - - func TestUtils(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Utils Suite") - } - - var _ = Describe("ExtractVersionFromURL", func() { - DescribeTable("should extract version from URL", - func(url string, expectedResult string) { - result := extractVersionFromURL(url) - Expect(result).To(Equal(expectedResult)) - }, - Entry("standard OCP stable release URL", - "quay.io/openshift-release-dev/ocp-release:4.20.4-x86_64", - "4.20.4-x86_64", - ), - Entry("URL with registry port", - "localhost:5000/ocp-release:4.20.4-x86_64", - "4.20.4-x86_64", - ), - ) - }) - - var _ = Describe("GetOCPVersion", func() { - DescribeTable("should get OCP version", - func(applianceConfig *config.ApplianceConfig, expectedResult string) { - result := GetOCPVersion(applianceConfig) - Expect(result).To(Equal(expectedResult)) - }, - Entry("extract version from URL", - &config.ApplianceConfig{ - Config: &types.ApplianceConfig{ - OcpRelease: types.ReleaseImage{ - Version: "4.20.4", - CpuArchitecture: swag.String("x86_64"), - URL: swag.String("quay.io/openshift-release-dev/ocp-release:4.20.4-x86_64"), - }, - }, - }, - "4.20.4-x86_64", - ), - Entry("extract version from URL with registry port", - &config.ApplianceConfig{ - Config: &types.ApplianceConfig{ - OcpRelease: types.ReleaseImage{ - Version: "4.20.4", - CpuArchitecture: swag.String("x86_64"), - URL: swag.String("localhost:5000/openshift-release:4.20.4-x86_64"), - }, - }, - }, - "4.20.4-x86_64", - ), - Entry("construct version from version and architecture", - &config.ApplianceConfig{ - Config: &types.ApplianceConfig{ - OcpRelease: types.ReleaseImage{ - Version: "4.20.4", - CpuArchitecture: swag.String("x86_64"), - }, - }, - }, - "4.20.4-x86_64", - ), - ) - })