Skip to content

Commit c2e7d15

Browse files
authored
Pull request update/250428
56bf836 OSN-823. Category for LB + skip metrics for Basic LB 6770e09 OSN-765: Compact S3 Duplicate Buckets List ede9c79 OSN-804. Fixed division by zero in rightsizing_instances 8a0c750 OSN-821. Added action for testing run_observer
2 parents f31dbe8 + 56bf836 commit c2e7d15

File tree

13 files changed

+123
-44
lines changed

13 files changed

+123
-44
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build run_observer test image and run tests on it
2+
run-name: Build run_observer test image and run tests on it - started by ${{ github.actor }}
3+
permissions: read-all
4+
on:
5+
pull_request:
6+
types: [opened, synchronize]
7+
paths:
8+
- 'docker_images/run_observer/**'
9+
workflow_dispatch:
10+
11+
12+
jobs:
13+
build_image:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v3
18+
- name: Login to Docker Hub (optional)
19+
env:
20+
username: ${{ secrets.EXT_DOCKER_LOGIN }}
21+
password: ${{ secrets.EXT_DOCKER_TOKEN }}
22+
if: ${{ env.username != '' && env.password != ''}}
23+
uses: docker/login-action@v3
24+
with:
25+
username: ${{ env.username }}
26+
password: ${{ env.password }}
27+
- name: Build image
28+
run: bash -x build.sh run_observer build
29+
- name: Build test image and run tests
30+
run: bash -x docker_images/run_test.sh run_observer

