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

feat(OCPADVISOR-71): Show upgrade risks table #547

Merged
merged 11 commits into from
Apr 18, 2023
4 changes: 4 additions & 0 deletions compiled-lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
"noRecsForClusterListTitle": "No clusters yet",
"noRecsFoundError": "No recommendations to display",
"noRecsFoundErrorDesc": "Insights identifies and prioritizes risks to security, performance, availability, and stability of your clusters. This feature uses the Remote Health functionality of OpenShift Container Platform. For further details about Insights, see the",
"noUpgradeRisksFound": "No upgrade risks found for this cluster",
"noUpgradeRisksFoundDesc": "There are no known update risks that affect this cluster.",
"none": "None",
"oneOrMore": "1 or more",
"performance": "Performance",
Expand Down Expand Up @@ -116,6 +118,8 @@
"undefined": "Undefined",
"unknown": "Unknown",
"upgradeRisks": "Upgrade risks",
"upgradeRisksNotAvailable": "Upgrade risks are not available",
"upgradeRisksNotAvailableDesc": "This cluster has gone more than two hours without sending metrics. Check the cluster's web console if you think that this is incorrect.",
"version": "Version",
"veryLow": "Very Low",
"viewAffectedClusters": "View {clusters, plural, one {the affected cluster} other {# affected clusters}}",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"status": "ok",
"upgrade_recommendation": {
"upgrade_risks_predictors": {
"alerts": [
{
"name": "ClusterOperatorDown",
"namespace": "openshift-monitoring",
"severity": "critical"
},
{
"name": "PostDisruptionBudgetLimit",
"namespace": "openshift-etcd",
"severity": "warning"
},
{
"name": "Cluster operators",
"namespace": "openshift-kube-apiserver",
"severity": "info"
}
],
"operator_conditions": [
{
"name": "Version",
"condition": "failing"
},
{
"name": "Node-tuning",
"condition": "degraded",
"reason": "Multiple tasks failed"
}
]
}
}
}
6 changes: 3 additions & 3 deletions src/Components/ClusterTabs/ClusterTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import messages from '../../Messages';
import { setSearchParameter } from '../../Utilities/Helpers';
import { useUpgradeRisksFeatureFlag } from '../../Utilities/useFeatureFlag';
import ClusterRules from '../ClusterRules/ClusterRules';
import { ComingSoon } from '../MessageState/EmptyStates';
import { UpgradeRisksTable } from '../UpgradeRisksTable';

const CLUSTER_TABS = ['recommendations', 'upgrade_risks'];

Expand All @@ -26,7 +26,7 @@ const ClusterTabs = () => {
});

return (
<Card isCompact>
<Card isCompact isPlain>
<CardBody>
<Tabs
activeKey={activeKey}
Expand All @@ -47,7 +47,7 @@ const ClusterTabs = () => {
eventKey="upgrade_risks"
title={intl.formatMessage(messages.upgradeRisks)}
>
<ComingSoon />
<UpgradeRisksTable />
</Tab>
)}
</Tabs>
Expand Down
28 changes: 28 additions & 0 deletions src/Components/MessageState/EmptyStates.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { InProgressIcon } from '@patternfly/react-icons/dist/esm/icons/in-progre
import InfoCircleIcon from '@patternfly/react-icons/dist/js/icons/info-circle-icon';
import { global_info_color_100 as globalInfoColor100 } from '@patternfly/react-tokens/dist/js/global_info_color_100.js';
import CheckIcon from '@patternfly/react-icons/dist/js/icons/check-icon';
import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';

import DefaultErrorMessage from '@redhat-cloud-services/frontend-components/ErrorState/DefaultErrorMessage';

Expand Down Expand Up @@ -187,6 +188,31 @@ const NoRecsAffecting = () => {
);
};

const NoUpgradeRisks = () => {
const intl = useIntl();
return (
<MessageState
icon={CheckCircleIcon}
iconStyle={{
color: globalSuccessColor100.value,
}}
title={intl.formatMessage(messages.noUpgradeRisksFound)}
text={intl.formatMessage(messages.noUpgradeRisksFoundDesc)}
/>
);
};

const UpgradeRisksNotAvailable = () => {
const intl = useIntl();
return (
<MessageState
icon={ExclamationTriangleIcon}
title={intl.formatMessage(messages.upgradeRisksNotAvailable)}
text={intl.formatMessage(messages.upgradeRisksNotAvailableDesc)}
/>
);
};

