Skip to content

Commit be309af

Browse files
authoredMar 21, 2024
Add warning for missing ClusterImageSets (stolostron#3203)
Signed-off-by: rawagner <rawagner@redhat.com>
1 parent 0018968 commit be309af

File tree

2 files changed

+68
-31
lines changed

2 files changed

+68
-31
lines changed
 

‎frontend/public/locales/en/translation.json

+1
Original file line numberDiff line numberDiff line change
@@ -1913,6 +1913,7 @@
19131913
"Number of clusters where the grouped Argo applications' resources are deployed.": "Number of clusters where the grouped Argo applications' resources are deployed.",
19141914
"Number of nodes": "Number of nodes",
19151915
"Number of resources grouped": "Number of resources grouped",
1916+
"Nutanix requires x86_64 release image. No other architecture is supported.": "Nutanix requires x86_64 release image. No other architecture is supported.",
19161917
"NV-series": "NV-series",
19171918
"Object storage": "Object storage",
19181919
"of": "of",

‎frontend/src/routes/Infrastructure/Clusters/ManagedClusters/CreateClusterCatalog/CreateClusterCatalog.tsx

+67-31
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
ICatalogCard,
88
ItemView,
99
} from '@stolostron/react-data-view'
10-
import { useCallback, useMemo, useState } from 'react'
10+
import React, { useCallback, useMemo, useState } from 'react'
1111
import { useTranslation } from '../../../../../lib/acm-i18next'
1212
import { NavigationPath, useBackCancelNavigation } from '../../../../../NavigationPath'
1313
import {
@@ -21,8 +21,39 @@ import {
2121
import { DOC_LINKS, ViewDocumentationLink } from '../../../../../lib/doc-util'
2222
import { useSharedAtoms, useRecoilState } from '../../../../../shared-recoil'
2323
import { ClusterInfrastructureType, getTypedCreateClusterPath } from '../ClusterInfrastructureType'
24-
import { Divider, ExpandableSection } from '@patternfly/react-core'
24+
import { Divider, ExpandableSection, Stack, StackItem } from '@patternfly/react-core'
2525
import { useDataViewStrings } from '../../../../../lib/dataViewStrings'
26+
import { ClusterImageSet } from '../../../../../resources'
27+
import { TFunction } from 'i18next'
28+
29+
const hasClusterImageSetWithArch = (clusterImageSets: ClusterImageSet[], arch: string) =>
30+
clusterImageSets.filter((cis) => cis.spec?.releaseImage.endsWith(arch) && cis.metadata.labels?.visible === 'true')
31+
32+
const clusterImageSetsRequired = (
33+
clusterImageSets: ClusterImageSet[],
34+
t: TFunction,
35+
children?: React.ReactNode
36+
): {
37+
alertTitle: ICatalogCard['alertTitle']
38+
alertVariant: ICatalogCard['alertVariant']
39+
alertContent: ICatalogCard['alertContent']
40+
} => ({
41+
alertTitle: clusterImageSets.length ? undefined : t('OpenShift release images unavailable'),
42+
alertVariant: 'info',
43+
alertContent: (
44+
<Stack hasGutter>
45+
<StackItem>
46+
<>
47+
{t(
48+
'No release image is available. Follow cluster creation prerequisite documentation to learn how to add release images.'
49+
)}
50+
</>
51+
<ViewDocumentationLink doclink={DOC_LINKS.CREATE_CLUSTER_PREREQ} />
52+
</StackItem>
53+
{children && <StackItem>{children}</StackItem>}
54+
</Stack>
55+
),
56+
})
2657

2758
type CardProvider = Provider & (ClusterInfrastructureType | Provider.hostinventory | Provider.nutanix)
2859
type CardData = {
@@ -131,7 +162,7 @@ export function CreateClusterCatalog() {
131162
} else if (provider === Provider.hostinventory) {
132163
return clusterImageSets.length ? nextStep(NavigationPath.createBMControlPlane) : undefined
133164
} else if (provider === Provider.nutanix) {
134-
return clusterImageSets.length
165+
return hasClusterImageSetWithArch(clusterImageSets, 'x86_64').length
135166
? nextStep({
136167
pathname: NavigationPath.createDiscoverHost,
137168
search: 'nutanix=true',
@@ -164,33 +195,38 @@ export function CreateClusterCatalog() {
164195
labels,
165196
onClick: getOnClickAction(provider),
166197
}
167-
if (provider === Provider.hostinventory) {
168-
card = {
169-
...card,
170-
title: t('Host inventory'),
171-
alertTitle: clusterImageSets.length ? undefined : t('OpenShift release images unavailable'),
172-
alertVariant: 'info',
173-
alertContent: (
174-
<>
175-
{t(
176-
'No release image is available. Follow cluster creation prerequisite documentation to learn how to add release images.'
177-
)}
178-
<ViewDocumentationLink doclink={DOC_LINKS.CREATE_CLUSTER_PREREQ} />
179-
</>
180-
),
181-
}
182-
} else if (provider === Provider.redhatvirtualization) {
183-
card = {
184-
...card,
185-
alertTitle: t('Deprecated host platform'),
186-
alertVariant: 'info',
187-
alertContent: (
188-
<>
189-
{t('Red Hat Virtualization is deprecated for OpenShift 4.13.')}
190-
<ViewDocumentationLink doclink={DOC_LINKS.RHV_DEPRECATION} />
191-
</>
192-
),
193-
}
198+
199+
switch (provider) {
200+
case Provider.hostinventory:
201+
card = {
202+
...card,
203+
title: t('Host inventory'),
204+
...clusterImageSetsRequired(clusterImageSets, t),
205+
}
206+
break
207+
case Provider.nutanix:
208+
card = {
209+
...card,
210+
...clusterImageSetsRequired(
211+
hasClusterImageSetWithArch(clusterImageSets, 'x86_64'),
212+
t,
213+
<>{t('Nutanix requires x86_64 release image. No other architecture is supported.')}</>
214+
),
215+
}
216+
break
217+
case Provider.redhatvirtualization:
218+
card = {
219+
...card,
220+
alertTitle: t('Deprecated host platform'),
221+
alertVariant: 'info',
222+
alertContent: (
223+
<>
224+
{t('Red Hat Virtualization is deprecated for OpenShift 4.13.')}
225+
<ViewDocumentationLink doclink={DOC_LINKS.RHV_DEPRECATION} />
226+
</>
227+
),
228+
}
229+
break
194230
}
195231
return card
196232
}
@@ -209,7 +245,7 @@ export function CreateClusterCatalog() {
209245
})
210246

211247
return { cardsWithCreds, cardsWithOutCreds }
212-
}, [getCredentialLabels, clusterImageSets.length, t, cardsData, getOnClickAction])
248+
}, [getCredentialLabels, clusterImageSets, t, cardsData, getOnClickAction])
213249

214250
const keyFn = useCallback((card: ICatalogCard) => card.id, [])
215251

0 commit comments

Comments
 (0)
Failed to load comments.