bumiworker/bumiworker/modules/rightsizing_base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,10 @@ def get_base_azure_instances_info(self, cloud_resources,
476476
continue
477477
res_id = r['_id']['resource_id']
478478
meter_id = r['_id']['meter_id']
479-
day_cost = r['cost'] * HOURS_IN_DAY / r['usage_quantity']
479+
usage = r['usage_quantity']
480+
if not usage:
481+
continue
482+
day_cost = r['cost'] * HOURS_IN_DAY / usage
480483
data = {
481484
'day_cost': day_cost,
482485
'total_cost': r['cost'],

docker_images/run_observer/run_observer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def observe(self):
108108
if runs_to_update:
109109
self.mongo_client.arcee.run.bulk_write(runs_to_update)
110110
runs_to_update.clear()
111-
LOG.info(f"Finished processing for organization {organization_id},"
112-
f"updated {run_count} runs")
111+
LOG.info("Finished processing for organization %s,"
112+
"updated %s runs", organization_id, run_count)
113113

114114

115115
if __name__ == "__main__":

metroculus/metroculus_worker/processor.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,16 @@ def start(self):
206206
'Cloud %s is not supported' % cloud_type)
207207

208208
adapter = self._get_cloud_adapter(cloud_account)
209+
additional_params = {}
210+
if cloud_type == 'azure_cnr':
211+
# metrics are not supported for Basic LB
212+
additional_params['meta.category'] = {'$ne': 'Basic'}
209213
cloud_account_resources = list(
210214
self.mongo_client.restapi.resources.find({
211215
'cloud_account_id': cloud_account['id'],
212216
'active': True,
213-
'resource_type': {'$in': SUPPORTED_RESOURCE_TYPES}
217+
'resource_type': {'$in': SUPPORTED_RESOURCE_TYPES},
218+
**additional_params
214219
}, ['_id', 'last_seen', 'cloud_resource_id',
215220
'region', 'resource_type', 'name', 'k8s_namespace',
216221
'meta.source_cluster_id', 'meta.ram']

ngui/ui/src/components/DashedTypography/DashedTypography.styles.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@ import { makeStyles } from "tss-react/mui";
33
const useStyles = makeStyles()(() => ({
44
dashed: {
55
display: "inline",
6-
borderBottom: "1px dashed",
7-
width: "fit-content"
6+
position: "relative",
7+
width: "fit-content",
8+
"&:after": {
9+
content: '""',
10+
position: "absolute",
11+
bottom: -1,
12+
left: 0,
13+
width: "100%",
14+
borderBottom: "1px dashed"
15+
}
816
},
917
cursorPointer: {
1018
"&:hover": {

ngui/ui/src/components/ExpandableList/ExpandableList.tsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ type ExpandableListProps<T> = {
1010
stopPropagationOnShowMore?: boolean;
1111
};
1212

13-
const ExpandableList = <T,>({
14-
items,
15-
render,
16-
maxRows = undefined,
17-
stopPropagationOnShowMore = false
18-
}: ExpandableListProps<T>) => {
13+
const Expander = <T,>({ items, render, maxRows = undefined, stopPropagationOnShowMore = false }: ExpandableListProps<T>) => {
1914
const [isExpanded, setIsExpanded] = useToggle(false);
2015

2116
const content = useMemo(() => {
@@ -24,27 +19,34 @@ const ExpandableList = <T,>({
2419
return itemsToShow.map((item, i, array) => render(item, i, array));
2520
}, [isExpanded, items, maxRows, render]);
2621

27-
const expander = () => (
28-
<DashedTypography
29-
onClick={(event) => {
30-
if (stopPropagationOnShowMore) {
31-
event.stopPropagation();
32-
}
33-
setIsExpanded();
34-
}}
35-
>
36-
<FormattedMessage id={isExpanded ? "showLess" : "showMore"} />
37-
</DashedTypography>
38-
);
39-
40-
const showExpander = isExpanded || content.length !== items.length;
41-
4222
return (
4323
<>
4424
{content}
45-
{showExpander && expander()}
25+
<DashedTypography
26+
onClick={(event) => {
27+
if (stopPropagationOnShowMore) {
28+
event.stopPropagation();
29+
}
30+
setIsExpanded();
31+
}}
32+
>
33+
<FormattedMessage id={isExpanded ? "showLess" : "showMore"} />
34+
</DashedTypography>
4635
</>
4736
);
4837
};
4938

39+
const ExpandableList = <T,>({
40+
items,
41+
render,
42+
maxRows = undefined,
43+
stopPropagationOnShowMore = false
44+
}: ExpandableListProps<T>) => {
45+
if (maxRows && items.length > maxRows) {
46+
return <Expander items={items} render={render} maxRows={maxRows} stopPropagationOnShowMore={stopPropagationOnShowMore} />;
47+
}
48+
49+
return items.map((item, i, array) => render(item, i, array));
50+
};
51+
5052
export default ExpandableList;

ngui/ui/src/components/S3DuplicateFinderCheck/S3DuplicateFinderCheck.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { FormattedMessage } from "react-intl";
44
import { Link as RouterLink } from "react-router-dom";
55
import ActionBar from "components/ActionBar";
66
import FormattedDigitalUnit, { SI_UNITS } from "components/FormattedDigitalUnit";
7-
import KeyValueLabel from "components/KeyValueLabel/KeyValueLabel";
7+
import KeyValueLabel from "components/KeyValueLabel";
88
import PageContentWrapper from "components/PageContentWrapper";
9+
import S3DuplicatesBucketsList from "components/S3DuplicatesBucketsList";
910
import TypographyLoader from "components/TypographyLoader";
1011
import { RECOMMENDATIONS, S3_DUPLICATE_FINDER } from "urls";
1112
import { MB } from "utils/constants";
@@ -125,10 +126,7 @@ const S3DuplicateFinderCheck = ({ gemini: checkData, thresholds, isLoadingProps
125126
<TypographyLoader linesCount={2} />
126127
) : (
127128
<>
128-
<KeyValueLabel
129-
keyMessageId="selectedBuckets"
130-
value={filtersBuckets.map(({ name: bucketName }) => bucketName).join(", ")}
131-
/>
129+
<S3DuplicatesBucketsList bucketNames={filtersBuckets.map(({ name: bucketName }) => bucketName)} />
132130
<KeyValueLabel
133131
keyMessageId="minimumObjectSize"
134132
value={<FormattedDigitalUnit value={minSize / MB} baseUnit={SI_UNITS.MEGABYTE} />}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Box, Typography } from "@mui/material";
2+
import { FormattedMessage } from "react-intl";
3+
import ExpandableList from "components/ExpandableList";
4+
import HtmlSymbol from "components/HtmlSymbol";
5+
import { isLastItem } from "utils/arrays";
6+
7+
type S3DuplicatesBucketsListProps = {
8+
bucketNames: string[];
9+
};
10+
11+
const S3DuplicatesBucketsList = ({ bucketNames }: S3DuplicatesBucketsListProps) => (
12+
<Box display="flex" columnGap="4px" rowGap="2px" flexWrap="wrap" alignItems="center">
13+
<Typography noWrap component="span">
14+
<FormattedMessage id="selectedBuckets" />
15+
&#58;
16+
</Typography>
17+
<ExpandableList
18+
items={bucketNames}
19+
render={(bucketName, index, items) => (
20+
<Typography key={bucketName}>
21+
<strong>{bucketName}</strong>
22+
{!isLastItem(index, items.length) && <HtmlSymbol symbol="comma" />}
23+
</Typography>
24+
)}
25+
maxRows={5}
26+
/>
27+
</Box>
28+
);
29+
30+
export default S3DuplicatesBucketsList;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import S3DuplicatesBucketsList from "./S3DuplicatesBucketsList";
2+
3+
export default S3DuplicatesBucketsList;

ngui/ui/src/components/forms/CreateS3DuplicateFinderCheckForm/FormElements/BucketsField.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { useEffect, useMemo } from "react";
22
import { FormControl, FormHelperText } from "@mui/material";
3-
import Typography from "@mui/material/Typography";
43
import { Controller, useFormContext } from "react-hook-form";
54
import { FormattedMessage, useIntl } from "react-intl";
65
import CloudResourceId from "components/CloudResourceId";
6+
import S3DuplicatesBucketsList from "components/S3DuplicatesBucketsList";
77
import Table from "components/Table";
88
import TableLoader from "components/TableLoader";
99
import { resourceLocation } from "utils/columns";
@@ -131,14 +131,7 @@ const BucketsField = ({ buckets, dataSources, isLoading }) => {
131131
) : (
132132
<>
133133
<TableField buckets={buckets} dataSources={dataSources} value={value} onChange={onChange} errors={errors} />
134-
{!isEmptyObject(selectedBuckets) && (
135-
// Intentionally avoided using KeyValue label due to inconvenience
136-
<Typography variant="caption">
137-
<FormattedMessage id="selectedBuckets" />
138-
&#58;&nbsp;
139-
<strong>{Object.keys(selectedBuckets).join(", ")}</strong>
140-
</Typography>
141-
)}
134+
{!isEmptyObject(selectedBuckets) && <S3DuplicatesBucketsList bucketNames={Object.keys(selectedBuckets)} />}
142135
{!!errors[FIELD_NAME] && <FormHelperText error>{errors[FIELD_NAME].message}</FormHelperText>}
143136
</>
144137
)

0 commit comments

Comments
 (0)