Skip to content

Commit

Permalink
Show stopped by autoscaler info
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 committed Jun 14, 2024
1 parent 0883843 commit 9beff4d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const ActiveComponentOverview: FunctionComponent<{

{component.horizontalScalingSummary && (
<HorizontalScalingSummary
{...component.horizontalScalingSummary}
summary={component.horizontalScalingSummary}
/>
)}
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/components/page-active-component/dev.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HorizontalScalingSummary } from './horizontal-scaling-summary';
import { HorizontalScalingSummary as HorizontalScalingSummaryModel } from '../../store/radix-api';

const testData: Array<Parameters<typeof HorizontalScalingSummary>[0]> = [
const testData: Array<HorizontalScalingSummaryModel> = [
{
minReplicas: 4,
maxReplicas: 20,
Expand Down Expand Up @@ -40,7 +41,7 @@ export default (
backgroundColor: 'var(--eds_ui_background__default)',
}}
>
<HorizontalScalingSummary {...x} />
<HorizontalScalingSummary summary={x} />
</div>
))}
</>
Expand Down
31 changes: 16 additions & 15 deletions src/components/page-active-component/horizontal-scaling-summary.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Accordion, Typography } from '@equinor/eds-core-react';
import { isNil } from 'lodash';
import * as PropTypes from 'prop-types';
import { FunctionComponent } from 'react';

import {
HorizontalScalingSummary as HorizontalScalingSummaryModel,
Expand All @@ -10,9 +9,11 @@ import {
import { pluraliser } from '../../utils/string';
import { Alert } from '../alert';

export const HorizontalScalingSummary: FunctionComponent<
HorizontalScalingSummaryModel
> = (data) => (
type Props = {
summary: HorizontalScalingSummaryModel;
};

export const HorizontalScalingSummary = ({ summary }: Props) => (
<Accordion className="accordion elevated" chevronPosition="right">
<Accordion.Item isExpanded>
<Accordion.Header>
Expand All @@ -27,51 +28,51 @@ export const HorizontalScalingSummary: FunctionComponent<
<dl className="o-key-values">
<Typography as="dt">Current replicas:</Typography>
<Typography as="dd" variant="body_short_bold">
{data.currentReplicas}
{summary.currentReplicas}
</Typography>

<Typography as="dt">Desired replicas:</Typography>
<Typography as="dd" variant="body_short_bold">
{data.desiredReplicas}
{summary.desiredReplicas}
</Typography>

{!isNil(data.minReplicas) && (
{!isNil(summary.minReplicas) && (
<>
<Typography as="dt">Min replicas:</Typography>
<Typography as="dd" variant="body_short_bold">
{data.minReplicas}
{summary.minReplicas}
</Typography>
</>
)}

{!isNil(data.maxReplicas) && (
{!isNil(summary.maxReplicas) && (
<>
<Typography as="dt">Max replicas:</Typography>
<Typography as="dd" variant="body_short_bold">
{data.maxReplicas}
{summary.maxReplicas}
</Typography>
</>
)}

{data.pollingInterval > 0 && (
{summary.pollingInterval > 0 && (
<>
<Typography as="dt">Polling interval:</Typography>
<Typography as="dd" variant="body_short_bold">
{data.pollingInterval}sec
{summary.pollingInterval}sec
</Typography>
</>
)}

{data.cooldownPeriod > 0 && (
{summary.cooldownPeriod > 0 && (
<>
<Typography as="dt">Cooldown period:</Typography>
<Typography as="dd" variant="body_short_bold">
{data.cooldownPeriod}sec
{summary.cooldownPeriod}sec
</Typography>
</>
)}

{data.triggers.map((trigger, i) => (
{summary.triggers.map((trigger, i) => (
<TriggerStatus key={trigger.name + i} trigger={trigger} />
))}
</dl>
Expand Down
10 changes: 9 additions & 1 deletion src/components/page-active-component/overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,18 @@ export const Overview: FunctionComponent<{
const dnsExternalAliasUrls = dnsExternalAliases
? dnsExternalAliases.map((alias) => alias.fqdn)
: [];

const isStopped = component.status == 'Stopped';
const isScaledDown =
component.horizontalScalingSummary?.desiredReplicas === 0 && isStopped;

console.log({ component, isScaledDown, isStopped });

return (
<div className="grid grid--gap-medium">
<Typography variant="h4">Overview</Typography>

{component.status === 'Stopped' && (
{isStopped && !isScaledDown && (
<Alert>
Component has been manually stopped; please note that a new deployment
will cause it to be restarted unless you set <code>replicas</code> of
Expand All @@ -61,6 +68,7 @@ export const Overview: FunctionComponent<{
</Typography>
</Alert>
)}
{isScaledDown && <Alert>Component has been stopped by autoscaler.</Alert>}

<div className="grid grid--gap-medium grid--overview-columns">
<div className="grid grid--gap-medium">
Expand Down
8 changes: 6 additions & 2 deletions src/store/radix-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2203,13 +2203,13 @@ export type ExternalDns = {
};
export type HorizontalScalingSummaryTriggerStatus = {
/** CurrentUtilization is the last measured utilization */
current_utilization?: string;
currentUtilization?: string;
/** Error contains short description if trigger have problems */
error?: string;
/** Name of trigger */
name?: string;
/** TargetUtilization is the average target across replicas */
target_utilization?: string;
targetUtilization?: string;
/** Type of trigger */
type?: string;
};
Expand All @@ -2220,6 +2220,10 @@ export type HorizontalScalingSummary = {
currentCPUUtilizationPercentage?: number;
/** Deprecated: Component current average memory utilization over all pods, represented as a percentage of requested memory. Use Triggers instead. Will be removed from Radix API 2025-01-01. */
currentMemoryUtilizationPercentage?: number;
/** CurrentReplicas returns the current number of replicas */
currentReplicas?: number;
/** DesiredReplicas returns the target number of replicas across all triggers */
desiredReplicas?: number;
/** Component maximum replicas. From radixconfig.yaml */
maxReplicas?: number;
/** Component minimum replicas. From radixconfig.yaml */
Expand Down

0 comments on commit 9beff4d

Please sign in to comment.