Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup in prep for structured params #89

Merged
merged 4 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions api/nvidia.com/resource/gpu/nas/v1alpha1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ const (
GroupName = "nas.gpu.resource.nvidia.com"
Version = "v1alpha1"

GpuDeviceType = "gpu"
MigDeviceType = "mig"
UnknownDeviceType = "unknown"

NodeAllocationStateStatusReady = "Ready"
NodeAllocationStateStatusNotReady = "NotReady"
)
Expand Down
40 changes: 19 additions & 21 deletions api/nvidia.com/resource/gpu/nas/v1alpha1/nas.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@
package v1alpha1

import (
"github.com/NVIDIA/k8s-dra-driver/api/utils/sharing"
"github.com/NVIDIA/k8s-dra-driver/api/utils/types"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ClaimInfo holds the identifying information about a claim.
type ClaimInfo struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
UID string `json:"uid"`
}

// MigDevicePlacement represents the placement of a MIG device within a GPU.
type MigDevicePlacement struct {
Start int `json:"start"`
Expand All @@ -43,6 +39,8 @@ type AllocatableGpu struct {
Brand string `json:"brand"`
Architecture string `json:"architecture"`
CUDAComputeCapability string `json:"cudaComputeCapability"`
DriverVersion string `json:"driverVersion"`
CUDADriverVersion string `json:"cudaDriverVersion"`
}

// AllocatableMigDevice represents an allocatable MIG device (and its possible placements) on a given type of GPU.
Expand All @@ -61,12 +59,12 @@ type AllocatableDevice struct {
// Type returns the type of AllocatableDevice this represents.
func (d AllocatableDevice) Type() string {
if d.Gpu != nil {
return GpuDeviceType
return types.GpuDeviceType
}
if d.Mig != nil {
return MigDeviceType
return types.MigDeviceType
}
return UnknownDeviceType
return types.UnknownDeviceType
}

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

// AllocatedGpus represents a set of allocated GPUs.
type AllocatedGpus struct {
Devices []AllocatedGpu `json:"devices"`
Sharing *GpuSharing `json:"sharing,omitempty"`
Devices []AllocatedGpu `json:"devices"`
Sharing *sharing.GpuSharing `json:"sharing,omitempty"`
}

// AllocatedMigDevices represents a set of allocated MIG devices.
type AllocatedMigDevices struct {
Devices []AllocatedMigDevice `json:"devices"`
Sharing *MigDeviceSharing `json:"sharing,omitempty"`
Devices []AllocatedMigDevice `json:"devices"`
Sharing *sharing.MigDeviceSharing `json:"sharing,omitempty"`
}

// AllocatedDevices represents a set of allocated devices.
type AllocatedDevices struct {
ClaimInfo *ClaimInfo `json:"claimInfo"`
ClaimInfo *types.ClaimInfo `json:"claimInfo"`
Gpu *AllocatedGpus `json:"gpu,omitempty"`
Mig *AllocatedMigDevices `json:"mig,omitempty"`
}

// Type returns the type of AllocatedDevices this represents.
func (r AllocatedDevices) Type() string {
if r.Gpu != nil {
return GpuDeviceType
return types.GpuDeviceType
}
if r.Mig != nil {
return MigDeviceType
return types.MigDeviceType
}
return UnknownDeviceType
return types.UnknownDeviceType
}

// PreparedGpu represents a prepared GPU on a node.
Expand Down Expand Up @@ -143,12 +141,12 @@ type PreparedDevices struct {
// Type returns the type of PreparedDevices this represents.
func (d PreparedDevices) Type() string {
if d.Gpu != nil {
return GpuDeviceType
return types.GpuDeviceType
}
if d.Mig != nil {
return MigDeviceType
return types.MigDeviceType
}
return UnknownDeviceType
return types.UnknownDeviceType
}

// NodeAllocationStateSpec is the spec for the NodeAllocationState CRD.
Expand Down
141 changes: 5 additions & 136 deletions api/nvidia.com/resource/gpu/nas/v1alpha1/zz_generated.deepcopy.go
elezar marked this conversation as resolved.
Show resolved Hide resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions api/nvidia.com/resource/gpu/v1alpha1/gpuclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

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

// GpuClaimParametersSpec is the spec for the GpuClaimParameters CRD.
type GpuClaimParametersSpec struct {
Count *int `json:"count,omitempty"`
Selector *GpuSelector `json:"selector,omitempty"`
Sharing *nascrd.GpuSharing `json:"sharing,omitempty"`
Count *int `json:"count,omitempty"`
Selector *GpuSelector `json:"selector,omitempty"`
Sharing *sharing.GpuSharing `json:"sharing,omitempty"`
elezar marked this conversation as resolved.
Show resolved Hide resolved
}

// +genclient
Expand Down
2 changes: 1 addition & 1 deletion api/nvidia.com/resource/gpu/v1alpha1/gpuselector.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type GpuSelectorProperties struct {
Architecture *selector.GlobProperty `json:"architecture,omitempty"`
CUDAComputeCapability *selector.VersionComparator `json:"cudaComputeCapability,omitempty"`
DriverVersion *selector.VersionComparator `json:"driverVersion,omitempty"`
CUDARuntimeVersion *selector.VersionComparator `json:"cudaRuntimeVersion,omitempty"`
CUDADriverVersion *selector.VersionComparator `json:"cudaDriverVersion,omitempty"`
}

// Matches evaluates a GpuSelector to see if it matches the boolean expression it represents
Expand Down
8 changes: 4 additions & 4 deletions api/nvidia.com/resource/gpu/v1alpha1/migclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

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

// MigDeviceClaimParametersSpec is the spec for the MigDeviceClaimParameters CRD.
type MigDeviceClaimParametersSpec struct {
Profile string `json:"profile,omitempty"`
Sharing *nascrd.MigDeviceSharing `json:"sharing,omitempty"`
GpuClaimParametersName string `json:"gpuClaimName,omitempty"`
Profile string `json:"profile,omitempty"`
Sharing *sharing.MigDeviceSharing `json:"sharing,omitempty"`
GpuClaimParametersName string `json:"gpuClaimName,omitempty"`
}

// +genclient
Expand Down
10 changes: 5 additions & 5 deletions api/nvidia.com/resource/gpu/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading