Skip to content

Commit 83f8c06

Browse files
committed
Remove vGPU reconciliation dead code
1 parent 5589424 commit 83f8c06

9 files changed

Lines changed: 18 additions & 29 deletions

File tree

lib/devices/mdev_darwin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func DestroyVGPU(ctx context.Context, assignment VGPUAssignment) error {
6666
return nil
6767
}
6868

69-
func ReconcileVGPUs(ctx context.Context, protectedDevicePaths map[string]struct{}, sweepDevices bool) error {
69+
func ReconcileVGPUs(ctx context.Context, protectedDevicePaths map[string]struct{}) error {
7070
return nil
7171
}
7272

lib/devices/vgpu_linux.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,11 @@ func mdevReconcileInfos(protectedDevicePaths map[string]struct{}) []MdevReconcil
125125
}
126126

127127
// ReconcileVGPUs releases orphaned vGPU assignments.
128-
func ReconcileVGPUs(ctx context.Context, protectedDevicePaths map[string]struct{}, sweepDevices bool) error {
128+
func ReconcileVGPUs(ctx context.Context, protectedDevicePaths map[string]struct{}) error {
129129
framework, _, err := DiscoverVGPU()
130130
if err != nil {
131131
return err
132132
}
133-
if !sweepDevices {
134-
return nil
135-
}
136133

137134
switch framework {
138135
case VGPUFrameworkMdev:

lib/instances/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ type manager struct {
187187
configureVGPU func(context.Context, string, string) error
188188
vendorVFIOProfiles func([]devices.VirtualFunction) (map[string][]devices.VGPUProfileType, error)
189189
destroyVGPU func(context.Context, devices.VGPUAssignment) error
190-
reconcileVGPUDevices func(context.Context, map[string]struct{}, bool) error
190+
reconcileVGPUDevices func(context.Context, map[string]struct{}) error
191191
vgpuAllocationMu sync.Mutex
192192
deleteSnapshotFn func(context.Context, string) error
193193
ttlReaperDeleteTimeout time.Duration

lib/instances/metrics_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ func TestVGPUReconcileFailureMetric_RecordStages(t *testing.T) {
567567

568568
m := &manager{
569569
paths: paths.New(t.TempDir()),
570-
reconcileVGPUDevices: func(context.Context, map[string]struct{}, bool) error {
570+
reconcileVGPUDevices: func(context.Context, map[string]struct{}) error {
571571
return errors.New("sweep failed")
572572
},
573573
}

lib/instances/vgpu.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,8 @@ func (m *manager) cleanupCreateVGPU(ctx context.Context, stored *StoredMetadata)
197197
if path == "" {
198198
return true
199199
}
200-
pid, err := resolveLiveHypervisorPID(stored.HypervisorProcessIdentity, stored.SocketPath)
201-
if err != nil {
202-
logger.FromContext(ctx).WarnContext(ctx, "cannot confirm hypervisor stopped during vGPU cleanup", "instance_id", stored.Id, "error", err)
203-
return false
204-
}
205-
if pid > 0 {
206-
logger.FromContext(ctx).WarnContext(ctx, "preserving vGPU claim for live hypervisor", "instance_id", stored.Id, "pid", pid)
200+
if hypervisorMayBeAlive(stored.HypervisorProcessIdentity, stored.SocketPath) {
201+
logger.FromContext(ctx).WarnContext(ctx, "preserving vGPU claim because hypervisor liveness is not clear", "instance_id", stored.Id)
207202
return false
208203
}
209204
if stored.GPUFramework == devices.VGPUFrameworkVendorVFIO {
@@ -224,9 +219,8 @@ func (m *manager) cleanupStartVGPU(ctx context.Context, current *StoredMetadata,
224219
if path == "" {
225220
return
226221
}
227-
pid, err := resolveLiveHypervisorPID(current.HypervisorProcessIdentity, current.SocketPath)
228-
if err != nil || pid > 0 {
229-
logger.FromContext(ctx).WarnContext(ctx, "preserving vGPU claim because hypervisor liveness is not clear", "instance_id", current.Id, "device_path", path, "pid", pid, "error", err)
222+
if hypervisorMayBeAlive(current.HypervisorProcessIdentity, current.SocketPath) {
223+
logger.FromContext(ctx).WarnContext(ctx, "preserving vGPU claim because hypervisor liveness is not clear", "instance_id", current.Id, "device_path", path)
230224
return
231225
}
232226
if current.GPUFramework == devices.VGPUFrameworkVendorVFIO {

lib/instances/vgpu_reconcile.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (m *manager) ReconcileVGPUs(ctx context.Context) {
5858
if reconcileDevices == nil {
5959
reconcileDevices = devices.ReconcileVGPUs
6060
}
61-
if err := reconcileDevices(ctx, protected, true); err != nil {
61+
if err := reconcileDevices(ctx, protected); err != nil {
6262
m.recordVGPUReconcileFailure(ctx, vgpuReconcileStageReconcileDevices)
6363
log.WarnContext(ctx, "failed to reconcile mdev devices", "error", err)
6464
}
@@ -76,8 +76,7 @@ func (m *manager) reconcileVGPUAssignments(ctx context.Context) (map[string]stru
7676
if devicePath == "" {
7777
continue
7878
}
79-
pid, err := resolveLiveHypervisorPID(stored.HypervisorProcessIdentity, stored.SocketPath)
80-
if err != nil || pid > 0 {
79+
if hypervisorMayBeAlive(stored.HypervisorProcessIdentity, stored.SocketPath) {
8180
protected[devicePath] = struct{}{}
8281
continue
8382
}
@@ -106,8 +105,7 @@ func (m *manager) releaseStaleVGPUAssignment(ctx context.Context, id string) {
106105
if path == "" {
107106
return
108107
}
109-
pid, err := resolveLiveHypervisorPID(stored.HypervisorProcessIdentity, stored.SocketPath)
110-
if err != nil || pid > 0 {
108+
if hypervisorMayBeAlive(stored.HypervisorProcessIdentity, stored.SocketPath) {
111109
return
112110
}
113111
if err := m.releaseStoredVGPUPersisted(ctx, meta); err != nil {

lib/instances/vgpu_reconcile_linux_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestReconcileVGPUsProtectsSocketOwnerWithoutPersistedPID(t *testing.T) {
2828
destroyed = append(destroyed, assignment)
2929
return nil
3030
},
31-
reconcileVGPUDevices: func(_ context.Context, p map[string]struct{}, _ bool) error {
31+
reconcileVGPUDevices: func(_ context.Context, p map[string]struct{}) error {
3232
protected = p
3333
return nil
3434
},

lib/instances/vgpu_reconcile_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestReconcileVGPUsReleasesOnlyDeadClaims(t *testing.T) {
2323
destroyed = append(destroyed, assignment)
2424
return nil
2525
},
26-
reconcileVGPUDevices: func(context.Context, map[string]struct{}, bool) error { return nil },
26+
reconcileVGPUDevices: func(context.Context, map[string]struct{}) error { return nil },
2727
}
2828
liveIdentity := HypervisorProcessIdentity{}
2929
liveIdentity.Set(os.Getpid())
@@ -59,7 +59,7 @@ func TestReconcileVGPUsKeepsAssignmentWhenReleaseFails(t *testing.T) {
5959
}
6060
return nil
6161
},
62-
reconcileVGPUDevices: func(context.Context, map[string]struct{}, bool) error { return nil },
62+
reconcileVGPUDevices: func(context.Context, map[string]struct{}) error { return nil },
6363
}
6464
meta := saveTestVGPUInstance(t, m, "wedged")
6565
meta.GPUFramework = devices.VGPUFrameworkVendorVFIO
@@ -85,7 +85,7 @@ func TestReconcileVGPUsSkipsDevicePassWhenListingFails(t *testing.T) {
8585
var passes atomic.Int32
8686
m := &manager{
8787
paths: paths.New(t.TempDir()),
88-
reconcileVGPUDevices: func(context.Context, map[string]struct{}, bool) error {
88+
reconcileVGPUDevices: func(context.Context, map[string]struct{}) error {
8989
passes.Add(1)
9090
return nil
9191
},
@@ -106,7 +106,7 @@ func TestStartVGPUReconcilerSkipsHostsWithoutGPUs(t *testing.T) {
106106
discoverVGPU: func() (devices.VGPUFramework, []devices.VirtualFunction, error) {
107107
return devices.VGPUFrameworkNone, nil, nil
108108
},
109-
reconcileVGPUDevices: func(context.Context, map[string]struct{}, bool) error {
109+
reconcileVGPUDevices: func(context.Context, map[string]struct{}) error {
110110
passes.Add(1)
111111
return nil
112112
},
@@ -125,7 +125,7 @@ func TestStartVGPUReconcilerRunsPeriodically(t *testing.T) {
125125
discoverVGPU: func() (devices.VGPUFramework, []devices.VirtualFunction, error) {
126126
return devices.VGPUFrameworkVendorVFIO, nil, nil
127127
},
128-
reconcileVGPUDevices: func(context.Context, map[string]struct{}, bool) error {
128+
reconcileVGPUDevices: func(context.Context, map[string]struct{}) error {
129129
passes.Add(1)
130130
return nil
131131
},

lib/instances/vgpu_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func TestVGPUCrashAfterClaimIsReconciled(t *testing.T) {
124124
destroyed = append(destroyed, assignment)
125125
return nil
126126
}
127-
m.reconcileVGPUDevices = func(context.Context, map[string]struct{}, bool) error { return nil }
127+
m.reconcileVGPUDevices = func(context.Context, map[string]struct{}) error { return nil }
128128
m.ReconcileVGPUs(context.Background())
129129

130130
require.Equal(t, []devices.VGPUAssignment{{

0 commit comments

Comments
 (0)