Skip to content

Commit be6a9ca

Browse files
committed
rework draResource status api
Signed-off-by: Varun Ramachandra Sekar <vsekar@nvidia.com>
1 parent b3c1db6 commit be6a9ca

File tree

10 files changed

+461
-259
lines changed

10 files changed

+461
-259
lines changed

api/apps/v1alpha1/common_types.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,17 +294,22 @@ type DRAResource struct {
294294
}
295295

296296
// DRAResourceStatus defines the status of the DRAResource.
297+
// +kubebuilder:validation:XValidation:rule="has(self.resourceClaimStatus) != has(self.resourceClaimTemplateStatus)",message="exactly one of resourceClaimStatus and resourceClaimTemplateStatus must be set."
297298
type DRAResourceStatus struct {
299+
// Name is the pod claim name referenced in the pod spec as `spec.resourceClaims[].name` for this DRA resource.
298300
Name string `json:"name"`
299-
// ResourceClaimTemplateName is the name of the ResourceClaimTemplate that was
300-
// used to generate the ResourceClaim for an instance of NIMService.
301-
ResourceClaimTemplateName *string `json:"resourceClaimTemplateName,omitempty"`
302-
// ResourceClaims is the status of resource claims.
303-
ResourceClaims []DRAResourceClaimStatus `json:"resourceClaims,omitempty"`
301+
// ResourceClaimStatus is the status of the resource claim in this DRA resource.
302+
//
303+
// Exactly one of resourceClaimStatus and resourceClaimTemplateStatus will be set.
304+
ResourceClaimStatus *DRAResourceClaimStatusInfo `json:"resourceClaimStatus,omitempty"`
305+
// ResourceClaimTemplateStatus is the status of the resource claim template in this DRA resource.
306+
//
307+
// Exactly one of resourceClaimStatus and resourceClaimTemplateStatus will be set.
308+
ResourceClaimTemplateStatus *DRAResourceClaimTemplateStatusInfo `json:"resourceClaimTemplateStatus,omitempty"`
304309
}
305310