export {
ErrorState,
NoAffectedClusters,
Expand All @@ -197,4 +223,6 @@ export {
NoInsightsResults,
NoRecsError,
NoRecsAffecting,
NoUpgradeRisks,
UpgradeRisksNotAvailable,
};
4 changes: 3 additions & 1 deletion src/Components/MessageState/MessageState.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ const MessageState = ({
<Title headingLevel="h5" size="lg">
{title}
</Title>
<EmptyStateBody style={{ marginBottom: '16px' }}>{text}</EmptyStateBody>
<EmptyStateBody style={{ marginBottom: '16px', maxWidth: '400px' }}>
{text}
</EmptyStateBody>
{children}
</EmptyState>
);
Expand Down
89 changes: 89 additions & 0 deletions src/Components/UpgradeRisksTable/AlertsList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { Flex, Icon } from '@patternfly/react-core';
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';
import {
TableComposable,
Tbody,
Td,
Th,
Thead,
Tr,
} from '@patternfly/react-table';
import React from 'react';
import { useParams } from 'react-router-dom';
import { useGetUpgradeRisksQuery } from '../../Services/SmartProxy';

export const ALERTS_SEVERITY_ICONS = {
critical: (
<Icon status="danger">
<ExclamationCircleIcon />
</Icon>
),
warning: (
<Icon status="warning">
<ExclamationTriangleIcon />
</Icon>
),
info: (
<Icon status="info">
<InfoCircleIcon />
</Icon>
),
};

export const ALERTS_SEVERITY_LABEL = {
critical: (
<Flex alignItems={{ default: 'alignItemsCenter' }}>
{ALERTS_SEVERITY_ICONS['critical']} <b>Critical</b>
</Flex>
),
warning: (
<Flex alignItems={{ default: 'alignItemsCenter' }}>
{ALERTS_SEVERITY_ICONS['warning']} <b>Warning</b>
</Flex>
),
info: (
<Flex alignItems={{ default: 'alignItemsCenter' }}>
{ALERTS_SEVERITY_ICONS['info']} <b>Info</b>
</Flex>
),
};

export const ALERTS_SEVERITY_ORDER = ['critical', 'warning', 'info'];

const AlertsList = () => {
const { clusterId } = useParams();
const { data } = useGetUpgradeRisksQuery({ id: clusterId });
const { alerts = [] } =
data?.upgrade_recommendation?.upgrade_risks_predictors || {};

return (
<TableComposable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When comparing to the mocks I see a few links/icons that arent shown here.
Your version:
Screen Shot 2023-04-14 at 9 16 19 AM

mock version:
Screen Shot 2023-04-14 at 9 17 15 AM

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. there is no final agreement on the docs URL, so I'd wait for folks first to decide and then will add it via separate PR most probably

aria-label="Alerts firing table"
variant="compact"
borders={false}
>
<Thead>
<Tr>
<Th width={50}>Name</Th>
<Th width={25}>Status</Th>
<Th width={25}>Namespace</Th>
</Tr>
</Thead>
<Tbody>
{alerts.map(({ name, namespace, severity }) => (
<Tr key={name}>
<Td className="alerts__name">{name}</Td>
<Td className="alerts__severity">
{ALERTS_SEVERITY_LABEL[severity]}
</Td>
<Td className="alerts__namespace">{namespace}</Td>
</Tr>
))}
</Tbody>
</TableComposable>
);
};

export default AlertsList;
61 changes: 61 additions & 0 deletions src/Components/UpgradeRisksTable/ClusterOperatorsList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from 'react';
import {
TableComposable,
Tbody,
Td,
Th,
Thead,
Tr,
} from '@patternfly/react-table';
import { useParams } from 'react-router-dom';
import { useGetUpgradeRisksQuery } from '../../Services/SmartProxy';
import { Flex, Icon } from '@patternfly/react-core';
import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';

export const CLUSTER_OPERATOR_LABEL = {
degraded: 'Degraded',
failing: 'Failing',
available: 'Not Available',
upgradeable: 'Not Upgradeable',
};

const ClusterOperatorsList = () => {
const { clusterId } = useParams();
const { data } = useGetUpgradeRisksQuery({ id: clusterId });
const { operator_conditions: conditions = [] } =
data?.upgrade_recommendation?.upgrade_risks_predictors || {};

return (
<TableComposable
aria-label="Cluster operators firing table"
variant="compact"
borders={false}
>
<Thead>
<Tr>
<Th width={50}>Name</Th>
<Th width={25}>Status</Th>
<Th width={25}>Message</Th>
</Tr>
</Thead>
<Tbody>
{conditions.map(({ name, condition, reason }) => (
<Tr key={name}>
<Td class="operators__name">{name}</Td>
<Td class="operators__status">
<Flex alignItems={{ default: 'alignItemsCenter' }}>
<Icon status="warning">
<ExclamationTriangleIcon />
</Icon>
<b>{CLUSTER_OPERATOR_LABEL[condition]}</b>
</Flex>
</Td>
<Td class="operators__message">{reason || '-'}</Td>
</Tr>
))}
</Tbody>
</TableComposable>
);
};

export default ClusterOperatorsList;
Loading