Skip to content

Commit

Permalink
Add MTU validation (#2736)
Browse files Browse the repository at this point in the history
  • Loading branch information
ammont82 authored Dec 18, 2024
1 parent 4a5e939 commit d6a58ca
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 14 deletions.
3 changes: 3 additions & 0 deletions libs/locales/lib/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@
"ai:Learn more": "Learn more",
"ai:Learn more about configuration.": "Learn more about configuration.",
"ai:Learn more about enabling CIM on AWS <1></1>": "Learn more about enabling CIM on AWS <1></1>",
"ai:Learn more about MTU (maximum transmission unit)": "Learn more about MTU (maximum transmission unit)",
"ai:Learn more about OpenShift releases": "Learn more about OpenShift releases",
"ai:Learn more about pull secrets and view examples": "Learn more about pull secrets and view examples",
"ai:Learn more about storage class": "Learn more about storage class",
Expand Down Expand Up @@ -525,6 +526,8 @@
"ai:More info for image storage": "More information for image storage",
"ai:More info for load balancer on Amazon web services": "More information for load balancer on Amazon web services",
"ai:More info for system storage": "More information for system storage",
"ai:MTU (maximum transmission unit) failure": "MTU (maximum transmission unit) failure",
"ai:MTU requirements": "MTU requirements",
"ai:Multicluster engine": "Multicluster engine",
"ai:Multicluster engine requirements": "Multicluster engine requirements",
"ai:Must be at least 1": "Must be at least 1",
Expand Down
13 changes: 8 additions & 5 deletions libs/types/assisted-installer-service.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ export type ClusterValidationId =
| 'lvm-requirements-satisfied'
| 'mce-requirements-satisfied'
| 'mtv-requirements-satisfied'
| 'osc-requirements-satisfied'
| 'network-type-valid'
| 'platform-requirements-satisfied'
| 'node-feature-discovery-requirements-satisfied'
Expand All @@ -628,7 +629,7 @@ export type ClusterValidationId =
| 'servicemesh-requirements-satisfied'
| 'serverless-requirements-satisfied'
| 'openshift-ai-requirements-satisfied'
| 'osc-requirements-satisfied';
| 'authorino-requirements-satisfied';
export interface CompletionParams {
isSuccess: boolean;
errorInfo?: string;
Expand Down Expand Up @@ -995,6 +996,7 @@ export type FeatureSupportLevelId =
| 'CNV'
| 'MCE'
| 'MTV'
| 'OSC'
| 'NUTANIX_INTEGRATION'
| 'BAREMETAL_PLATFORM'
| 'NONE_PLATFORM'
Expand All @@ -1017,9 +1019,8 @@ export type FeatureSupportLevelId =
| 'SERVICEMESH'
| 'SERVERLESS'
| 'OPENSHIFT_AI'
| 'OSC'
| 'NON_STANDARD_HA_CONTROL_PLANE';

| 'NON_STANDARD_HA_CONTROL_PLANE'
| 'AUTHORINO';
/**
* Cluster finalizing stage managed by controller
*/
Expand Down Expand Up @@ -1545,6 +1546,7 @@ export type HostValidationId =
| 'lvm-requirements-satisfied'
| 'mce-requirements-satisfied'
| 'mtv-requirements-satisfied'
| 'osc-requirements-satisfied'
| 'sufficient-installation-disk-speed'
| 'cnv-requirements-satisfied'
| 'sufficient-network-latency-requirement-for-role'
Expand All @@ -1570,7 +1572,8 @@ export type HostValidationId =
| 'servicemesh-requirements-satisfied'
| 'serverless-requirements-satisfied'
| 'openshift-ai-requirements-satisfied'
| 'osc-requirements-satisfied';
| 'authorino-requirements-satisfied'
| 'mtu-valid';
/**
* Explicit ignition endpoint overrides the default ignition endpoint.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ const hostValidationsInfo = {
status: 'pending',
message: 'Not enough information to calculate host majority groups',
},
{
id: 'mtu-valid',
status: 'success',
message: '',
},
],
};

Expand Down
5 changes: 3 additions & 2 deletions libs/ui-lib/lib/common/components/hosts/HostStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ const HostStatusPopoverContent: React.FC<HostStatusPopoverContentProps> = ({
const { host } = props;
const { status, statusInfo } = host;
const { t } = useTranslation();

// eslint-disable-next-line no-console
console.log(status);
if (['installing-in-progress'].includes(status)) {
return (
<TextContent>
Expand Down Expand Up @@ -141,7 +142,7 @@ const HostStatusPopoverContent: React.FC<HostStatusPopoverContentProps> = ({
<Text>{details}</Text>
</TextContent>
)}
<HostValidationGroups {...props} />
<HostValidationGroups openshiftVersion={openshiftVersion} {...props} />
</StackItem>
</Stack>
);
Expand Down
63 changes: 58 additions & 5 deletions libs/ui-lib/lib/common/components/hosts/HostValidationGroups.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import React, { Fragment, ReactElement } from 'react';
import { Alert, AlertGroup, AlertVariant, Level, LevelItem } from '@patternfly/react-core';
import { global_warning_color_100 as warningColor } from '@patternfly/react-tokens/dist/js/global_warning_color_100';
Expand All @@ -9,6 +10,7 @@ import { ExclamationTriangleIcon } from '@patternfly/react-icons/dist/js/icons/e
import { Host, HostValidationId } from '@openshift-assisted/types/assisted-installer-service';
import { Validation, ValidationsInfo } from '../../types/hosts';
import {
getMtuLink,
hostValidationFailureHints,
hostValidationGroupLabels,
hostValidationLabels,
Expand All @@ -19,6 +21,7 @@ import { useTranslation } from '../../hooks/use-translation-wrapper';
import { getKeys } from '../../utils';

import './HostValidationGroups.css';
import { ExternalLinkAltIcon } from '@patternfly/react-icons/dist/js/icons/external-link-alt-icon';

export type AdditionNtpSourcePropsType = {
AdditionalNTPSourcesDialogToggleComponent?: React.FC;
Expand All @@ -39,6 +42,7 @@ export type ValidationInfoActionProps = AdditionNtpSourcePropsType &

type HostValidationGroupsProps = ValidationInfoActionProps & {
validationsInfo: ValidationsInfo;
openshiftVersion?: string;
};

type ValidationGroupAlertProps = ValidationInfoActionProps & {
Expand Down Expand Up @@ -145,6 +149,34 @@ const ApiVipConnectivityAlert = ({
);
};

const MtuInfoLink = ({ docsVersion }: { docsVersion: string }) => {
const { t } = useTranslation();
return (
<a href={getMtuLink(docsVersion)} target="_blank" rel="noopener noreferrer">
{t('ai:Learn more about MTU (maximum transmission unit)')} <ExternalLinkAltIcon />.
</a>
);
};

const MtuSyncAlert = ({
variant,
validation,
docsVersion,
}: {
variant: AlertVariant;
validation: Validation;
docsVersion: string;
}) => {
const { t } = useTranslation();
return (
<Alert title={t('ai:MTU (maximum transmission unit) failure')} variant={variant} isInline>
{toSentence(validation.message)} {hostValidationFailureHints(t)[validation.id]}
<br />
{<MtuInfoLink docsVersion={docsVersion} />}
</Alert>
);
};

const ValidationGroupAlerts = ({
validations,
title,
Expand All @@ -153,7 +185,8 @@ const ValidationGroupAlerts = ({
AdditionalNTPSourcesDialogToggleComponent,
UpdateDay2ApiVipDialogToggleComponent,
host,
}: ValidationGroupAlertProps) => {
openshiftVersion,
}: ValidationGroupAlertProps & { openshiftVersion?: string }) => {
if (!validations.length) {
return null;
}
Expand All @@ -162,6 +195,7 @@ const ValidationGroupAlerts = ({
['hostname-valid']: undefined,
['ntp-synced']: undefined,
['ignition-downloadable']: undefined,
['mtu-valid']: undefined,
};
const alerts = [];
const validationsWithoutActions: Validation[] = [];
Expand Down Expand Up @@ -210,6 +244,16 @@ const ValidationGroupAlerts = ({
/>,
);
}
if (validationsWithActions['mtu-valid'] && AdditionalNTPSourcesDialogToggleComponent) {
alerts.push(
<MtuSyncAlert
validation={validationsWithActions['mtu-valid']}
variant={variant}
key="mtu-sync-alert"
docsVersion={openshiftVersion || '4.17'}
/>,
);
}
if (validationsWithoutActions.length > 0) {
alerts.push(
<ValidationsAlert
Expand All @@ -223,20 +267,26 @@ const ValidationGroupAlerts = ({
return <AlertGroup>{alerts}</AlertGroup>;
};

export const HostValidationGroups = ({ validationsInfo, ...props }: HostValidationGroupsProps) => {
export const HostValidationGroups = ({
validationsInfo,
openshiftVersion,
...props
}: HostValidationGroupsProps) => {
const { t } = useTranslation();
return (
<>
{getKeys(validationsInfo).map((groupName) => {
const validations = validationsInfo[groupName] || [];

// eslint-disable-next-line no-console
console.log(validations);
const pendingValidations = validations.filter(
(v) => v.status === 'pending' && v.id !== 'ntp-synced',
);
const failedValidations = validations.filter(
(v) => (v.status === 'failure' || v.status === 'error') && v.id !== 'ntp-synced',
);

console.log('FAILED');
console.log(failedValidations);
const softValidations = validations.filter(
(v) => ['pending', 'failure', 'error'].includes(v.status) && v.id === 'ntp-synced',
);
Expand All @@ -261,7 +311,7 @@ export const HostValidationGroups = ({ validationsInfo, ...props }: HostValidati
</>
);
};

console.log(getValidationGroupState());
const groupLabel = hostValidationGroupLabels(t)[groupName] as string;
return (
<Fragment key={groupName}>
Expand All @@ -279,11 +329,13 @@ export const HostValidationGroups = ({ validationsInfo, ...props }: HostValidati
variant={AlertVariant.info}
title={t('ai:Pending validations:')}
validations={pendingValidations}
openshiftVersion={openshiftVersion}
{...props}
/>
<ValidationGroupAlerts
variant={AlertVariant.info}
validations={softValidations}
openshiftVersion={openshiftVersion}
title={''}
{...props}
/>
Expand All @@ -294,6 +346,7 @@ export const HostValidationGroups = ({ validationsInfo, ...props }: HostValidati
variant={AlertVariant.warning}
title={t('ai:Failed validations:')}
validations={failedValidations}
openshiftVersion={openshiftVersion}
{...props}
/>
</Fragment>
Expand Down
2 changes: 1 addition & 1 deletion libs/ui-lib/lib/common/components/hosts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export const areOnlySoftValidationsFailing = (validationsInfo: HostValidationsIn
);
if (!failingValidationIds.length) return false;
for (const id of failingValidationIds) {
if (!['ntp-synced', 'container-images-available'].includes(id)) {
if (!['ntp-synced', 'container-images-available', 'mtu-valid'].includes(id)) {
return false;
}
}
Expand Down
4 changes: 4 additions & 0 deletions libs/ui-lib/lib/common/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ export const hostValidationLabels = (t: TFunction): { [key in HostValidationId]:
'servicemesh-requirements-satisfied': t('ai:Service Mesh requirements'),
'openshift-ai-requirements-satisfied': t('ai:OpenShift AI requirements'),
'osc-requirements-satisfied': t('ai:OpenShift sandboxed containers requirements'),
'mtu-valid': t('ai:MTU requirements'),
'authorino-requirements-satisfied': '',
});

export const hostValidationFailureHints = (
Expand Down Expand Up @@ -192,6 +194,8 @@ export const hostValidationFailureHints = (
'servicemesh-requirements-satisfied': '',
'openshift-ai-requirements-satisfied': '',
'osc-requirements-satisfied': '',
'authorino-requirements-satisfied': '',
'mtu-valid': '',
});

export const clusterValidationLabels = (
Expand Down
5 changes: 5 additions & 0 deletions libs/ui-lib/lib/common/config/docs_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,8 @@ export const OPENSHIFT_AI_LINK =
'https://www.redhat.com/en/technologies/cloud-computing/openshift/openshift-ai';

export const OSC_LINK = 'https://docs.redhat.com/en/documentation/openshift_sandboxed_containers';

export const getMtuLink = (ocpVersion?: string) =>
`https://docs.redhat.com/en/documentation/openshift_container_platform/${getShortOpenshiftVersion(
ocpVersion,
)}/html/networking/changing-cluster-network-mtu#nw-cluster-mtu-change-about_changing-cluster-network-mtu`;
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ const flatValidationHostsDiscovery: HostValidation[] = [
message: 'a host validation message',
status: 'success',
},
{
id: 'mtu-valid',
message: 'a host validation message',
status: 'success',
},
];

const flatValidationHostsStorage: HostValidation[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ const hostDiscoveryStepValidationsMap: WizardStepValidationMap = {
'nvidia-gpu-requirements-satisfied',
'openshift-ai-requirements-satisfied',
'osc-requirements-satisfied',
'mtu-valid',
],
},
softValidationIds: ['no-skip-installation-disk', 'no-skip-missing-disk'],
Expand Down Expand Up @@ -227,7 +228,7 @@ const networkingStepValidationsMap: WizardStepValidationMap = {
// Alternatively we would have to whitelist network validations instead of using group
// 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'],
softValidationIds: ['ntp-synced', 'container-images-available', 'mtu-valid'],
};

const reviewStepValidationsMap: WizardStepValidationMap = {
Expand Down

0 comments on commit d6a58ca

Please sign in to comment.