Skip to content

Commit ba49202

Browse files
committed
change gpu-plugin path from config()
Signed-off-by: Swati Gupta <[email protected]>
1 parent 8db28ec commit ba49202

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

cmd/gpu-kubelet-plugin/device_state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func NewDeviceState(ctx context.Context, config *Config) (*DeviceState, error) {
8585
}
8686

8787
tsManager := NewTimeSlicingManager(nvdevlib)
88-
mpsManager := NewMpsManager(config, nvdevlib, config.MpsRoot(), hostDriverRoot, MpsControlDaemonTemplatePath)
88+
mpsManager := NewMpsManager(config, nvdevlib, hostDriverRoot, MpsControlDaemonTemplatePath)
8989

9090
if err := cdi.CreateStandardDeviceSpecFile(allocatable); err != nil {
9191
return nil, fmt.Errorf("unable to create base CDI spec file: %v", err)

cmd/gpu-kubelet-plugin/driver.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,30 @@ import (
3333
"github.com/NVIDIA/k8s-dra-driver-gpu/pkg/flock"
3434
)
3535

36+
// DriverPrepUprepFlockPath is the path to a lock file used to make sure
37+
// that calls to nodePrepareResource() / nodeUnprepareResource() never
38+
// interleave, node-globally.
39+
const DriverPrepUprepFlockFileName = "pu.lock"
40+
3641
type driver struct {
3742
client coreclientset.Interface
3843
pluginhelper *kubeletplugin.Helper
3944
state *DeviceState
4045
pulock *flock.Flock
4146
}
4247

43-
// DriverPrepUprepFlockPath is the path to a lock file used to make sure
44-
// that calls to nodePrepareResource() / nodeUnprepareResource() never
45-
// interleave, node-globally.
46-
func (c Config) DriverPrepUprepFlockPath() string {
47-
return filepath.Join(c.DriverPluginPath(), "pu.lock")
48-
}
49-
5048
func NewDriver(ctx context.Context, config *Config) (*driver, error) {
5149
state, err := NewDeviceState(ctx, config)
5250
if err != nil {
5351
return nil, err
5452
}
5553

54+
puLockPath := filepath.Join(config.DriverPluginPath(), DriverPrepUprepFlockFileName)
55+
5656
driver := &driver{
5757
client: config.clientsets.Core,
5858
state: state,
59-
pulock: flock.NewFlock(config.DriverPrepUprepFlockPath()),
59+
pulock: flock.NewFlock(puLockPath),
6060
}
6161

6262
helper, err := kubeletplugin.Start(
@@ -97,7 +97,6 @@ func (d *driver) Shutdown() error {
9797
if d == nil {
9898
return nil
9999
}
100-
101100
d.pluginhelper.Stop()
102101
return nil
103102
}

cmd/gpu-kubelet-plugin/sharing.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import (
5252
)
5353

5454
const (
55+
MpsControlFilesDirName = "mps"
5556
MpsControlDaemonTemplatePath = "/templates/mps-control-daemon.tmpl.yaml"
5657
MpsControlDaemonNameFmt = "mps-control-daemon-%v" // Fill with ClaimUID
5758
)
@@ -97,10 +98,6 @@ type MpsControlDaemonTemplateData struct {
9798
FeatureGates map[string]bool
9899
}
99100

100-
func (c Config) MpsRoot() string {
101-
return filepath.Join(c.DriverPluginPath(), "mps")
102-
}
103-
104101
func NewTimeSlicingManager(deviceLib *deviceLib) *TimeSlicingManager {
105102
return &TimeSlicingManager{
106103
nvdevlib: deviceLib,
@@ -128,7 +125,9 @@ func (t *TimeSlicingManager) SetTimeSlice(devices UUIDProvider, config *configap
128125
return nil
129126
}
130127

131-
func NewMpsManager(config *Config, deviceLib *deviceLib, controlFilesRoot, hostDriverRoot, templatePath string) *MpsManager {
128+
func NewMpsManager(config *Config, deviceLib *deviceLib, hostDriverRoot, templatePath string) *MpsManager {
129+
controlFilesRoot := filepath.Join(config.DriverPluginPath(), MpsControlFilesDirName)
130+
132131
return &MpsManager{
133132
controlFilesRoot: controlFilesRoot,
134133
hostDriverRoot: hostDriverRoot,

0 commit comments

Comments
 (0)