From 1bd6ec815bed6d06300503b7f29953af0a943458 Mon Sep 17 00:00:00 2001 From: "Shiva Krishna, Merla" Date: Thu, 8 Aug 2024 06:22:45 -0700 Subject: [PATCH 1/3] Add Make target to sync CRDS and remove profiles printcolumn as it is now a map Signed-off-by: Shiva Krishna, Merla --- Makefile | 7 +++++++ api/apps/v1alpha1/nimcache_types.go | 1 - bundle/manifests/apps.nvidia.com_nimcaches.yaml | 4 ---- config/crd/bases/apps.nvidia.com_nimcaches.yaml | 4 ---- .../k8s-nim-operator/crds/apps.nvidia.com_nimcaches.yaml | 5 ----- 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index c072eec7..287a4c96 100644 --- a/Makefile +++ b/Makefile @@ -189,11 +189,18 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. $(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f - +.PHONY: install-tools install-tools: @echo Installing tools from tools.go export GOBIN=$(PROJECT_DIR)/bin && \ grep '^\s*_' tools/tools.go | awk '{print $$2}' | xargs -tI % $(GO_CMD) install -mod=readonly -modfile=tools/go.mod % +.PHONY: sync-crds +sync-crds: + @echo Syncing CRDs into Helm and OLM packages + cp $(PROJECT_DIR)/config/crd/bases/* deployments/helm/k8s-nim-operator/crds + cp $(PROJECT_DIR)/config/crd/bases/* bundle/manifests + ##@ Dependencies ## Location to install dependencies to diff --git a/api/apps/v1alpha1/nimcache_types.go b/api/apps/v1alpha1/nimcache_types.go index da9eeb65..e010d3d5 100644 --- a/api/apps/v1alpha1/nimcache_types.go +++ b/api/apps/v1alpha1/nimcache_types.go @@ -217,7 +217,6 @@ func (s *NIMSource) EnvFromSecrets() []v1.EnvFromSource { // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.state`,priority=0 // +kubebuilder:printcolumn:name="PVC",type=string,JSONPath=`.status.pvc`,priority=0 -// +kubebuilder:printcolumn:name="Profiles",type=string,JSONPath=`.status.profiles`,priority=1 // +kubebuilder:printcolumn:name="Age",type=string,JSONPath=`.metadata.creationTimestamp`,priority=0 // NIMCache is the Schema for the nimcaches API diff --git a/bundle/manifests/apps.nvidia.com_nimcaches.yaml b/bundle/manifests/apps.nvidia.com_nimcaches.yaml index 08cf8e68..ff645d0f 100644 --- a/bundle/manifests/apps.nvidia.com_nimcaches.yaml +++ b/bundle/manifests/apps.nvidia.com_nimcaches.yaml @@ -21,10 +21,6 @@ spec: - jsonPath: .status.pvc name: PVC type: string - - jsonPath: .status.profiles - name: Profiles - priority: 1 - type: string - jsonPath: .metadata.creationTimestamp name: Age type: string diff --git a/config/crd/bases/apps.nvidia.com_nimcaches.yaml b/config/crd/bases/apps.nvidia.com_nimcaches.yaml index 08cf8e68..ff645d0f 100644 --- a/config/crd/bases/apps.nvidia.com_nimcaches.yaml +++ b/config/crd/bases/apps.nvidia.com_nimcaches.yaml @@ -21,10 +21,6 @@ spec: - jsonPath: .status.pvc name: PVC type: string - - jsonPath: .status.profiles - name: Profiles - priority: 1 - type: string - jsonPath: .metadata.creationTimestamp name: Age type: string diff --git a/deployments/helm/k8s-nim-operator/crds/apps.nvidia.com_nimcaches.yaml b/deployments/helm/k8s-nim-operator/crds/apps.nvidia.com_nimcaches.yaml index e8e2e9b5..ff645d0f 100644 --- a/deployments/helm/k8s-nim-operator/crds/apps.nvidia.com_nimcaches.yaml +++ b/deployments/helm/k8s-nim-operator/crds/apps.nvidia.com_nimcaches.yaml @@ -21,10 +21,6 @@ spec: - jsonPath: .status.pvc name: PVC type: string - - jsonPath: .status.profiles - name: Profiles - priority: 1 - type: string - jsonPath: .metadata.creationTimestamp name: Age type: string @@ -266,7 +262,6 @@ spec: type: object type: array required: - - resources - source - storage type: object From dab854550fe3aee111f72fba9c711c00713c29a1 Mon Sep 17 00:00:00 2001 From: "Shiva Krishna, Merla" Date: Thu, 8 Aug 2024 07:40:15 -0700 Subject: [PATCH 2/3] Generate manifests before sync Signed-off-by: Shiva Krishna, Merla --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 287a4c96..b1d39cd5 100644 --- a/Makefile +++ b/Makefile @@ -196,7 +196,7 @@ install-tools: grep '^\s*_' tools/tools.go | awk '{print $$2}' | xargs -tI % $(GO_CMD) install -mod=readonly -modfile=tools/go.mod % .PHONY: sync-crds -sync-crds: +sync-crds: manifests @echo Syncing CRDs into Helm and OLM packages cp $(PROJECT_DIR)/config/crd/bases/* deployments/helm/k8s-nim-operator/crds cp $(PROJECT_DIR)/config/crd/bases/* bundle/manifests From b341f03edcb84c85e756b67753c8f9bf67c407a5 Mon Sep 17 00:00:00 2001 From: "Shiva Krishna, Merla" Date: Thu, 8 Aug 2024 07:41:17 -0700 Subject: [PATCH 3/3] Add to validation target Add validation step in the CI pipeline for generated assets Signed-off-by: Shiva Krishna, Merla --- .github/workflows/golang.yml | 2 ++ Makefile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/golang.yml b/.github/workflows/golang.yml index 940ec0de..426bacb1 100644 --- a/.github/workflows/golang.yml +++ b/.github/workflows/golang.yml @@ -50,6 +50,8 @@ jobs: skip-cache: true - name: Check golang modules run: make check-vendor + - name: Check generated assets + run: make validate-generated-assets test: name: Unit test runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index b1d39cd5..aef146d2 100644 --- a/Makefile +++ b/Makefile @@ -96,7 +96,7 @@ generate-clientset: install-tools --input-base $(CURDIR)/api \ --input "apps/v1alpha1" -validate-generated-assets: manifests generate generate-clientset +validate-generated-assets: manifests generate generate-clientset sync-crds @echo "- Verifying that the generated code and manifests are in-sync..." @git diff --exit-code -- api config