Skip to content

Commit 4c2a325

Browse files
mathis-marcotteMathis Marcotte
andauthored
added shared cost column (#222)
* added shared cost column --------- Co-authored-by: Mathis Marcotte <[email protected]>
1 parent 4fbe13e commit 4c2a325

File tree

10 files changed

+72
-40
lines changed

10 files changed

+72
-40
lines changed

frontend/common/kubeflow-common-lib/angular.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"cli": {
4+
"analytics": false
5+
},
36
"version": 1,
47
"newProjectRoot": "projects",
58
"projects": {

frontend/jupyter/angular.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"cli": {
4+
"analytics": false
5+
},
36
"version": 1,
47
"newProjectRoot": "projects",
58
"projects": {

frontend/jupyter/i18n/fr/messages.fr.xlf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,12 +1154,20 @@
11541154
<context context-type="linenumber">245</context>
11551155
</context-group>
11561156
</trans-unit>
1157+
<trans-unit id="5739581984228459958" datatype="html">
1158+
<source>Shared</source>
1159+
<target>Partagés</target>
1160+
<context-group purpose="location">
1161+
<context context-type="sourcefile">src/app/pages/index/index-default/config.ts</context>
1162+
<context context-type="linenumber">250</context>
1163+
</context-group>
1164+
</trans-unit>
11571165
<trans-unit id="3448462145758383019" datatype="html">
11581166
<source>Total</source>
11591167
<target>Total</target>
11601168
<context-group purpose="location">
11611169
<context context-type="sourcefile">src/app/pages/index/index-default/config.ts</context>
1162-
<context context-type="linenumber">250</context>
1170+
<context context-type="linenumber">255</context>
11631171
</context-group>
11641172
</trans-unit>
11651173
<trans-unit id="fbc6d8bbd465eba779b7c1aa7017cc0b47125097" datatype="html">

frontend/jupyter/i18n/messages.xlf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,11 +1028,18 @@
10281028
<context context-type="linenumber">245</context>
10291029
</context-group>
10301030
</trans-unit>
1031+
<trans-unit id="5739581984228459958" datatype="html">
1032+
<source>Shared</source>
1033+
<context-group purpose="location">
1034+
<context context-type="sourcefile">src/app/pages/index/index-default/config.ts</context>
1035+
<context context-type="linenumber">250</context>
1036+
</context-group>
1037+
</trans-unit>
10311038
<trans-unit id="3448462145758383019" datatype="html">
10321039
<source>Total</source>
10331040
<context-group purpose="location">
10341041
<context context-type="sourcefile">src/app/pages/index/index-default/config.ts</context>
1035-
<context context-type="linenumber">250</context>
1042+
<context context-type="linenumber">255</context>
10361043
</context-group>
10371044
</trans-unit>
10381045
<trans-unit id="fbc6d8bbd465eba779b7c1aa7017cc0b47125097" datatype="html">

frontend/jupyter/src/app/pages/index/index-default/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ export const defaultCostConfig = {
246246
matColumnDef: 'storage',
247247
value: new PropertyValue({ field: 'pvCost' }),
248248
},
249+
{
250+
matHeaderCellDef: $localize`Shared`,
251+
matColumnDef: 'shared',
252+
value: new PropertyValue({ field: 'sharedCost' }),
253+
},
249254
{
250255
matHeaderCellDef: $localize`Total`,
251256
matColumnDef: 'total',

frontend/jupyter/src/app/pages/index/index-default/index-default.component.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export class IndexDefaultComponent implements OnInit, OnDestroy {
136136
if (!isEqual(this.rawCostData, aggCost)) {
137137
this.rawCostData = aggCost;
138138

139-
this.processedCostData = [this.processIncomingCostData(aggCost)];
139+
this.processedCostData = this.processIncomingCostData(aggCost);
140140
}
141141
},
142142
err => {
@@ -470,7 +470,7 @@ export class IndexDefaultComponent implements OnInit, OnDestroy {
470470
}
471471

472472
public costTrackByFn(index: number, cost: AllocationCostObject) {
473-
return `${cost.cpuCost}/${cost.gpuCost}/${cost.pvCost}/${cost.totalCost}`;
473+
return `${cost.cpuCost}/${cost.gpuCost}/${cost.ramCost}/${cost.pvCost}/${cost.sharedCost}/${cost.totalCost}`;
474474
}
475475

476476
public getCostStatus() {
@@ -493,20 +493,31 @@ export class IndexDefaultComponent implements OnInit, OnDestroy {
493493
gpuCost: this.formatCost(0),
494494
ramCost: this.formatCost(0),
495495
pvCost: this.formatCost(0),
496+
sharedCost: this.formatCost(0),
496497
totalCost: this.formatCost(0)
497498
};
498-
if (resp.data[0][this.currNamespace]) {
499-
costCopy.cpuCost = this.formatCost(resp.data[0][this.currNamespace].cpuCost);
500-
costCopy.gpuCost = this.formatCost(resp.data[0][this.currNamespace].gpuCost);
501-
costCopy.ramCost = this.formatCost(resp.data[0][this.currNamespace].ramCost);
502-
costCopy.pvCost = this.formatCost(resp.data[0][this.currNamespace].pvCost);
503-
costCopy.totalCost = this.formatCost(resp.data[0][this.currNamespace].totalCost);
499+
500+
const alloc = resp.data.sets[0].allocations[this.currNamespace];
501+
if (alloc) {
502+
costCopy.cpuCost = this.formatCost(alloc.cpuCost);
503+
costCopy.gpuCost = this.formatCost(alloc.gpuCost);
504+
costCopy.ramCost = this.formatCost(alloc.ramCost);
505+
costCopy.pvCost = this.formatCost(alloc.pvCost);
506+
costCopy.sharedCost = this.formatCost(alloc.sharedCost);
507+
costCopy.totalCost = Number.parseInt(costCopy.sharedCost).toString();
508+
costCopy.totalCost = this.formatCost(alloc.cpuCost
509+
+alloc.gpuCost
510+
+alloc.ramCost
511+
+alloc.pvCost
512+
+alloc.sharedCost
513+
);
504514
}
505-
return costCopy;
515+
516+
return [costCopy];
506517
}
507518

508519
public formatCost(value: number): string {
509-
return "$" + (value > 0 ? Math.max(value, 0.01) : 0).toFixed(2)
520+
return "$" + value.toFixed(2)
510521
}
511522

512523
}

frontend/jupyter/src/app/services/kubecost.service.ts

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,38 @@ import {
99
interface AllocationCostData {
1010
[namespace: string]: {
1111
"name": string,
12-
"properties": object,
13-
"window": object,
1412
"start": string,
1513
"end": string,
16-
"minutes": number,
17-
"cpuCores": number,
18-
"cpuCoreRequestAverage": number,
14+
"cpuCoreRequestAverage": number,
1915
"cpuCoreUsageAverage": number,
20-
"cpuCoreHours": number,
2116
"cpuCost": number,
22-
"cpuCostAdjustment": number,
23-
"cpuEfficiency": number,
24-
"gpuCount": number,
25-
"gpuHours": number,
2617
"gpuCost": number,
27-
"gpuCostAdjustment": number,
28-
"networkTransferBytes": number,
29-
"networkReceiveBytes": number,
3018
"networkCost": number,
31-
"networkCostAdjustment": number,
3219
"loadBalancerCost": number,
33-
"loadBalancerCostAdjustment": number,
34-
"pvBytes": number,
35-
"pvByteHours": number,
3620
"pvCost": number,
37-
"pvs": object,
38-
"pvCostAdjustment": number,
39-
"ramBytes": number,
4021
"ramByteRequestAverage": number,
4122
"ramByteUsageAverage": number,
42-
"ramByteHours": number,
4323
"ramCost": number,
44-
"ramCostAdjustment": number,
45-
"ramEfficiency": number,
4624
"sharedCost": number,
4725
"externalCost": number,
48-
"totalCost": number,
49-
"totalEfficiency": number,
50-
"rawAllocationOnly": object
5126
}
5227
};
5328

5429
export type AllocationCostResponse = {
5530
code: number;
56-
data: Array<AllocationCostData>;
31+
data: {
32+
sets: Array<{
33+
allocations: AllocationCostData,
34+
window: {
35+
start: string,
36+
end: string
37+
}
38+
}>
39+
window: {
40+
start: string,
41+
end: string
42+
}
43+
};
5744
message: string;
5845
};
5946

frontend/jupyter/src/app/types/allocationcost.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ export interface AllocationCostObject {
33
"gpuCost"?: string,
44
"ramCost"?: string,
55
"pvCost"?: string,
6+
"sharedCost"?: string,
67
"totalCost"?: string
78
};

frontend/jupyter/yarn.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5698,6 +5698,12 @@
56985698
"resolved" "https://registry.npmjs.org/klona/-/klona-2.0.5.tgz"
56995699
"version" "2.0.5"
57005700

5701+
"kubeflow@file:../common/kubeflow-common-lib/dist/kubeflow":
5702+
"resolved" "file:../common/kubeflow-common-lib/dist/kubeflow"
5703+
"version" "0.0.4"
5704+
dependencies:
5705+
"tslib" "^2.0.0"
5706+
57015707
"lazy-ass@^1.6.0":
57025708
"integrity" "sha1-eZllXoZGwX8In90YfRUNMyTVRRM="
57035709
"resolved" "https://registry.npmjs.org/lazy-ass/-/lazy-ass-1.6.0.tgz"

namespacecost.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ func (s *server) GetCost(w http.ResponseWriter, r *http.Request) {
1515
window := r.URL.Query().Get("window")
1616
log.Printf("loading namespace costs for %q", namespace)
1717

18-
u, _ := s.kubecostURL.Parse("model/allocation")
18+
u, _ := s.kubecostURL.Parse("model/allocation/summary")
1919

2020
params := url.Values{}
2121
params.Add("filterNamespaces", namespace)
2222
params.Add("window", window)
2323
params.Add("aggregate", "namespace")
24+
params.Add("shareNamespaces", "aad-pod-identity-system,argocd-operator-system,azure-blob-csi-system,boathouse-system,cert-manager-system,cloud-main-system,daaas-system,default,eck-operator-system,fdi-gateway-protected-b-system,fdi-gateway-system,fdi-gateway-unclassified-system,fluentd-system,gatekeeper-system,gitea-default,goofys-injector-system,hive-system,ingress-general-system,istio-operator-system,istio-system,kiali-system,knative-eventing,knative-serving,jfrog-system,kube-public,kube-system,kubeflow,kubecost-system,minio-gateway-premium-oidc-system,minio-gateway-premium-ro-system,minio-gateway-premium-system,minio-gateway-protected-b-system,minio-gateway-standard-oidc-system,minio-gateway-standard-ro-system,minio-gateway-standard-system,monitoring-system,notebook-cleanup-system,nvidia-system,oauth2-proxy-system,profiles-argocd-system,prometheus-system,s3proxy-default,shared-daaas-system,solr-operator-system,statcan-system,trino-protb-system,trino-system,vault-agent-system,vault-system,velero-system")
2425
params.Add("idle", "false")
2526
params.Add("accumulate", "true")
2627
u.RawQuery = params.Encode()

0 commit comments

Comments
 (0)