Repository: openshift/assisted-service (language: python)

Issue:
[release-ocm-2.12] MGMT-19218: Remove getting OKD for late-binding InfraEnv
This is an automated cherry-pick of #6963

/assign CrystalChun

/cherrypick release-ocm-2.11 release-ocm-2.10


Discussion / hints:

Fix patch:
diff --git a/internal/ignition/discovery.go b/internal/ignition/discovery.go
index e70d0b04d28..74a49b8d101 100644
--- a/internal/ignition/discovery.go
+++ b/internal/ignition/discovery.go
@@ -209,6 +209,10 @@ func (ib *ignitionBuilder) shouldAppendOKDFiles(ctx context.Context, infraEnv *c
 	if cfg.OKDRPMsImage != "" {
 		return cfg.OKDRPMsImage, true
 	}
+	// Late-binding InfraEnvs will not have release images associated with them
+	if infraEnv.ClusterID == "" {
+		return "", false
+	}
 	// Check if selected payload contains `okd-rpms` image
 	releaseImage, err := ib.versionHandler.GetReleaseImage(ctx, infraEnv.OpenshiftVersion, infraEnv.CPUArchitecture, infraEnv.PullSecret)
 	if err != nil {


Test patch:
diff --git a/internal/ignition/discovery_test.go b/internal/ignition/discovery_test.go
index 5fcaddd8962..f2bafd89e9e 100644
--- a/internal/ignition/discovery_test.go
+++ b/internal/ignition/discovery_test.go
@@ -97,10 +97,6 @@ var _ = Describe("IgnitionBuilder", func() {
 		mockMirrorRegistriesConfigBuilder = mirrorregistries.NewMockMirrorRegistriesConfigBuilder(ctrl)
 		mockOcRelease = oc.NewMockRelease(ctrl)
 		mockVersionHandler = versions.NewMockHandler(ctrl)
-		infraEnv = common.InfraEnv{InfraEnv: models.InfraEnv{
-			ID:            &infraEnvID,
-			PullSecretSet: false,
-		}, PullSecret: "{\"auths\":{\"cloud.openshift.com\":{\"auth\":\"dG9rZW46dGVzdAo=\",\"email\":\"coyote@acme.com\"}}}"}
 		clusterID := strfmt.UUID(uuid.New().String())
 		cluster = &common.Cluster{
 			PullSecret: "{\"auths\":{\"cloud.openshift.com\":{\"auth\":\"dG9rZW46dGVzdAo=\",\"email\":\"coyote@acme.com\"}}}",
@@ -112,6 +108,11 @@ var _ = Describe("IgnitionBuilder", func() {
 			},
 		}
 		cluster.ImageInfo = &models.ImageInfo{}
+		infraEnv = common.InfraEnv{InfraEnv: models.InfraEnv{
+			ID:            &infraEnvID,
+			ClusterID:     clusterID,
+			PullSecretSet: false,
+		}, PullSecret: "{\"auths\":{\"cloud.openshift.com\":{\"auth\":\"dG9rZW46dGVzdAo=\",\"email\":\"coyote@acme.com\"}}}"}
 		var err error
 		builder, err = NewBuilder(log, mockStaticNetworkConfig, mockMirrorRegistriesConfigBuilder, mockOcRelease, mockVersionHandler)
 		Expect(err).ToNot(HaveOccurred())
@@ -642,7 +643,6 @@ var _ = Describe("Ignition SSH key building", func() {
 		mockMirrorRegistriesConfigBuilder = mirrorregistries.NewMockMirrorRegistriesConfigBuilder(ctrl)
 		mockOcRelease = oc.NewMockRelease(ctrl)
 		mockVersionHandler = versions.NewMockHandler(ctrl)
-		mockVersionHandler.EXPECT().GetReleaseImage(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.New("some error")).Times(1)
 		infraEnv = common.InfraEnv{
 			InfraEnv: models.InfraEnv{
 				ID:            &infraEnvID,
@@ -810,9 +810,11 @@ var _ = Describe("OKD overrides", func() {
 		mockMirrorRegistriesConfigBuilder = mirrorregistries.NewMockMirrorRegistriesConfigBuilder(ctrl)
 		mockVersionHandler = versions.NewMockHandler(ctrl)
 		mockOcRelease = oc.NewMockRelease(ctrl)
+		clusterID := strfmt.UUID(uuid.New().String())
 		infraEnv = common.InfraEnv{
 			InfraEnv: models.InfraEnv{
 				ID:            &infraEnvID,
+				ClusterID:     clusterID,
 				PullSecretSet: false,
 			},
 			PullSecret: "{\"auths\":{\"cloud.openshift.com\":{\"auth\":\"dG9rZW46dGVzdAo=\",\"email\":\"coyote@acme.com\"}}}",