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

Show keda scaling status #1040

Merged
merged 6 commits into from
Jun 14, 2024
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
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"deps": "npm run deps:license && npm run deps:stale",
"deps:license": "node scripts/deps-license-check.js",
"deps:stale": "node scripts/deps-stale-check.js",
"apigen:cost": "npx @rtk-query/codegen-openapi ./src/store/configs/cost-openapi-config.ts",
"apigen:log": "npx @rtk-query/codegen-openapi ./src/store/configs/log-openapi-config.ts",
"apigen:radix": "npx @rtk-query/codegen-openapi ./src/store/configs/radix-openapi-config.ts",
"apigen:scan": "npx @rtk-query/codegen-openapi ./src/store/configs/scan-openapi-config.ts",
"apigen:service-now": "npx @rtk-query/codegen-openapi ./src/store/configs/service-now-openapi-config.ts"
"apigen:cost": "npx @rtk-query/codegen-openapi ./src/store/configs/cost-openapi-config.cts",
"apigen:log": "npx @rtk-query/codegen-openapi ./src/store/configs/log-openapi-config.cts",
"apigen:radix": "npx @rtk-query/codegen-openapi ./src/store/configs/radix-openapi-config.cts",
"apigen:scan": "npx @rtk-query/codegen-openapi ./src/store/configs/scan-openapi-config.cts",
"apigen:service-now": "npx @rtk-query/codegen-openapi ./src/store/configs/service-now-openapi-config.cts"
},
"dependencies": {
"@azure/msal-browser": "^3.14.0",
Expand Down
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
106 changes: 66 additions & 40 deletions src/components/page-active-component/horizontal-scaling-summary.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
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 } from '../../store/radix-api';
import {
HorizontalScalingSummary as HorizontalScalingSummaryModel,
HorizontalScalingSummaryTriggerStatus,
} from '../../store/radix-api';
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 @@ -20,67 +26,55 @@ export const HorizontalScalingSummary: FunctionComponent<
<Accordion.Panel>
<div className="grid grid--gap-medium">
<dl className="o-key-values">
{!isNil(data.minReplicas) && (
<Typography as="dt">Current replicas:</Typography>
<Typography as="dd" variant="body_short_bold">
{summary.currentReplicas}
</Typography>

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

{!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}
</Typography>
</>
)}

{!isNil(data.currentCPUUtilizationPercentage) && (
<>
<Typography as="dt">
CPU utilization, current average:
</Typography>
<Typography as="dd" variant="body_short_bold">
{data.currentCPUUtilizationPercentage}%
{summary.maxReplicas}
</Typography>
</>
)}

