From fb01724b793890c1639fa9dcc9115d889cf65547 Mon Sep 17 00:00:00 2001 From: xuzhonghu Date: Wed, 1 Jul 2020 14:06:41 +0800 Subject: [PATCH] fixl int --- pkg/scheduler/api/device_info.go | 2 +- pkg/scheduler/api/pod_info.go | 8 ++++---- pkg/scheduler/api/well_known_labels.go | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/scheduler/api/device_info.go b/pkg/scheduler/api/device_info.go index 093d06eb36b..11edae292a2 100644 --- a/pkg/scheduler/api/device_info.go +++ b/pkg/scheduler/api/device_info.go @@ -20,7 +20,7 @@ import ( v1 "k8s.io/api/core/v1" ) -// GPUDevice +// GPUDevice include gpu id, memory and the pods that are sharing it. type GPUDevice struct { // GPU ID ID int diff --git a/pkg/scheduler/api/pod_info.go b/pkg/scheduler/api/pod_info.go index 9cd0720759c..56405ecc774 100644 --- a/pkg/scheduler/api/pod_info.go +++ b/pkg/scheduler/api/pod_info.go @@ -95,7 +95,7 @@ func GetGPUIndex(pod *v1.Pod) int { return -1 } -func escapeJsonPointer(p string) string { +func escapeJSONPointer(p string) string { // Escaping reference name using https://tools.ietf.org/html/rfc6901 p = strings.Replace(p, "~", "~0", -1) p = strings.Replace(p, "/", "~1", -1) @@ -106,12 +106,12 @@ func escapeJsonPointer(p string) string { func AddGPUIndexPatch(id int) string { return fmt.Sprintf(`[{"op": "add", "path": "/metadata/annotations/%s", "value":"%d"},`+ `{"op": "add", "path": "/metadata/annotations/%s", "value": "%d"}]`, - escapeJsonPointer(PredicateTime), time.Now().UnixNano(), - escapeJsonPointer(GPUIndex), id) + escapeJSONPointer(PredicateTime), time.Now().UnixNano(), + escapeJSONPointer(GPUIndex), id) } // RemoveGPUIndexPatch returns the patch removing GPU index func RemoveGPUIndexPatch() string { return fmt.Sprintf(`[{"op": "remove", "path": "/metadata/annotations/%s"},`+ - `{"op": "remove", "path": "/metadata/annotations/%s"]`, escapeJsonPointer(PredicateTime), escapeJsonPointer(GPUIndex)) + `{"op": "remove", "path": "/metadata/annotations/%s"]`, escapeJSONPointer(PredicateTime), escapeJSONPointer(GPUIndex)) } diff --git a/pkg/scheduler/api/well_known_labels.go b/pkg/scheduler/api/well_known_labels.go index e6061d28555..c412d245297 100644 --- a/pkg/scheduler/api/well_known_labels.go +++ b/pkg/scheduler/api/well_known_labels.go @@ -18,12 +18,11 @@ package api const ( - // Extended gpu resource + // VolcanoGPUResource extended gpu resource VolcanoGPUResource = "volcano.sh/gpu-memory" - // Virtual GPU card number + // VolcanoGPUNumber virtual GPU card number VolcanoGPUNumber = "volcano.sh/gpu-number" - // Annotation // PredicateTime is the key of predicate time PredicateTime = "volcano.sh/predicate-time" // GPUIndex is the key of gpu index