plugin-kubernetes: fix div by zero pod resources
When pods have no resources set, currentToDeclaredResourceToPerc would throw div by zero, added check Signed-off-by: Manuel Stein <manuel.stein@nokia-bell-labs.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-kubernetes': patch
|
||||
---
|
||||
|
||||
Fix division by zero in currentToDeclaredResourceToPerc when pod resources weren't set
|
||||
@@ -118,6 +118,8 @@ export const currentToDeclaredResourceToPerc = (
|
||||
current: number | string,
|
||||
resource: number | string,
|
||||
): string => {
|
||||
if(Number(resource) == 0) return `0%`;
|
||||
|
||||
if (typeof current === 'number' && typeof resource === 'number') {
|
||||
return `${Math.round((current / resource) * 100)}%`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user