Skip to content

Commit 9fb92ad

Browse files
authored
Merge pull request #89 from klueska/cleanup-in-prep-for-structured-params
Cleanup in prep for structured params
2 parents 5c31d1d + ea4782e commit 9fb92ad

23 files changed

+331
-246
lines changed

api/nvidia.com/resource/gpu/nas/v1alpha1/api.go

-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ const (
2424
GroupName = "nas.gpu.resource.nvidia.com"
2525
Version = "v1alpha1"
2626

27-
GpuDeviceType = "gpu"
28-
MigDeviceType = "mig"
29-
UnknownDeviceType = "unknown"
30-
3127
NodeAllocationStateStatusReady = "Ready"
3228
NodeAllocationStateStatusNotReady = "NotReady"
3329
)

api/nvidia.com/resource/gpu/nas/v1alpha1/nas.go

+19-21
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,12 @@
1717
package v1alpha1
1818

1919
import (
20+
"github.com/NVIDIA/k8s-dra-driver/api/utils/sharing"
21+
"github.com/NVIDIA/k8s-dra-driver/api/utils/types"
22+
2023
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2124
)
2225

23-
// ClaimInfo holds the identifying information about a claim.
24-
type ClaimInfo struct {
25-
Namespace string `json:"namespace"`
26-
Name string `json:"name"`
27-
UID string `json:"uid"`
28-
}
29-
3026
// MigDevicePlacement represents the placement of a MIG device within a GPU.
3127
type MigDevicePlacement struct {
3228
Start int `json:"start"`
@@ -43,6 +39,8 @@ type AllocatableGpu struct {
4339
Brand string `json:"brand"`
4440
Architecture string `json:"architecture"`
4541
CUDAComputeCapability string `json:"cudaComputeCapability"`
42+
DriverVersion string `json:"driverVersion"`
43+
CUDADriverVersion string `json:"cudaDriverVersion"`
4644
}
4745

4846
// AllocatableMigDevice represents an allocatable MIG device (and its possible placements) on a given type of GPU.
@@ -61,12 +59,12 @@ type AllocatableDevice struct {
6159
// Type returns the type of AllocatableDevice this represents.
6260
func (d AllocatableDevice) Type() string {
6361
if d.Gpu != nil {
64-
return GpuDeviceType
62+
return types.GpuDeviceType
6563
}
6664
if d.Mig != nil {
67-
return MigDeviceType
65+
return types.MigDeviceType
6866
}
69-
return UnknownDeviceType
67+
return types.UnknownDeviceType
7068
}
7169

7270
// AllocatedGpu represents an allocated GPU.
@@ -83,32 +81,32 @@ type AllocatedMigDevice struct {
8381

8482
// AllocatedGpus represents a set of allocated GPUs.
8583
type AllocatedGpus struct {
86-
Devices []AllocatedGpu `json:"devices"`
87-
Sharing *GpuSharing `json:"sharing,omitempty"`
84+
Devices []AllocatedGpu `json:"devices"`
85+
Sharing *sharing.GpuSharing `json:"sharing,omitempty"`
8886
}
8987

9088
// AllocatedMigDevices represents a set of allocated MIG devices.
9189
type AllocatedMigDevices struct {
92-
Devices []AllocatedMigDevice `json:"devices"`
93-
Sharing *MigDeviceSharing `json:"sharing,omitempty"`
90+
Devices []AllocatedMigDevice `json:"devices"`
91+
Sharing *sharing.MigDeviceSharing `json:"sharing,omitempty"`
9492
}
9593

9694
// AllocatedDevices represents a set of allocated devices.
9795
type AllocatedDevices struct {
98-
ClaimInfo *ClaimInfo `json:"claimInfo"`
96+
ClaimInfo *types.ClaimInfo `json:"claimInfo"`
9997
Gpu *AllocatedGpus `json:"gpu,omitempty"`
10098
Mig *AllocatedMigDevices `json:"mig,omitempty"`
10199
}
102100

103101
// Type returns the type of AllocatedDevices this represents.
104102
func (r AllocatedDevices) Type() string {
105103
if r.Gpu != nil {
106-
return GpuDeviceType
104+
return types.GpuDeviceType
107105
}
108106
if r.Mig != nil {
109-
return MigDeviceType
107+
return types.MigDeviceType
110108
}
111-
return UnknownDeviceType
109+
return types.UnknownDeviceType
112110
}
113111

114112
// PreparedGpu represents a prepared GPU on a node.
@@ -143,12 +141,12 @@ type PreparedDevices struct {
143141
// Type returns the type of PreparedDevices this represents.
144142
func (d PreparedDevices) Type() string {
145143
if d.Gpu != nil {
146-
return GpuDeviceType
144+
return types.GpuDeviceType
147145
}
148146
if d.Mig != nil {
149-
return MigDeviceType
147+
return types.MigDeviceType
150148
}
151-
return UnknownDeviceType
149+
return types.UnknownDeviceType
152150
}
153151

154152
// NodeAllocationStateSpec is the spec for the NodeAllocationState CRD.

api/nvidia.com/resource/gpu/nas/v1alpha1/zz_generated.deepcopy.go

+5-136
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/nvidia.com/resource/gpu/v1alpha1/gpuclaim.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ package v1alpha1
1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121

22-
nascrd "github.com/NVIDIA/k8s-dra-driver/api/nvidia.com/resource/gpu/nas/v1alpha1"
22+
"github.com/NVIDIA/k8s-dra-driver/api/utils/sharing"
2323
)
2424

2525
// GpuClaimParametersSpec is the spec for the GpuClaimParameters CRD.
2626
type GpuClaimParametersSpec struct {
27-
Count *int `json:"count,omitempty"`
28-
Selector *GpuSelector `json:"selector,omitempty"`
29-
Sharing *nascrd.GpuSharing `json:"sharing,omitempty"`
27+
Count *int `json:"count,omitempty"`
28+
Selector *GpuSelector `json:"selector,omitempty"`
29+
Sharing *sharing.GpuSharing `json:"sharing,omitempty"`
3030
}
3131

3232
// +genclient

api/nvidia.com/resource/gpu/v1alpha1/gpuselector.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type GpuSelectorProperties struct {
6969
Architecture *selector.GlobProperty `json:"architecture,omitempty"`
7070
CUDAComputeCapability *selector.VersionComparator `json:"cudaComputeCapability,omitempty"`
7171
DriverVersion *selector.VersionComparator `json:"driverVersion,omitempty"`
72-
CUDARuntimeVersion *selector.VersionComparator `json:"cudaRuntimeVersion,omitempty"`
72+
CUDADriverVersion *selector.VersionComparator `json:"cudaDriverVersion,omitempty"`
7373
}
7474

7575
// Matches evaluates a GpuSelector to see if it matches the boolean expression it represents

api/nvidia.com/resource/gpu/v1alpha1/migclaim.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ package v1alpha1
1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121

22-
nascrd "github.com/NVIDIA/k8s-dra-driver/api/nvidia.com/resource/gpu/nas/v1alpha1"
22+
"github.com/NVIDIA/k8s-dra-driver/api/utils/sharing"
2323
)
2424

2525
// MigDeviceClaimParametersSpec is the spec for the MigDeviceClaimParameters CRD.
2626
type MigDeviceClaimParametersSpec struct {
27-
Profile string `json:"profile,omitempty"`
28-
Sharing *nascrd.MigDeviceSharing `json:"sharing,omitempty"`
29-
GpuClaimParametersName string `json:"gpuClaimName,omitempty"`
27+
Profile string `json:"profile,omitempty"`
28+
Sharing *sharing.MigDeviceSharing `json:"sharing,omitempty"`
29+
GpuClaimParametersName string `json:"gpuClaimName,omitempty"`
3030
}
3131

3232
// +genclient

api/nvidia.com/resource/gpu/v1alpha1/zz_generated.deepcopy.go

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)