Skip to content

Commit 4e7f132

Browse files
OliwiaGowordbadura
andauthored
fix: CPU and memory usage is not refreshing (#3562)
* fix: add comparing entire resource * fix cpu units * fix cpu units --------- Co-authored-by: Damian Badura <damian.badura@sap.com>
1 parent 85d02d6 commit 4e7f132

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

src/components/Nodes/NodeResources/NodeResources.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export function NodeResources({ metrics, resources }) {
1919
<UI5RadialChart
2020
color="var(--sapChart_OrderedColor_5)"
2121
value={cpu.usage}
22-
max={cpu.capacity}
22+
max={cpu.capacity * 1000}
2323
additionalInfo={`${roundTwoDecimals(cpu.usage)}m / ${roundTwoDecimals(
2424
cpu.capacity,
25-
)}m`}
25+
) * 1000}m`}
2626
/>
2727
</Card>
2828
<Card
@@ -53,10 +53,10 @@ export function NodeResources({ metrics, resources }) {
5353
<UI5RadialChart
5454
color="var(--sapChart_OrderedColor_5)"
5555
value={resources?.requests?.cpu}
56-
max={cpu.capacity}
56+
max={cpu.capacity * 1000}
5757
additionalInfo={`${roundTwoDecimals(
5858
resources?.requests?.cpu,
59-
)}m / ${roundTwoDecimals(cpu.capacity)}m`}
59+
)}m / ${roundTwoDecimals(cpu.capacity) * 1000}m`}
6060
/>
6161
</Card>
6262
<Card
@@ -85,10 +85,10 @@ export function NodeResources({ metrics, resources }) {
8585
<UI5RadialChart
8686
color="var(--sapChart_OrderedColor_5)"
8787
value={resources?.limits?.cpu}
88-
max={cpu.capacity}
88+
max={cpu.capacity * 1000}
8989
additionalInfo={`${roundTwoDecimals(
9090
resources?.limits?.cpu,
91-
)}m / ${roundTwoDecimals(cpu.capacity)}m`}
91+
)}m / ${roundTwoDecimals(cpu.capacity) * 1000}m`}
9292
/>
9393
</Card>
9494
<Card

src/components/Nodes/nodeQueries.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export function useNodesQuery(skip = false) {
5151
{
5252
pollingInterval: 4000,
5353
skip,
54+
compareEntireResource: true,
5455
},
5556
);
5657

src/shared/hooks/BackendAPI/useGet.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ const ERROR_TOLERANCY = 2;
1414
const useGetHook = processDataFn =>
1515
function(
1616
path,
17-
{ pollingInterval, onDataReceived, skip, errorTolerancy = undefined } = {},
17+
{
18+
pollingInterval,
19+
onDataReceived,
20+
skip,
21+
errorTolerancy = undefined,
22+
compareEntireResource = false,
23+
} = {},
1824
) {
1925
const authData = useRecoilValue(authDataState);
2026
const lastAuthData = useRef(null);
@@ -82,7 +88,13 @@ const useGetHook = processDataFn =>
8288
if (error) setTimeout(_ => setError(null)); // bring back the data and clear the error once the connection started working again
8389
errorTolerancyCounter.current = 0;
8490
setTimeout(_ =>
85-
processDataFn(payload, currentData, setData, lastResourceVersion),
91+
processDataFn(
92+
payload,
93+
currentData,
94+
setData,
95+
lastResourceVersion,
96+
compareEntireResource,
97+
),
8698
);
8799
} catch (e) {
88100
previousRequestNotFinished.current = null;
@@ -325,10 +337,17 @@ function handleListDataReceived(filter) {
325337
};
326338
}
327339

328-
function handleSingleDataReceived(newData, oldData, setDataFn) {
340+
function handleSingleDataReceived(
341+
newData,
342+
oldData,
343+
setDataFn,
344+
compareEntireResource,
345+
) {
329346
if (
330347
!oldData || // current data is empty and we received some. There's no doubdt we should update.
331-
newData.metadata.resourceVersion !== oldData.metadata?.resourceVersion
348+
newData.metadata.resourceVersion !== oldData.metadata?.resourceVersion ||
349+
(compareEntireResource &&
350+
JSON.stringify(newData) !== JSON.stringify(oldData))
332351
) {
333352
// Compare resourceVersion.
334353
setDataFn(newData);

0 commit comments

Comments
 (0)