Skip to content

Commit

Permalink
fixl int
Browse files Browse the repository at this point in the history
  • Loading branch information
hzxuzhonghu committed Jul 1, 2020
1 parent 66376f8 commit 1f52f75
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/scheduler/api/device_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pkg/scheduler/api/pod_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))
}
5 changes: 2 additions & 3 deletions pkg/scheduler/api/well_known_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1f52f75

Please sign in to comment.