Skip to content

Commit 0e59abd

Browse files
committed
Add validation markers for required params with PVC creation
Signed-off-by: Shiva Krishna, Merla <smerla@nvidia.com>
1 parent 5812e5d commit 0e59abd

12 files changed

Lines changed: 37 additions & 32 deletions

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ test-e2e:
131131
.PHONY: lint
132132
lint: golangci-lint
133133
$(GOLANGCI_LINT) config path
134-
$(GOLANGCI_LINT) run -v
134+
$(GOLANGCI_LINT) run -v --timeout=5m
135135

136136
.PHONY: lint-fix
137137
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
138-
$(GOLANGCI_LINT) run --fix
138+
$(GOLANGCI_LINT) run --fix --timeout=5m
139139

140140
##@ Build
141141

api/apps/v1alpha1/common_types.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,13 @@ type PersistentVolumeClaim struct {
227227
// StorageClass to be used for PVC creation. Leave it as empty if the PVC is already created or
228228
// a default storage class is set in the cluster.
229229
StorageClass string `json:"storageClass,omitempty"`
230-
// Size of the NIM cache in Gi, used during PVC creation
230+
// Size of the NIM cache in Gi. Required if Create is true.
231+
// +kubebuilder:validation:Optional
232+
// +kubebuilder:validation:Rule="!(self.create == true) || self.size != null && self.size != ''"
231233
Size string `json:"size,omitempty"`
232-
// VolumeAccessMode is the volume access mode of the PVC
234+
// VolumeAccessMode is the access mode of the PVC. Required if Create is true.
235+
// +kubebuilder:validation:Optional
236+
// +kubebuilder:validation:Rule="!(self.create == true) || self.volumeAccessMode != null && self.volumeAccessMode != ''"
233237
VolumeAccessMode corev1.PersistentVolumeAccessMode `json:"volumeAccessMode,omitempty"`
234238
// SubPath is the path inside the PVC that should be mounted
235239
SubPath string `json:"subPath,omitempty"`

api/apps/v1alpha1/nemo_customizer_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,10 +1089,10 @@ func (n *NemoCustomizer) GetPVCParams() *rendertypes.PVCParams {
10891089
return params
10901090
}
10911091

1092-
// GetPVCAnnotations return custom PVC annotations setup by the user
1092+
// GetPVCAnnotations return custom PVC annotations setup by the user.
10931093
func (n *NemoCustomizer) GetPVCAnnotations() map[string]string {
10941094
// Get global customizer annotations
1095-
pvcAnnotations := n.GetAnnotations()
1095+
pvcAnnotations := n.GetNemoCustomizerAnnotations()
10961096

10971097
if n.Spec.Training.ModelPVC.Annotations != nil {
10981098
return utils.MergeMaps(pvcAnnotations, n.Spec.Training.ModelPVC.Annotations)

api/apps/v1alpha1/nemo_datastore_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ func (n *NemoDatastore) GetPVCParams() *rendertypes.PVCParams {
10891089

10901090
func (n *NemoDatastore) GetPVCAnnotations() map[string]string {
10911091
// Get global service annotations
1092-
pvcAnnotations := n.GetServiceAnnotations()
1092+
pvcAnnotations := n.GetNemoDatastoreAnnotations()
10931093

10941094
if n.Spec.PVC.Annotations != nil {
10951095
return utils.MergeMaps(pvcAnnotations, n.Spec.PVC.Annotations)

api/apps/v1alpha1/nemo_guardrails_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ func (n *NemoGuardrail) GetPVCParams() *rendertypes.PVCParams {
788788

789789
func (n *NemoGuardrail) GetPVCAnnotations() map[string]string {
790790
// Get global service annotations
791-
pvcAnnotations := n.GetServiceAnnotations()
791+
pvcAnnotations := n.GetNemoGuardrailAnnotations()
792792

793793
if n.Spec.ConfigStore.PVC.Annotations != nil {
794794
return utils.MergeMaps(pvcAnnotations, n.Spec.ConfigStore.PVC.Annotations)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,8 +1986,8 @@ spec:
19861986
description: Name is the name of the PVC
19871987
type: string
19881988
size:
1989-
description: Size of the NIM cache in Gi, used during PVC
1990-
creation
1989+
description: Size of the NIM cache in Gi. Required if Create
1990+
is true.
19911991
type: string
19921992
storageClass:
19931993
description: |-
@@ -1999,8 +1999,8 @@ spec:
19991999
be mounted
20002000
type: string
20012001
volumeAccessMode:
2002-
description: VolumeAccessMode is the volume access mode of
2003-
the PVC
2002+
description: VolumeAccessMode is the access mode of the PVC.
2003+
Required if Create is true.
20042004
type: string
20052005
type: object
20062006
networkConfig:

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,8 @@ spec:
800800
description: Name is the name of the PVC
801801
type: string
802802
size:
803-
description: Size of the NIM cache in Gi, used during PVC creation
803+
description: Size of the NIM cache in Gi. Required if Create is
804+
true.
804805
type: string
805806
storageClass:
806807
description: |-
@@ -812,8 +813,8 @@ spec:
812813
mounted
813814
type: string
814815
volumeAccessMode:
815-
description: VolumeAccessMode is the volume access mode of the
816-
PVC
816+
description: VolumeAccessMode is the access mode of the PVC. Required
817+
if Create is true.
817818
type: string
818819
type: object
819820
replicas:

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ spec:
8787
description: Name is the name of the PVC
8888
type: string
8989
size:
90-
description: Size of the NIM cache in Gi, used during PVC
91-
creation
90+
description: Size of the NIM cache in Gi. Required if Create
91+
is true.
9292
type: string
9393
storageClass:
9494
description: |-
@@ -100,8 +100,8 @@ spec:
100100
be mounted
101101
type: string
102102
volumeAccessMode:
103-
description: VolumeAccessMode is the volume access mode of
104-
the PVC
103+
description: VolumeAccessMode is the access mode of the PVC.
104+
Required if Create is true.
105105
type: string
106106
type: object
107107
type: object

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ spec:
369369
description: Name is the name of the PVC
370370
type: string
371371
size:
372-
description: Size of the NIM cache in Gi, used during PVC
373-
creation
372+
description: Size of the NIM cache in Gi. Required if Create
373+
is true.
374374
type: string
375375
storageClass:
376376
description: |-
@@ -382,8 +382,8 @@ spec:
382382
be mounted
383383
type: string
384384
volumeAccessMode:
385-
description: VolumeAccessMode is the volume access mode of
386-
the PVC
385+
description: VolumeAccessMode is the access mode of the PVC.
386+
Required if Create is true.
387387
type: string
388388
type: object
389389
type: object

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,8 +2206,8 @@ spec:
22062206
description: Name is the name of the PVC
22072207
type: string
22082208
size:
2209-
description: Size of the NIM cache in Gi, used during
2210-
PVC creation
2209+
description: Size of the NIM cache in Gi. Required
2210+
if Create is true.
22112211
type: string
22122212
storageClass:
22132213
description: |-
@@ -2219,8 +2219,8 @@ spec:
22192219
that should be mounted
22202220
type: string
22212221
volumeAccessMode:
2222-
description: VolumeAccessMode is the volume access
2223-
mode of the PVC
2222+
description: VolumeAccessMode is the access mode
2223+
of the PVC. Required if Create is true.
22242224
type: string
22252225
type: object
22262226
readOnly:

0 commit comments

Comments
 (0)