Skip to content

Commit 2f4546a

Browse files
author
Zachary Seguin
committed
feat(notebooks): Display CPU limits as a decimal
1 parent f09fe91 commit 2f4546a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ require (
1919
golang.org/x/text v0.3.3 // indirect
2020
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
2121
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
22+
gopkg.in/inf.v0 v0.9.1
2223
gopkg.in/yaml.v2 v2.3.0
2324
k8s.io/api v0.18.6
2425
k8s.io/apimachinery v0.18.6

notebooks.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
kubeflowv1 "github.com/StatCan/kubeflow-controller/pkg/apis/kubeflowcontroller/v1"
1414
"github.com/andanhm/go-prettytime"
1515
"github.com/gorilla/mux"
16+
"gopkg.in/inf.v0"
1617
corev1 "k8s.io/api/core/v1"
1718
"k8s.io/apimachinery/pkg/api/resource"
1819
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -64,7 +65,7 @@ type newnotebookrequest struct {
6465

6566
type notebookresponse struct {
6667
Age string `json:"age"`
67-
CPU resource.Quantity `json:"cpu"`
68+
CPU *inf.Dec `json:"cpu"`
6869
GPU resource.Quantity `json:"gpu"`
6970
GPUVendor GPUVendor `json:"gpuvendor"`
7071
Image string `json:"image"`
@@ -203,13 +204,18 @@ func (s *server) GetNotebooks(w http.ResponseWriter, r *http.Request) {
203204
volumes = append(volumes, vol.Name)
204205
}
205206

207+
cpulimit := resource.Zero.AsDec()
208+
if req, ok := notebook.Spec.Template.Spec.Containers[0].Resources.Requests[corev1.ResourceCPU]; ok {
209+
cpulimit = req.AsDec()
210+
}
211+
206212
resp.Notebooks = append(resp.Notebooks, notebookresponse{
207213
Age: prettytime.Format(notebook.CreationTimestamp.Time),
208214
Name: notebook.Name,
209215
Namespace: notebook.Namespace,
210216
Image: notebook.Spec.Template.Spec.Containers[0].Image,
211217
ShortImage: imageparts[len(imageparts)-1],
212-
CPU: notebook.Spec.Template.Spec.Containers[0].Resources.Requests[corev1.ResourceCPU],
218+
CPU: cpulimit,
213219
Memory: notebook.Spec.Template.Spec.Containers[0].Resources.Requests[corev1.ResourceMemory],
214220
Reason: reason,
215221
Status: status,

0 commit comments

Comments
 (0)