Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display a warning if preserve static IPs are enabled with pod network mapping #1387

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
"First root device": "First root device",
"Flavor": "Flavor",
"Folder": "Folder",
"For fixing, update the destination network mappings to avoid using the 'Pod Networking' type.": "For fixing, update the destination network mappings to avoid using the 'Pod Networking' type.",
"GPUs/Host Devices": "GPUs/Host Devices",
"Hide from view": "Hide from view",
"Hide values": "Hide values",
Expand Down Expand Up @@ -373,6 +374,7 @@
"Preserve static IPs": "Preserve static IPs",
"Preserve the CPU model and flags the VM runs with in its oVirt cluster.": "Preserve the CPU model and flags the VM runs with in its oVirt cluster.",
"Preserve the static IPs of virtual machines migrated from vSphere.": "Preserve the static IPs of virtual machines migrated from vSphere.",
"Preserving static IPs of VMs might fail": "Preserving static IPs of VMs might fail",
"Product": "Product",
"Progress": "Progress",
"Project": "Project",
Expand Down Expand Up @@ -482,8 +484,10 @@
"The limit for memory usage by the inventory container, specified in Megabytes (Mi). Default value is 1000Mi.": "The limit for memory usage by the inventory container, specified in Megabytes (Mi). Default value is 1000Mi.",
"The Manager CA certificate unless it was replaced by a third-party certificate, in which case, enter the Manager Apache CA certificate.": "The Manager CA certificate unless it was replaced by a third-party certificate, in which case, enter the Manager Apache CA certificate.",
"The password for the ESXi host admin": "The password for the ESXi host admin",
"The plan is not ready - ": "The plan is not ready - ",
"The provider is not ready - ": "The provider is not ready - ",
"The plan is not ready": "The plan is not ready",
"The plan is set to preserve the static IPs of VMs mapped to a Pod network type. This is not supported and therefore VM IPs can be changed during the migration process.": "The plan is set to preserve the static IPs of VMs mapped to a Pod network type. This is not supported and therefore VM IPs can be changed during the migration process.",
"The plan migration might not work as expected": "The plan migration might not work as expected",
"The provider is not ready": "The provider is not ready",
"The provider is not ready.": "The provider is not ready.",
"The provider's CA certificate will be validated.": "The provider's CA certificate will be validated.",
"The provider's CA certificate won't be validated.": "The provider's CA certificate won't be validated.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import Linkify from 'react-linkify';
import { EMPTY_MSG } from 'src/utils/constants';

import { Alert, Text, TextContent, TextVariants } from '@patternfly/react-core';

