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

Issue:
MGMT-19290: iSCSI validation blocks UMN cluster installation
iSCSI validation gets stuck because machine networks is not prompted to
user when using UMN.

This change skips the validation when user tries to spawn a multi-node
cluster with UMN (the right machine network will be choose at install
time).

We will also skip the validation for imported and day 2 cluster because 
we don't have all the information to perform this validation.



Discussion / hints:

Fix patch:
diff --git a/internal/host/validator.go b/internal/host/validator.go
index ce06e35273..f1ccb79894 100644
--- a/internal/host/validator.go
+++ b/internal/host/validator.go
@@ -1831,6 +1831,23 @@ func (v *validator) inventoryHasIP(inventory *models.Inventory, ipAddress string
 }
 
 func (v *validator) noIscsiNicBelongsToMachineCidr(c *validationContext) (ValidationStatus, string) {
+	if c.cluster == nil {
+		return ValidationSuccessSuppressOutput, ""
+	}
+
+	if swag.BoolValue(c.cluster.UserManagedNetworking) && !common.IsSingleNodeCluster(c.cluster) {
+		// We don't expect users to select machine network in case of
+		// UMN with compact and multi-node clusters
+		return ValidationSuccessSuppressOutput, ""
+	}
+
+	if common.IsImportedCluster(c.cluster) || common.IsDay2Cluster(c.cluster) {
+		// Machine networks and network type (UMN or CNM) is not known
+		// for imported and day2 clusters
+		// We will skip this check in these cases
+		return ValidationSuccessSuppressOutput, ""
+	}
+
 	installationDisk, err := hostutil.GetHostInstallationDisk(c.host)
 	if err != nil || installationDisk == nil {
 		return ValidationSuccessSuppressOutput, ""


Test patch:
diff --git a/internal/host/validations_test.go b/internal/host/validations_test.go
index 041dcf0a2b..eced0ae308 100644
--- a/internal/host/validations_test.go
+++ b/internal/host/validations_test.go
@@ -2427,7 +2427,6 @@ var _ = Describe("Validations test", func() {
 			Expect(status).To(Equal(ValidationError))
 			Expect(message).To(Equal("Cannot find network interface associated to iSCSI host IP address"))
 		})
-
 		DescribeTable(
 			"iSCSI drive - malformed iSCSI properties",
 			func(iSCSI *models.Iscsi, expectedMessage string) {
@@ -2589,5 +2588,21 @@ var _ = Describe("Validations test", func() {
 				},
 				ValidationSuccess, "Network interface connected to iSCSI disk does not belong to machine network CIDRs"),
 		)
+		DescribeTable(
+			"Validation is skipped when cluster",
+			func(cluster *models.Cluster) {
+				Expect(db.Create(&cluster).Error).ToNot(HaveOccurred())
+				Expect(db.Create(&host).Error).ShouldNot(HaveOccurred())
+				mockAndRefreshStatus(&host)
+
+				refreshedHost := hostutil.GetHostFromDB(*host.ID, host.InfraEnvID, db).Host
+
+				status, message, ok := getValidationResult(refreshedHost.ValidationsInfo, NoIscsiNicBelongsToMachineCidr)
+				Expect(ok).To(BeFalse(), fmt.Sprintf("%s %s", status, message))
+			},
+			Entry("is multi-mode with UMN", &models.Cluster{ID: &clusterID, HighAvailabilityMode: swag.String(models.ClusterHighAvailabilityModeFull), UserManagedNetworking: swag.Bool(true)}),
+			Entry("is day 2", &models.Cluster{ID: &clusterID, Kind: swag.String(models.ClusterKindAddHostsCluster)}),
+			Entry("is imported", &models.Cluster{ID: &clusterID, Imported: swag.Bool(true)}),
+		)
 	})
 })