Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hzxuzhonghu committed Jun 30, 2020
1 parent edbb3ca commit 66376f8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions pkg/scheduler/api/device_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
v1 "k8s.io/api/core/v1"
)

// GPU device
// GPUDevice
type GPUDevice struct {
// GPU ID
Id int
ID int
// The pods that are sharing this GPU
PodMap map[string]*v1.Pod
// memory per card
Expand All @@ -33,7 +33,7 @@ type GPUDevice struct {
// NewGPUDevice creates a device
func NewGPUDevice(id int, mem uint) *GPUDevice {
return &GPUDevice{
Id: id,
ID: id,
Memory: mem,
PodMap: map[string]*v1.Pod{},
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/scheduler/api/node_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,15 @@ func (ni *NodeInfo) GetDevicesIdleGPUMemory() map[int]uint {
func (ni *NodeInfo) getDevicesUsedGPUMemory() map[int]uint {
res := map[int]uint{}
for _, device := range ni.GPUDevices {
res[device.Id] = device.getUsedGPUMemory()
res[device.ID] = device.getUsedGPUMemory()
}
return res
}

func (ni *NodeInfo) getDevicesAllGPUMemory() map[int]uint {
res := map[int]uint{}
for _, device := range ni.GPUDevices {
res[device.Id] = device.Memory
res[device.ID] = device.Memory
}
return res
}
Expand Down
10 changes: 5 additions & 5 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)
}

// AddGPUIndexPatch returns the patch removing GPU index
// 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))
}
4 changes: 3 additions & 1 deletion pkg/scheduler/api/well_known_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const (
VolcanoGPUNumber = "volcano.sh/gpu-number"

// Annotation
// PredicateTime is the key of predicate time
PredicateTime = "volcano.sh/predicate-time"
GPUIndex = "volcano.sh/gpu-index"
// GPUIndex is the key of gpu index
GPUIndex = "volcano.sh/gpu-index"
)

0 comments on commit 66376f8

Please sign in to comment.