chenyulin0719 commented on code in PR #146:
URL: https://github.com/apache/yunikorn-web/pull/146#discussion_r1423460180
##########
src/app/services/scheduler/scheduler.service.ts:
##########
@@ -325,48 +325,66 @@ export class SchedulerService {
}
private formatResource(resource: SchedulerResourceInfo): string {
- const formatted = [];
-
- if (resource && resource.memory !== undefined) {
- formatted.push(`Memory: ${CommonUtil.formatBytes(resource.memory)}`);
- } else {
- formatted.push(`Memory: ${NOT_AVAILABLE}`);
- }
-
- if (resource && resource.vcore !== undefined) {
- formatted.push(`CPU: ${CommonUtil.formatCount(resource.vcore)}`);
- } else {
- formatted.push(`CPU: ${NOT_AVAILABLE}`);
- }
+ const formatted: string[] = [];
+ if (resource) {
+ // Object.keys() didn't guarantee the order of keys, sort it before
iterate.
+ Object.keys(resource).sort(this.resourcesCompareFn).forEach((key) => {
+ let value = resource[key];
+ let formattedKey = key;
+ let formattedValue = NOT_AVAILABLE;
- if (resource){
- Object.keys(resource).forEach((key) => {
switch(key){
case "memory":
- case "vcore":{
+ formattedKey = "Memory";
+ formattedValue = CommonUtil.formatMemoryBytes(value);
+ break;
+ case "vcore":
+ formattedKey = "CPU";
+ formattedValue = CommonUtil.formatCpuCore(value);
break;
- }
- case "ephemeral-storage":{
- if (resource[`ephemeral-storage`] == 0) {
- formatted.push(`ephemeral-storage: ${NOT_AVAILABLE}`);
- }else{
- formatted.push(`ephemeral-storage:
${CommonUtil.formatBytes(resource[key])}`);
+ case "ephemeral-storage":
+ if (value !== 0){ // if value is 0, show NOT_AVAILABLE
Review Comment:
Change to '0 B' for memory/disk, 0 for other resources.
<img width="334" alt="image"
src="https://github.com/apache/yunikorn-web/assets/26764036/e4b7dc01-3234-4184-940e-4fc0f984f2e0">
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]