{!isNil(data.targetCPUUtilizationPercentage) && (
{summary.pollingInterval > 0 && (
<>
<Typography as="dt">
CPU utilization, target average:
</Typography>
<Typography as="dt">Polling interval:</Typography>
<Typography as="dd" variant="body_short_bold">
{data.targetCPUUtilizationPercentage}%
{summary.pollingInterval}sec
</Typography>
</>
)}

{!isNil(data.currentMemoryUtilizationPercentage) && (
{summary.cooldownPeriod > 0 && (
<>
<Typography as="dt">
Memory utilization, current average:
</Typography>
<Typography as="dt">Cooldown period:</Typography>
<Typography as="dd" variant="body_short_bold">
{data.currentMemoryUtilizationPercentage}%
{summary.cooldownPeriod}sec
</Typography>
</>
)}

{!isNil(data.targetMemoryUtilizationPercentage) && (
<>
<Typography as="dt">
Memory utilization, target average:
</Typography>
<Typography as="dd" variant="body_short_bold">
{data.targetMemoryUtilizationPercentage}%
</Typography>
</>
)}
{summary.triggers.map((trigger, i) => (
<TriggerStatus key={trigger.name + i} trigger={trigger} />
))}
</dl>
</div>
</Accordion.Panel>
Expand All @@ -96,3 +90,35 @@ HorizontalScalingSummary.propTypes = {
targetCPUUtilizationPercentage: PropTypes.number,
targetMemoryUtilizationPercentage: PropTypes.number,
};

type TriggerStatusProps = {
trigger: HorizontalScalingSummaryTriggerStatus;
};
const TriggerStatus = ({ trigger }: TriggerStatusProps) => {
let unitFn = pluraliser('%', '%');

if (trigger.type == 'cron') unitFn = pluraliser('replica', 'replicas');
if (trigger.type == 'azure-servicebus')
unitFn = pluraliser('message', 'messages');

return (
<>
<Typography as="dt">{trigger.name}:</Typography>
<Typography as="dd">
<strong>
{trigger.currentUtilization
? unitFn(Number(trigger.currentUtilization))
: '-'}
</strong>{' '}
of <strong>{unitFn(Number(trigger.targetUtilization))} </strong>
target utilization
{trigger.error && (
<>
<br />
<Alert type={'danger'}>{trigger.error}</Alert>
</>
)}
</Typography>
</>
);
};
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
14 changes: 14 additions & 0 deletions src/store/cost-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,35 @@ export type GetTotalCostsApiArg = {
'Impersonate-Group'?: string;
};
export type ApplicationCost = {
/** Comment regarding cost */
comment?: string;
/** Cost */
cost: number;
/** CostPercentageByCPU is cost percentage by CPU for the application. */
costPercentageByCpu?: number;
/** CostPercentageByMemory is cost percentage by memory for the application */
costPercentageByMemory?: number;
/** Creator of the application. */
creator?: string;
/** Cost currency */
currency: string;
/** Name of the application */
name: string;
/** Owner of the application (email). Can be a single person or a shared group email. */
owner?: string;
/** WBS for the application. */
wbs?: string;
};
export type ApplicationCostSet = {
/** ApplicationCosts with costs. */
applicationCosts: ApplicationCost[];
/** ApplicationCostSet period started From */
from: string;
/** ApplicationCostSet period continued To */
to: string;
/** TotalRequestedCPU within the period. */
totalRequestedCpu?: number;
/** TotalRequestedMemory within the period. */
totalRequestedMemory?: number;
};
export const {
Expand Down
32 changes: 27 additions & 5 deletions src/store/radix-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2201,19 +2201,41 @@ export type ExternalDns = {
fqdn: string;
tls: Tls;
};
export type HorizontalScalingSummaryTriggerStatus = {
/** CurrentUtilization is the last measured utilization */
currentUtilization?: string;
/** Error contains short description if trigger have problems */
error?: string;
/** Name of trigger */
name?: string;
/** TargetUtilization is the average target across replicas */
targetUtilization?: string;
/** Type of trigger */
type?: string;
};
export type HorizontalScalingSummary = {
/** Component current average CPU utilization over all pods, represented as a percentage of requested CPU */
/** CooldownPeriod in seconds. From radixconfig.yaml */
cooldownPeriod?: number;
/** Deprecated: Component current average CPU utilization over all pods, represented as a percentage of requested CPU. Use Triggers instead. Will be removed from Radix API 2025-01-01. */
currentCPUUtilizationPercentage?: number;
/** Component current average memory utilization over all pods, represented as a percentage of requested memory */
/** 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 */
minReplicas?: number;
/** Component target average CPU utilization over all pods */
/** PollingInterval in seconds. From radixconfig.yaml */
pollingInterval?: number;
/** Deprecated: Component target average CPU utilization over all pods. Use Triggers instead. Will be removed from Radix API 2025-01-01. */
targetCPUUtilizationPercentage?: number;
/** Component target average memory utilization over all pods */
/** Deprecated: Component target average memory utilization over all pods. use Triggers instead. Will be removed from Radix API 2025-01-01. */
targetMemoryUtilizationPercentage?: number;
/** Triggers lists status of all triggers found in radixconfig.yaml */
triggers?: HorizontalScalingSummaryTriggerStatus[];
};
export type AzureIdentity = {
/** The Azure Key Vaults names, which use Azure Identity */
Expand Down Expand Up @@ -2332,7 +2354,7 @@ export type Component = {
ports?: Port[];
/** Array of ReplicaSummary */
replicaList?: ReplicaSummary[];
/** Array of pod names */
/** Deprecated: Array of pod names. Use ReplicaList instead */
replicas?: string[];
resources?: ResourceRequirements;
/** ScheduledJobPayloadPath defines the payload path, where payload for Job Scheduler will be mapped as a file. From radixconfig.yaml */
Expand Down
Loading