Skip to content

Commit

Permalink
MGMT-15251: Link to infra env page instead of networking in case of n…
Browse files Browse the repository at this point in the history
…tp failure
  • Loading branch information
rawagner committed Aug 12, 2023
1 parent b270560 commit cc87711
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 30 deletions.
1 change: 1 addition & 0 deletions libs/locales/lib/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@
"ai:IP allocation from the DHCP server timed out.": "IP allocation from the DHCP server timed out.",
"ai:iPXE script file is ready to be downloaded": "iPXE script file is ready to be downloaded",
"ai:iPXE script file URL": "iPXE script file URL",
"ai:It can be fixed in the <1>{pageURL.name}</1> page.": "It can be fixed in the <1>{pageURL.name}</1> page.",
"ai:It can be fixed in the <2></2> step.": "It can be fixed in the <2></2> step.",
"ai:It is not possible to remove a host which is being installed.": "It is not possible to remove a host that is being installed.",
"ai:It is not possible to remove a node from a cluster during installation.": "It is not possible to remove a node from a cluster during installation.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Host } from '../../../common';
import {
getAllClusterWizardSoftValidationIds,
getWizardStepClusterStatus,
Expand Down Expand Up @@ -68,6 +69,15 @@ const networkingStepValidationsMap: WizardStepValidationMap = {
// TODO(mlibra): remove that container-images-available from soft validations and let backend drive it via disabling it.
// Depends on: https://issues.redhat.com/browse/MGMT-5265
softValidationIds: ['ntp-synced', 'container-images-available'],
getPageURL: (host: Host, validationID: string) => {
if (host && validationID === 'ntp-synced') {
return {
url: `multicloud/infrastructure/environments/details/${host.infraEnvId}`,

Check failure on line 75 in libs/ui-lib/lib/cim/components/ClusterDeployment/wizardTransition.ts

View workflow job for this annotation

GitHub Actions / lint

Invalid type "string | undefined" of template literal expression
name: 'infrastructure environment',
};
}
return undefined;
},
};

const reviewStepValidationsMap: WizardStepValidationMap = {
Expand Down
59 changes: 30 additions & 29 deletions libs/ui-lib/lib/cim/components/helpers/toAssisted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,44 +63,45 @@ export const getAIHosts = (
progressStages: agentProgress?.progressStages,
bootstrap: agent.status?.bootstrap,
installationDiskId: agent.spec.installation_disk_id || agent.status?.installation_disk_id,
infraEnvId: `${agent.metadata?.namespace || ''}/${agent.metadata?.labels?.['infraenvs.agent-install.openshift.io'] || ''}`,
};
});

const restBmhs =
infraEnv && bmhs
? bmhs
?.filter((h) =>
h.metadata?.namespace === infraEnv.metadata?.namespace &&
?.filter((h) =>
h.metadata?.namespace === infraEnv.metadata?.namespace &&
getInfraEnvNameOfAgent(h) === infraEnv.metadata?.name &&
h.metadata?.name
? !bmhAgents.includes(h.metadata.name)
: true,
)
.map((h) => {
const hostInventory: Inventory = {
hostname: h.metadata?.annotations?.[BMH_HOSTNAME_ANNOTATION] || h.metadata?.name,
bmcAddress: h.spec?.bmc?.address,
systemVendor: {
virtual: false,
productName: 'Bare Metal Host',
},
};
? !bmhAgents.includes(h.metadata.name)
: true,
)
.map((h) => {
const hostInventory: Inventory = {
hostname: h.metadata?.annotations?.[BMH_HOSTNAME_ANNOTATION] || h.metadata?.name,
bmcAddress: h.spec?.bmc?.address,
systemVendor: {
virtual: false,
productName: 'Bare Metal Host',
},
};

const restBmh: Host = {
id: h.metadata?.uid || '',
href: 'bmc', // It's BMC
kind: 'Host',
status: 'known',
statusInfo: '',
inventory: JSON.stringify(hostInventory),
requestedHostname:
h.metadata?.annotations?.[BMH_HOSTNAME_ANNOTATION] || h.metadata?.name,
role: undefined,
createdAt: h.metadata?.creationTimestamp,
};
const restBmh: Host = {
id: h.metadata?.uid || '',
href: 'bmc', // It's BMC
kind: 'Host',
status: 'known',
statusInfo: '',
inventory: JSON.stringify(hostInventory),
requestedHostname:
h.metadata?.annotations?.[BMH_HOSTNAME_ANNOTATION] || h.metadata?.name,
role: undefined,
createdAt: h.metadata?.creationTimestamp,
};

return restBmh;
})
return restBmh;
})
: [];

return [...hosts, ...restBmhs];
Expand Down Expand Up @@ -145,7 +146,7 @@ export const getAICluster = ({
vipDhcpAllocation: false,
userManagedNetworking: Boolean(
agentClusterInstall?.spec?.provisionRequirements?.controlPlaneAgents === 1 ||
agentClusterInstall?.spec?.networking?.userManagedNetworking,
agentClusterInstall?.spec?.networking?.userManagedNetworking,
),
hostNetworks: getHostNetworks(agents, agentClusterInstall),
totalHostCount: agents?.length,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const FailingValidation = <S extends string>({
setCurrentStepId,
wizardStepNames,
wizardStepsValidationsMap,
host,
}: FailingValidationsProps<S>) => {
const { t } = useTranslation();

Expand All @@ -85,7 +86,16 @@ const FailingValidation = <S extends string>({
// no sooner step, so the user can not do anything about it ...
fix = t('ai:Please wait till all checks are finished.');
} else if (step) {
fix = (
const pageURL = host
? wizardStepsValidationsMap[step].getPageURL?.(host, validation.id)
: undefined;
fix = pageURL ? (
<>
<Trans t={t}>
ai:It can be fixed in the <a href={pageURL.url}>{pageURL.name}</a> page.
</Trans>
</>
) : (
<>
<Trans t={t}>
ai:It can be fixed in the{' '}
Expand Down Expand Up @@ -193,6 +203,7 @@ export const HostsValidations = <S extends string, V extends string[]>({
<FailingValidation<S>
key={validationId}
validation={validation}
host={host}
hostGroup={group}
severity={severity}
setCurrentStepId={setCurrentStepId}
Expand Down
1 change: 1 addition & 0 deletions libs/ui-lib/lib/common/components/clusterWizard/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export type FailingValidationsProps<S extends string> = {
severity?: 'danger' | 'warning';
wizardStepNames: { [key in S]: string };
wizardStepsValidationsMap: WizardStepsValidationMap<S>;
host?: Host;
};

export type ValidationActionLinkProps<S extends string> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ export type WizardStepValidationMap = {
validationIds: HostValidationId[];
};
softValidationIds: (HostValidationId | ClusterValidationId)[];
getPageURL?: (
host: Host,
validationId: string,
) =>
| {
url: string;
name: string;
}
| undefined;
};

export type WizardStepsValidationMap<T extends string> = {
Expand Down

0 comments on commit cc87711

Please sign in to comment.