diff --git a/api/config/v1/sharing.go b/api/config/v1/sharing.go index 82906fd36..ab7681124 100644 --- a/api/config/v1/sharing.go +++ b/api/config/v1/sharing.go @@ -19,7 +19,7 @@ package v1 // Sharing encapsulates the set of sharing strategies that are supported. type Sharing struct { // TimeSlicing defines the set of replicas to be made for timeSlicing available resources. - TimeSlicing ReplicatedResources `json:"timeSlicing,omitempty" yaml:"timeSlicing,omitempty"` + TimeSlicing *ReplicatedResources `json:"timeSlicing,omitempty" yaml:"timeSlicing,omitempty"` // MPS defines the set of replicas to be shared using MPS MPS *ReplicatedResources `json:"mps,omitempty" yaml:"mps,omitempty"` } @@ -49,5 +49,5 @@ func (s *Sharing) ReplicatedResources() *ReplicatedResources { if s.MPS != nil { return s.MPS } - return &s.TimeSlicing + return s.TimeSlicing } diff --git a/internal/lm/mig-strategy_test.go b/internal/lm/mig-strategy_test.go index 73fcbac95..7adb09515 100644 --- a/internal/lm/mig-strategy_test.go +++ b/internal/lm/mig-strategy_test.go @@ -183,7 +183,7 @@ func TestMigStrategyNoneLabels(t *testing.T) { }, }, Sharing: spec.Sharing{ - TimeSlicing: tc.timeSlicing, + TimeSlicing: &tc.timeSlicing, }, } diff --git a/internal/lm/nvml_test.go b/internal/lm/nvml_test.go index 073721cd8..812e7f82e 100644 --- a/internal/lm/nvml_test.go +++ b/internal/lm/nvml_test.go @@ -103,7 +103,7 @@ func TestSharingLabeler(t *testing.T) { description: "config with timeslicing replicas", config: &spec.Config{ Sharing: spec.Sharing{ - TimeSlicing: spec.ReplicatedResources{ + TimeSlicing: &spec.ReplicatedResources{ Resources: []spec.ReplicatedResource{ { Replicas: 2, diff --git a/internal/lm/resource.go b/internal/lm/resource.go index 5ed73ca18..5a0d5428c 100644 --- a/internal/lm/resource.go +++ b/internal/lm/resource.go @@ -215,7 +215,7 @@ func (rl resourceLabeler) getReplicas() int { // sharingDisabled checks whether the resourceLabeler has sharing disabled // TODO: The nil check here is because we call NewGPUResourceLabeler with a nil config when sharing is disabled. func (rl resourceLabeler) sharingDisabled() bool { - return rl.sharing == nil + return rl.sharing == nil || (rl.sharing.SharingStrategy() == spec.SharingStrategyNone) } // isShared checks whether the resource is shared. diff --git a/internal/lm/resource_test.go b/internal/lm/resource_test.go index c2e3b3e5c..6a3d7ae7f 100644 --- a/internal/lm/resource_test.go +++ b/internal/lm/resource_test.go @@ -55,7 +55,7 @@ func TestGPUResourceLabeler(t *testing.T) { description: "time-slicing ignores non-matching resource", count: 1, sharing: spec.Sharing{ - TimeSlicing: spec.ReplicatedResources{ + TimeSlicing: &spec.ReplicatedResources{ Resources: []spec.ReplicatedResource{ { Name: "nvidia.com/not-gpu", @@ -79,7 +79,7 @@ func TestGPUResourceLabeler(t *testing.T) { description: "time-slicing appends suffix and doubles count", count: 1, sharing: spec.Sharing{ - TimeSlicing: spec.ReplicatedResources{ + TimeSlicing: &spec.ReplicatedResources{ Resources: []spec.ReplicatedResource{ { Name: "nvidia.com/gpu", @@ -103,7 +103,7 @@ func TestGPUResourceLabeler(t *testing.T) { description: "time-slicing renamed does not append suffix and doubles count", count: 1, sharing: spec.Sharing{ - TimeSlicing: spec.ReplicatedResources{ + TimeSlicing: &spec.ReplicatedResources{ Resources: []spec.ReplicatedResource{ { Name: "nvidia.com/gpu", @@ -422,7 +422,7 @@ func TestMigResourceLabeler(t *testing.T) { t.Run(tc.description, func(t *testing.T) { config := &spec.Config{ Sharing: spec.Sharing{ - TimeSlicing: tc.timeSlicing, + TimeSlicing: &tc.timeSlicing, }, } l, err := NewMIGResourceLabeler(tc.resourceName, config, device, tc.count) diff --git a/internal/rm/rm_test.go b/internal/rm/rm_test.go index 063ed4034..26c10f6c7 100644 --- a/internal/rm/rm_test.go +++ b/internal/rm/rm_test.go @@ -53,7 +53,7 @@ func TestValidateRequest(t *testing.T) { { description: "timeslicing with single device", sharing: spec.Sharing{ - TimeSlicing: spec.ReplicatedResources{ + TimeSlicing: &spec.ReplicatedResources{ Resources: []spec.ReplicatedResource{ { Name: "nvidia.com/gpu", @@ -73,7 +73,7 @@ func TestValidateRequest(t *testing.T) { { description: "timeslicing with two devices", sharing: spec.Sharing{ - TimeSlicing: spec.ReplicatedResources{ + TimeSlicing: &spec.ReplicatedResources{ Resources: []spec.ReplicatedResource{ { Name: "nvidia.com/gpu", @@ -93,7 +93,7 @@ func TestValidateRequest(t *testing.T) { { description: "timeslicing with two devices -- failRequestsGreaterThanOne", sharing: spec.Sharing{ - TimeSlicing: spec.ReplicatedResources{ + TimeSlicing: &spec.ReplicatedResources{ FailRequestsGreaterThanOne: true, Resources: []spec.ReplicatedResource{ {