-
Notifications
You must be signed in to change notification settings - Fork 854
Expand file tree
/
Copy pathroot.go
More file actions
69 lines (58 loc) · 2.3 KB
/
Copy pathroot.go
File metadata and controls
69 lines (58 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
# Copyright 2024 NVIDIA CORPORATION
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
**/
package mps
import (
"path/filepath"
spec "github.com/NVIDIA/k8s-device-plugin/api/config/v1"
)
const (
ContainerRoot = Root("/mps")
)
// Root represents an MPS root.
// This is where per-resource pipe and log directories are created.
// For containerised applications the host root is typically mounted to /mps in the container.
type Root string
// LogDir returns the per-resource pipe dir for the specified root.
func (r Root) LogDir(resourceName spec.ResourceName) string {
return r.Path(string(resourceName), "log")
}
// PipeDir returns the per-resource pipe dir for the specified root.
func (r Root) PipeDir(resourceName spec.ResourceName) string {
return r.Path(string(resourceName), "pipe")
}
// ShmDir returns the shm dir associated with the root.
// Note that the shm dir is the same for all resources.
func (r Root) ShmDir(resourceName spec.ResourceName) string {
return r.Path("shm")
}
// startedFile returns the per-resource .started file name for the specified root.
func (r Root) startedFile(resourceName spec.ResourceName) string {
return r.Path(string(resourceName), ".started")
}
// ReadyFilePath returns the path to the node-global .ready file. Unlike the
// per-resource .started file, this single marker is created only after all MPS
// daemons have completed initialization (compute mode, pinned memory limits,
// and active thread percentage). Consumers such as the device plugin use it to
// avoid advertising MPS-shared resources before the daemons are fully
// configured.
func (r Root) ReadyFilePath() string {
return r.Path(".ready")
}
// Path returns a path relative to the MPS root.
func (r Root) Path(parts ...string) string {
pathparts := append([]string{string(r)}, parts...)
return filepath.Join(pathparts...)
}