Expand All @@ -13,7 +14,7 @@ export const NetworkMapCriticalConditions: React.FC<{ type: string; message: str
<Alert title={type} variant="danger">
<TextContent className="forklift-providers-list-header__alert">
<Text component={TextVariants.p}>
<Linkify>{message || '-'}</Linkify>
<Linkify>{message || EMPTY_MSG}</Linkify>
<br />
{t('To troubleshoot, check the Forklift controller pod logs.')}
</Text>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import Linkify from 'react-linkify';
import { EMPTY_MSG } from 'src/utils/constants';

import { Alert, Text, TextContent, TextVariants } from '@patternfly/react-core';

Expand All @@ -13,7 +14,7 @@ export const PlanCriticalConditions: React.FC<{ type: string; message: string }>
<Alert title={type} variant="danger">
<TextContent className="forklift-providers-list-header__alert">
<Text component={TextVariants.p}>
<Linkify>{message || '-'}</Linkify>
<Linkify>{message || EMPTY_MSG}</Linkify>
<br />
{t('To troubleshoot, check the Forklift controller pod logs.')}
</Text>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import Linkify from 'react-linkify';
import { EMPTY_MSG } from 'src/utils/constants';

import { Alert, Text, TextContent, TextVariants } from '@patternfly/react-core';
import { Alert, AlertVariant, Text, TextContent, TextVariants } from '@patternfly/react-core';

export const PlanCriticalCondition: React.FC<{ type: string; message: string }> = ({
type,
message,
}) => {
const PlanCriticalCondition: React.FC<{ type: string; message: string }> = ({ type, message }) => {
const { t } = useTranslation();
return (
<Alert title={t('The plan is not ready - ') + type} variant="danger">
<Alert title={t('The plan is not ready') + ' - ' + type} variant={AlertVariant.danger}>
<TextContent className="forklift-providers-list-header__alert">
<Text component={TextVariants.p}>
<Linkify>{message || '-'}</Linkify>
<Linkify>{message || EMPTY_MSG}</Linkify>
{'. '}
{t('To troubleshoot, check the Forklift controller pod logs.')}
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ import { useModal } from 'src/modules/Providers/modals';
import { PageHeadings } from 'src/modules/Providers/utils';
import { useForkliftTranslation } from 'src/utils';

import { PlanModel, PlanModelGroupVersionKind, V1beta1Plan } from '@kubev2v/types';
import {
NetworkMapModelGroupVersionKind,
PlanModel,
PlanModelGroupVersionKind,
V1beta1NetworkMap,
V1beta1Plan,
} from '@kubev2v/types';
import { useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk';
import { Button, Level, LevelItem, PageSection } from '@patternfly/react-core';
import StartIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
import ReStartIcon from '@patternfly/react-icons/dist/esm/icons/redo-icon';

import PlanCriticalCondition from './PlanCriticalCondition';
import PlanWarningCondition from './PlanWarningCondition';

export const PlanPageHeadings: React.FC<{ name: string; namespace: string }> = ({
name,
Expand All @@ -22,13 +29,20 @@ export const PlanPageHeadings: React.FC<{ name: string; namespace: string }> = (
const { t } = useForkliftTranslation();
const { showModal } = useModal();

const [plan, loaded, error] = useK8sWatchResource<V1beta1Plan>({
const [plan, planLoaded, planError] = useK8sWatchResource<V1beta1Plan>({
groupVersionKind: PlanModelGroupVersionKind,
namespaced: true,
name,
namespace,
});

const [netMaps, netMapsLoaded, netMapsError] = useK8sWatchResource<V1beta1NetworkMap[]>({
groupVersionKind: NetworkMapModelGroupVersionKind,
namespaced: true,
isList: true,
namespace,
});

const permissions = useGetDeleteAndEditAccessReview({
model: PlanModel,
namespace,
Expand All @@ -44,10 +58,27 @@ export const PlanPageHeadings: React.FC<{ name: string; namespace: string }> = (
const buttonStartIcon = canReStart ? <ReStartIcon /> : <StartIcon />;

const criticalCondition =
loaded &&
!error &&
planLoaded &&
!planError &&
plan?.status?.conditions?.find((condition) => condition?.category === 'Critical');

/**
* Check if the preserve static IPs is enabled with pod networking mapping.
*/
const preserveIpsWithPodMapCondition = (): boolean => {
if (!netMapsLoaded || netMapsError) return false;

const isPreserveStaticIPs = plan?.spec?.preserveStaticIPs;
const planNetMaps = (netMaps || []).find(
(net) => net?.metadata?.name === plan?.spec?.map?.network?.name,
);

const isMapToPod =
planNetMaps?.spec?.map.find((map) => map.destination.type === 'pod') !== undefined;

return isPreserveStaticIPs && isMapToPod;
};

if (criticalCondition) {
alerts.push(
<PlanCriticalCondition
Expand All @@ -56,6 +87,18 @@ export const PlanPageHeadings: React.FC<{ name: string; namespace: string }> = (
key={'providerCriticalCondition'}
/>,
);
} else if (preserveIpsWithPodMapCondition()) {
metalice marked this conversation as resolved.
Show resolved Hide resolved
alerts.push(
<PlanWarningCondition
type={t('Preserving static IPs of VMs might fail')}
message={t(
'The plan is set to preserve the static IPs of VMs mapped to a Pod network type. This is not supported and therefore VM IPs can be changed during the migration process.',
)}
suggestion={t(
"For fixing, update the destination network mappings to avoid using the 'Pod Networking' type.",
)}
/>,
);
}

const onClick = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import Linkify from 'react-linkify';
import { EMPTY_MSG } from 'src/utils/constants';

import { Alert, AlertVariant, Text, TextContent, TextVariants } from '@patternfly/react-core';

const PlanWarningCondition: React.FC<{
type: string;
message: string;
suggestion: string;
}> = ({ type, message, suggestion }) => {
const { t } = useTranslation();
return (
<Alert
title={t('The plan migration might not work as expected') + ' - ' + type}
variant={AlertVariant.warning}
>
<TextContent className="forklift-providers-list-header__alert">
<Text component={TextVariants.p}>
<Linkify>{message || EMPTY_MSG}</Linkify>
<br />
<br />
<Linkify>{suggestion || EMPTY_MSG}</Linkify>
</Text>
</TextContent>
</Alert>
);
};

export default PlanWarningCondition;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * from './MappingListItem';
export * from './MigrationsSection';
export * from './PlanCriticalCondition';
export * from './PlanPageHeadings';
export * from './PlanWarningCondition';
export * from './ProvidersSection';
export * from './SettingsSection';
export * from './Suspend';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import Linkify from 'react-linkify';
import { EMPTY_MSG } from 'src/utils/constants';

import { Alert, Text, TextContent, TextVariants } from '@patternfly/react-core';

Expand All @@ -10,10 +11,10 @@ export const ProviderCriticalCondition: React.FC<{ type: string; message: string
}) => {
const { t } = useTranslation();
return (
<Alert title={t('The provider is not ready - ') + type} variant="danger">
<Alert title={t('The provider is not ready') + ' - ' + type} variant="danger">
<TextContent className="forklift-providers-list-header__alert">
<Text component={TextVariants.p}>
<Linkify>{message || '-'}</Linkify>
<Linkify>{message || EMPTY_MSG}</Linkify>
{'. '}
{t('To troubleshoot, check the Forklift controller pod logs.')}
</Text>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import Linkify from 'react-linkify';
import { EMPTY_MSG } from 'src/utils/constants';

import { Alert, Text, TextContent, TextVariants } from '@patternfly/react-core';

Expand All @@ -13,7 +14,7 @@ export const StorageMapCriticalConditions: React.FC<{ type: string; message: str
<Alert title={type} variant="danger">
<TextContent className="forklift-providers-list-header__alert">
<Text component={TextVariants.p}>
<Linkify>{message || '-'}</Linkify>
<Linkify>{message || EMPTY_MSG}</Linkify>
<br />
{t('To troubleshoot, check the Forklift controller pod logs.')}
</Text>
Expand Down
1 change: 1 addition & 0 deletions packages/forklift-console-plugin/src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const EMPTY_MSG = '-';
1 change: 1 addition & 0 deletions packages/forklift-console-plugin/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @index(['./*', /style/g], f => `export * from '${f.path}';`)
export * from './constants';
export * from './deepCopy';
export * from './enums';
export * from './fetch';
Expand Down
Loading