306-
// DRAResourceClaimStatus defines the status of the DRAResourceClaim.
307-
type DRAResourceClaimStatus struct {
311+
// DRAResourceClaimStatusInfo defines the status of a ResourceClaim referenced in the DRAResource.
312+
type DRAResourceClaimStatusInfo struct {
308313
// Name is the name of the ResourceClaim.
309314
Name string `json:"name"`
310315
// State is the state of the ResourceClaim.
@@ -317,3 +322,11 @@ type DRAResourceClaimStatus struct {
317322
// +kubebuilder:validation:default=pending
318323
State string `json:"state"`
319324
}
325+
326+
// DRAResourceClaimTemplateStatusInfo defines the status of a ResourceClaimTemplate referenced in the DRAResource.
327+
type DRAResourceClaimTemplateStatusInfo struct {
328+
// Name is the name of the resource claim template.
329+
Name string `json:"name"`
330+
// ResourceClaimStatuses is the statuses of the generated resource claims from this resource claim template.
331+
ResourceClaimStatuses []DRAResourceClaimStatusInfo `json:"resourceClaimStatuses,omitempty"`
332+
}

api/apps/v1alpha1/zz_generated.deepcopy.go

Lines changed: 31 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/manifests/apps.nvidia.com_nimservices.yaml

Lines changed: 63 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,38 +2363,74 @@ spec:
23632363
description: DRAResourceStatus defines the status of the DRAResource.
23642364
properties:
23652365
name:
2366+
description: Name is the pod claim name referenced in the pod
2367+
spec as `spec.resourceClaims[].name` for this DRA resource.
23662368
type: string
2367-
resourceClaimTemplateName:
2369+
resourceClaimStatus:
23682370
description: |-
2369-
ResourceClaimTemplateName is the name of the ResourceClaimTemplate that was
2370-
used to generate the ResourceClaim for an instance of NIMService.
2371-
type: string
2372-
resourceClaims:
2373-
description: ResourceClaims is the status of resource claims.
2374-
items:
2375-
description: DRAResourceClaimStatus defines the status of
2376-
the DRAResourceClaim.
2377-
properties:
2378-
name:
2379-
description: Name is the name of the ResourceClaim.
2380-
type: string
2381-
state:
2382-
description: |-
2383-
State is the state of the ResourceClaim.
2384-
* pending: the resource claim is pending allocation.
2385-
* deleted: the resource claim has a deletion timestamp set but is not yet finalized.
2386-
* allocated: the resource claim is allocated to a pod.
2387-
* reserved: the resource claim is consumed by a pod.
2388-
This field will have one or more of the above values depending on the status of the resource claim.
2389-
type: string
2390-
required:
2391-
- name
2392-
- state
2393-
type: object
2394-
type: array
2371+
ResourceClaimStatus is the status of the resource claim in this DRA resource.
2372+
2373+
Exactly one of resourceClaimStatus and resourceClaimTemplateStatus will be set.
2374+
properties:
2375+
name:
2376+
description: Name is the name of the ResourceClaim.
2377+
type: string
2378+
state:
2379+
description: |-
2380+
State is the state of the ResourceClaim.
2381+
* pending: the resource claim is pending allocation.
2382+
* deleted: the resource claim has a deletion timestamp set but is not yet finalized.
2383+
* allocated: the resource claim is allocated to a pod.
2384+
* reserved: the resource claim is consumed by a pod.
2385+
This field will have one or more of the above values depending on the status of the resource claim.
2386+
type: string
2387+
required:
2388+
- name
2389+
- state
2390+
type: object
2391+
resourceClaimTemplateStatus:
2392+
description: |-
2393+
ResourceClaimTemplateStatus is the status of the resource claim template in this DRA resource.
2394+
2395+
Exactly one of resourceClaimStatus and resourceClaimTemplateStatus will be set.
2396+
properties:
2397+
name:
2398+
description: Name is the name of the resource claim template.
2399+
type: string
2400+
resourceClaimStatuses:
2401+
description: ResourceClaimStatuses is the statuses of the
2402+
generated resource claims from this resource claim template.
2403+
items:
2404+
description: DRAResourceClaimStatusInfo defines the status
2405+
of a ResourceClaim referenced in the DRAResource.
2406+
properties:
2407+
name:
2408+
description: Name is the name of the ResourceClaim.
2409+
type: string
2410+
state:
2411+
description: |-
2412+
State is the state of the ResourceClaim.
2413+
* pending: the resource claim is pending allocation.
2414+
* deleted: the resource claim has a deletion timestamp set but is not yet finalized.
2415+
* allocated: the resource claim is allocated to a pod.
2416+
* reserved: the resource claim is consumed by a pod.
2417+
This field will have one or more of the above values depending on the status of the resource claim.
2418+
type: string
2419+
required:
2420+
- name
2421+
- state
2422+
type: object
2423+
type: array
2424+
required:
2425+
- name
2426+
type: object
23952427
required:
23962428
- name
23972429
type: object
2430+
x-kubernetes-validations:
2431+
- message: exactly one of resourceClaimStatus and resourceClaimTemplateStatus
2432+
must be set.
2433+
rule: has(self.resourceClaimStatus) != has(self.resourceClaimTemplateStatus)
23982434
type: array
23992435
x-kubernetes-list-map-keys:
24002436
- name

config/crd/bases/apps.nvidia.com_nimservices.yaml

Lines changed: 63 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,38 +2363,74 @@ spec:
23632363
description: DRAResourceStatus defines the status of the DRAResource.
23642364
properties:
23652365
name:
2366+
description: Name is the pod claim name referenced in the pod
2367+
spec as `spec.resourceClaims[].name` for this DRA resource.
23662368
type: string
2367-
resourceClaimTemplateName:
2369+
resourceClaimStatus:
23682370
description: |-
2369-
ResourceClaimTemplateName is the name of the ResourceClaimTemplate that was
2370-
used to generate the ResourceClaim for an instance of NIMService.
2371-
type: string
2372-
resourceClaims:
2373-
description: ResourceClaims is the status of resource claims.
2374-
items:
2375-
description: DRAResourceClaimStatus defines the status of
2376-
the DRAResourceClaim.
2377-
properties:
2378-
name:
2379-
description: Name is the name of the ResourceClaim.
2380-
type: string
2381-
state:
2382-
description: |-
2383-
State is the state of the ResourceClaim.
2384-
* pending: the resource claim is pending allocation.
2385-
* deleted: the resource claim has a deletion timestamp set but is not yet finalized.
2386-
* allocated: the resource claim is allocated to a pod.
2387-
* reserved: the resource claim is consumed by a pod.
2388-
This field will have one or more of the above values depending on the status of the resource claim.
2389-
type: string
2390-
required:
2391-
- name
2392-
- state
2393-
type: object
2394-
type: array
2371+
ResourceClaimStatus is the status of the resource claim in this DRA resource.
2372+
2373+
Exactly one of resourceClaimStatus and resourceClaimTemplateStatus will be set.
2374+
properties:
2375+
name:
2376+
description: Name is the name of the ResourceClaim.
2377+
type: string
2378+
state:
2379+
description: |-
2380+
State is the state of the ResourceClaim.
2381+
* pending: the resource claim is pending allocation.
2382+
* deleted: the resource claim has a deletion timestamp set but is not yet finalized.
2383+
* allocated: the resource claim is allocated to a pod.
2384+
* reserved: the resource claim is consumed by a pod.
2385+
This field will have one or more of the above values depending on the status of the resource claim.
2386+
type: string
2387+
required:
2388+
- name
2389+
- state
2390+
type: object
2391+
resourceClaimTemplateStatus:
2392+
description: |-
2393+
ResourceClaimTemplateStatus is the status of the resource claim template in this DRA resource.
2394+
2395+
Exactly one of resourceClaimStatus and resourceClaimTemplateStatus will be set.
2396+
properties:
2397+
name:
2398+
description: Name is the name of the resource claim template.
2399+
type: string
2400+
resourceClaimStatuses:
2401+
description: ResourceClaimStatuses is the statuses of the
2402+
generated resource claims from this resource claim template.
2403+
items:
2404+
description: DRAResourceClaimStatusInfo defines the status
2405+
of a ResourceClaim referenced in the DRAResource.
2406+
properties:
2407+
name:
2408+
description: Name is the name of the ResourceClaim.
2409+
type: string
2410+
state:
2411+
description: |-
2412+
State is the state of the ResourceClaim.
2413+
* pending: the resource claim is pending allocation.
2414+
* deleted: the resource claim has a deletion timestamp set but is not yet finalized.
2415+
* allocated: the resource claim is allocated to a pod.
2416+
* reserved: the resource claim is consumed by a pod.
2417+
This field will have one or more of the above values depending on the status of the resource claim.
2418+
type: string
2419+
required:
2420+
- name
2421+
- state
2422+
type: object
2423+
type: array
2424+
required:
2425+
- name
2426+
type: object
23952427
required:
23962428
- name
23972429
type: object
2430+
x-kubernetes-validations:
2431+
- message: exactly one of resourceClaimStatus and resourceClaimTemplateStatus
2432+
must be set.
2433+
rule: has(self.resourceClaimStatus) != has(self.resourceClaimTemplateStatus)
23982434
type: array
23992435
x-kubernetes-list-map-keys:
24002436
- name

0 commit comments

Comments
 (0)