You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@yunikorn.apache.org by wi...@apache.org on 2023/08/15 23:35:19 UTC
[yunikorn-web] branch master updated: [YUNIKORN-108] Display "other" resource types (#127)
This is an automated email from the ASF dual-hosted git repository.
wilfreds pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-web.git
The following commit(s) were added to refs/heads/master by this push:
new f4f663d [YUNIKORN-108] Display "other" resource types (#127)
f4f663d is described below
commit f4f663d7d7cba23bb9701d0e6995fc8db7d80330
Author: wusamzong <t3...@gmail.com>
AuthorDate: Wed Aug 16 09:31:12 2023 +1000
[YUNIKORN-108] Display "other" resource types (#127)
Only memory and vcore were displayed on the web UI even if more resource
types were defined. Add dynamic display of different types of resources
based on what is defined on the object.
Set n/a for the value if the type is defined but not a value is given,
i.e. if a resource is empty.
Closes: #127
Signed-off-by: Wilfred Spiegelenburg <wi...@apache.org>
---
json-db.json | 23 ++++++++++++++------
src/app/models/resource-info.model.ts | 2 ++
src/app/services/scheduler/scheduler.service.ts | 29 ++++++++++++++++++++++++-
src/app/utils/common.util.spec.ts | 10 ++++-----
src/app/utils/common.util.ts | 8 +++++--
5 files changed, 57 insertions(+), 15 deletions(-)
diff --git a/json-db.json b/json-db.json
index 216070c..edbd71f 100644
--- a/json-db.json
+++ b/json-db.json
@@ -31,7 +31,10 @@
"hugepages-64Ki": 0,
"memory": 4110970880,
"pods": 110,
- "vcore": 2000
+ "vcore": 2000,
+ "nvidia.com/gpu": 10,
+ "amd.com/gpu": 10,
+ "gpu.intel.com/i915": 10
},
"guaranteedResource": {},
"allocatedResource": {
@@ -65,11 +68,13 @@
"pendingResource": {},
"maxResource": {
"memory": 300000000,
- "vcore": 300
+ "vcore": 300,
+ "nvidia.com/gpu": 10
},
"guaranteedResource": {
"memory": 200000000,
- "vcore": 200
+ "vcore": 200,
+ "nvidia.com/gpu": 10
},
"allocatedResource": {
"memory": 270000000,
@@ -98,11 +103,13 @@
"pendingResource": {},
"maxResource": {
"memory": 300000000,
- "vcore": 300
+ "vcore": 300,
+ "amd.com/gpu": 10
},
"guaranteedResource": {
"memory": 200000000,
- "vcore": 200
+ "vcore": 200,
+ "amd.com/gpu": 10
},
"allocatedResource": {},
"preemptingResource": {},
@@ -165,11 +172,13 @@
"pendingResource": {},
"maxResource": {
"memory": 100000000,
- "vcore": 100
+ "vcore": 100,
+ "gpu.intel.com/i915": 10
},
"guaranteedResource": {
"memory": 100000000,
- "vcore": 100
+ "vcore": 100,
+ "gpu.intel.com/i915": 10
},
"allocatedResource": {
"memory": 80000000,
diff --git a/src/app/models/resource-info.model.ts b/src/app/models/resource-info.model.ts
index a257bd7..db7d7c0 100644
--- a/src/app/models/resource-info.model.ts
+++ b/src/app/models/resource-info.model.ts
@@ -19,9 +19,11 @@
export interface ResourceInfo {
memory: string;
vcore: string;
+ [key: string]: string;
}
export interface SchedulerResourceInfo {
memory: number;
vcore: number;
+ [key: string]: number;
}
diff --git a/src/app/services/scheduler/scheduler.service.ts b/src/app/services/scheduler/scheduler.service.ts
index d213f2a..25c81be 100644
--- a/src/app/services/scheduler/scheduler.service.ts
+++ b/src/app/services/scheduler/scheduler.service.ts
@@ -318,7 +318,7 @@ export class SchedulerService {
const formatted = [];
if (resource && resource.memory !== undefined) {
- formatted.push(`Memory: ${CommonUtil.formatMemory(resource.memory)}`);
+ formatted.push(`Memory: ${CommonUtil.formatBytes(resource.memory)}`);
} else {
formatted.push(`Memory: ${NOT_AVAILABLE}`);
}
@@ -329,6 +329,33 @@ export class SchedulerService {
formatted.push(`CPU: ${NOT_AVAILABLE}`);
}
+ if (resource){
+ Object.keys(resource).forEach((key) => {
+ switch(key){
+ case "memory":
+ case "vcore":{
+ break;
+ }
+ case "ephemeral-storage":{
+ if (resource[`ephemeral-storage`] == 0) {
+ formatted.push(`ephemeral-storage: ${NOT_AVAILABLE}`);
+ }else{
+ formatted.push(`ephemeral-storage: ${CommonUtil.formatBytes(resource[key])}`);
+ }
+ break;
+ }
+ default:{
+ if (resource[key] == 0) {
+ formatted.push(`${key}: ${NOT_AVAILABLE}`);
+ }else{
+ formatted.push(`${key}: ${CommonUtil.formatOtherResource(resource[key])}`);
+ }
+ break;
+ }
+ }
+ });
+ }
+
return formatted.join(', ');
}
diff --git a/src/app/utils/common.util.spec.ts b/src/app/utils/common.util.spec.ts
index 83c337d..d892d76 100644
--- a/src/app/utils/common.util.spec.ts
+++ b/src/app/utils/common.util.spec.ts
@@ -23,16 +23,16 @@ describe('CommonUtil', () => {
expect(CommonUtil.createUniqId).toBeTruthy();
});
- it('should have formatMemory method', () => {
- expect(CommonUtil.formatMemory).toBeTruthy();
+ it('should have formatBytes method', () => {
+ expect(CommonUtil.formatBytes).toBeTruthy();
});
- it('checking formatMemory method result', () => {
+ it('checking formatBytes method result', () => {
var inputs: number[] = [100, 1100, 1200000, 1300000000, 1400000000000, 1500000000000000];
var expected: string[] = ['100.0 bytes', '1.1 KB', '1.2 MB', '1.3 GB', '1.4 TB', '1.5 PB'];
for (var index: number = 0, len = inputs.length; index < len; index = index + 1) {
- expect(CommonUtil.formatMemory(inputs[index])).toEqual(expected[index]);
- expect(CommonUtil.formatMemory(inputs[index].toString())).toEqual(expected[index]);
+ expect(CommonUtil.formatBytes(inputs[index])).toEqual(expected[index]);
+ expect(CommonUtil.formatBytes(inputs[index].toString())).toEqual(expected[index]);
}
});
});
diff --git a/src/app/utils/common.util.ts b/src/app/utils/common.util.ts
index 3c86a0e..35674e1 100644
--- a/src/app/utils/common.util.ts
+++ b/src/app/utils/common.util.ts
@@ -30,7 +30,7 @@ export class CommonUtil {
return uniqid;
}
- static formatMemory(value: number | string): string {
+ static formatBytes(value: number | string): string {
const units: readonly string[] = ['KB', 'MB', 'GB', 'TB', 'PB'];
var unit: string = 'bytes';
let toValue = +value
@@ -48,7 +48,6 @@ export class CommonUtil {
static formatCount(value: number | string): string {
const unit = 'K';
const toValue = +value;
-
if (toValue >= 10000) {
return `${(toValue / 1000).toLocaleString(undefined, { maximumFractionDigits: 1 })} ${unit}`;
}
@@ -56,6 +55,11 @@ export class CommonUtil {
return toValue.toLocaleString();
}
+ static formatOtherResource(value: number | string): string {
+ const toValue = +value;
+ return toValue.toLocaleString();
+ }
+
static resourceColumnFormatter(value: string): string {
return value.split(', ').join('<br/>');
}
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: issues-help@yunikorn.apache.org