mirror of
https://github.com/dsx-ai-factory/nvke.git
synced 2026-12-07 04:35:58 +08:00
* refactor(controller): render the release CRDs from the controller chart The NVKE controller and management-engine no longer share CRDs, so the nvke-crds subchart only added a helm dependency build step. Render the three release CRDs from the controller chart's own files/crds and remove the subchart, its Chart.lock and the build plumbing around it. Signed-off-by: Miancheng Lin <mianchengl@nvidia.com> * fix(controller): address review of the chart-owned release CRDs Embed the controller chart file by file, so a stale charts/nvke-crds-*.tgz in an existing checkout is not embedded and rendered a second time. Point the generated-CRD check at the generator's fixed output path instead of the overridable CHART. Keep the .gitignore entries for built chart dependencies and dist/, which existing checkouts and the CLI build still use. Signed-off-by: Miancheng Lin <mianchengl@nvidia.com> --------- Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>
326 lines
16 KiB
Makefile
326 lines
16 KiB
Makefile
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# Local entry points for merge-gate checks. Tools come from PATH unless a
|
|
# target explicitly installs its pinned tool (credential-alerts-check).
|
|
|
|
CHART ?= controller/deploy/charts/controller
|
|
|
|
define require_command
|
|
command -v $(1) >/dev/null 2>&1 || { \
|
|
echo "ERROR: $(1) is missing."; \
|
|
echo "Use 'flox activate', or install $(1) with your OS package manager."; \
|
|
exit 1; }
|
|
endef
|
|
|
|
define require_tool
|
|
./hack/check-tool-version.sh "$(1)" "$(2)"
|
|
endef
|
|
|
|
##@ Checks
|
|
|
|
# The repository guard compares the id, never the slug. A renamed or
|
|
# transferred repository keeps its id, while a slug guard that has gone false
|
|
# skips every job without a failure. See .github/workflows/README.md,
|
|
# "Repository guards". `github.repository_id` and `github.repository_owner`
|
|
# do not match the pattern, and neither does `x == github.repository`.
|
|
lint-workflows: ## Lint the GitHub Actions workflows. (run by the merge gate)
|
|
@$(call require_tool,actionlint,$(ACTIONLINT_VERSION))
|
|
@actionlint -color
|
|
@if git grep -n -E 'github\.repository[[:space:]]*[!=]=' -- .github >/dev/null; then \
|
|
echo "ERROR: a workflow compares github.repository to a string. Guard on github.repository_id instead:"; \
|
|
git grep -n -E 'github\.repository[[:space:]]*[!=]=' -- .github; \
|
|
exit 1; \
|
|
fi
|
|
@$(call require_command,python3)
|
|
@$(call require_command,yq)
|
|
@python3 -B ./hack/test_e2e_path_filter.py
|
|
@python3 -B ./hack/e2e-path-filter.py check
|
|
@echo " workflows: no findings"
|
|
|
|
# --severity=error matches shellcheck.yml. The tree is clean at error and is not
|
|
# clean at warning, so raising it here would fail on a backlog the gate does not
|
|
# block on. xargs -0, never mapfile: see hack/shell-scripts.sh.
|
|
lint-shell: ## Lint every tracked shell script. (run by the merge gate)
|
|
@$(call require_tool,shellcheck,$(SHELLCHECK_VERSION))
|
|
@n=$$(./hack/shell-scripts.sh | tr -dc '\0' | wc -c | tr -d ' '); \
|
|
echo " checking $$n shell scripts at severity=error"; \
|
|
./hack/shell-scripts.sh | xargs -0 shellcheck --severity=error --format=tty
|
|
@echo " shell scripts: no error-level findings"
|
|
|
|
# Facts that live in the tree and were restated in prose: the module count, the
|
|
# binary names, the merge-gate member count, and every relative link. Each is
|
|
# read back from go.work, the Makefile and merge-gate.yml rather than from a
|
|
# second copy. Needs nothing beyond bash, git, awk and grep, so there is no
|
|
# version to pin and no require_tool line.
|
|
docs-check: ## Check the documented facts against the repository. (run by the merge gate)
|
|
@./hack/docs-check.sh
|
|
|
|
# Identifiers of infrastructure only NVIDIA can see. Not credentials, which
|
|
# is why they read as safe and are not: this repository is the staging ground
|
|
# for a public one, and an org, site, VPC or subnet id is a map of a real
|
|
# account. Matched by digest so this check does not publish what it forbids.
|
|
internal-config-check: ## Check the tree names no internal infrastructure. (run by the merge gate)
|
|
@python3 -B ./hack/test_internal_config_check.py
|
|
@./hack/internal-config-check.sh
|
|
|
|
# A banned name, found as tokens rather than lines so that an English word or
|
|
# a camel-case identifier does not hide the real token beside it. Fail mode
|
|
# lists every hit outside hack/name-check-allowlist.txt and exits 1. Report
|
|
# mode summarises and exits 0; the gate ran that way until 2026-10-11, while
|
|
# the tree still carried the name. A dead allowlist entry fails in either mode.
|
|
# hack/removed-settings-check.py fails on the controller setting names that
|
|
# #1399 removed, so that no reader of an old name comes back.
|
|
NAME_CHECK_MODE ?= fail
|
|
name-check: ## Fail on tokens that carry a banned name outside the allowlist, or a removed controller setting name, and run the offline hack/rotation-demo tests. (run by the merge gate)
|
|
@$(call require_command,python3)
|
|
@python3 -B ./hack/test_name_check.py
|
|
@python3 -B ./hack/test_removed_settings_check.py
|
|
@$(MAKE) --no-print-directory -C hack/rotation-demo test
|
|
@python3 -B ./hack/name-check.py --mode $(NAME_CHECK_MODE)
|
|
@python3 -B ./hack/removed-settings-check.py
|
|
|
|
# The version every nightly beta and release candidate is tagged with, and the
|
|
# version every publisher pushes under. A wrong answer is pushed as a tag or an
|
|
# artifact rather than reported, so both are tested against fixture repositories.
|
|
next-tag-test: ## Test the release version rules in release/hack/next-tag.sh and describe-version.sh. (run by the merge gate)
|
|
@$(call require_command,python3)
|
|
@python3 -B ./release/hack/test_next_tag.py
|
|
@python3 -B ./release/hack/test_describe_version.py
|
|
|
|
# The generator writes here whatever CHART is set to, so the path is not derived
|
|
# from the overridable CHART.
|
|
RELEASE_CRD_DIR := controller/deploy/charts/controller/files/crds
|
|
|
|
.PHONY: chart-crds-check chart-crds-render-check
|
|
chart-crds-check: ## Verify each component's committed CRDs against its own generator.
|
|
@# The NVKE controller (controller/k8s-apis) and management-engine each generate
|
|
@# and install their own CRDs, and the two sets may differ, so each generator
|
|
@# is checked against its own committed files.
|
|
@$(MAKE) --no-print-directory -C controller/k8s-apis generate manifests
|
|
@$(MAKE) --no-print-directory -C management-engine manifests-state
|
|
git diff --exit-code -- $(RELEASE_CRD_DIR) controller/k8s-apis/v1/zz_generated.deepcopy.go management-engine/config/crd/bases management-engine/apis/v1/zz_generated.deepcopy.go
|
|
@test -z "$$(git ls-files --others --exclude-standard -- $(RELEASE_CRD_DIR) management-engine/config/crd/bases)" || { echo "Commit generated schemas"; exit 1; }
|
|
@$(call require_tool,kubectl,$(KUBECTL_VERSION))
|
|
kubectl kustomize management-engine/config/crd > /dev/null
|
|
|
|
chart-crds-render-check: ## Verify the controller chart renders the generated CRDs.
|
|
@$(call require_tool,helm,$(HELM_VERSION))
|
|
$(MAKE) --no-print-directory -C controller/k8s-apis test-chart-crds
|
|
|
|
# helm lint and helm template both pass on a manifest Kubernetes would reject, so
|
|
# kubeconform parses what was rendered. A chart that renders nothing also passes
|
|
# helm template silently, hence the count.
|
|
lint-chart: ## Lint and render the Helm chart, then validate it. (run by the merge gate)
|
|
@$(call require_tool,helm,$(HELM_VERSION))
|
|
@$(call require_tool,kubeconform,$(KUBECONFORM_VERSION))
|
|
@helm lint $(CHART)
|
|
@# A directory, not `mktemp -t`: kubeconform selects files by extension, and
|
|
@# macOS mktemp appends random characters after the template, so a file named
|
|
@# nvke-chart-XXXXXX.qlKjrjG4RL is skipped and the summary reads
|
|
@# "0 resource found in 0 file" while the target reports success.
|
|
@set -eu; \
|
|
dir=$$(mktemp -d); \
|
|
trap 'rm -rf "$$dir"' EXIT HUP INT TERM; \
|
|
out="$$dir/rendered.yaml"; \
|
|
helm template cwe $(CHART) > "$$out"; \
|
|
count=$$(grep -c '^kind:' "$$out" || true); \
|
|
if [ "$$count" -eq 0 ]; then \
|
|
echo "ERROR: the chart rendered no resources."; exit 1; \
|
|
fi; \
|
|
echo " rendered $$count resources"; \
|
|
kubeconform -strict -summary -ignore-missing-schemas \
|
|
-schema-location default \
|
|
-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
|
|
"$$out"
|
|
@./controller/hack/chart-auth-assertions.sh
|
|
@./controller/hack/chart-node-agent-auth-assertions.sh
|
|
@./controller/hack/chart-node-agent-external-mtls-assertions.sh
|
|
@./controller/hack/chart-provider-assertions.sh
|
|
@./controller/hack/chart-spire-attestation-assertions.sh
|
|
|
|
chart-rbac-check: ## Assert that tenant RBAC grants every permission the controller uses.
|
|
@$(call require_tool,helm,$(HELM_VERSION))
|
|
@$(call require_command,python3)
|
|
@python3 -c 'import yaml' >/dev/null 2>&1 || { \
|
|
echo "ERROR: Python module PyYAML is required for chart RBAC assertions."; \
|
|
echo " install: python3 -m pip install PyYAML"; \
|
|
exit 1; \
|
|
}
|
|
@python3 ./controller/hack/chart-rbac-assertions.py --chart "$(CHART)"
|
|
|
|
chart-package-check: ## Assert that chart packaging replaces placeholder versions.
|
|
@$(call require_tool,helm,$(HELM_VERSION))
|
|
@CHART="$(CHART)" ./controller/hack/chart-package-assertions.sh
|
|
|
|
# The chart package is named nvke-controller while everything it renders stays
|
|
# cloud-workflow-engine, held there by nameOverride. helm lint and kubeconform
|
|
# both pass if that pin is dropped, so this is the only check that would catch it.
|
|
chart-identity-check: ## Assert the chart still renders the deployed identities it must preserve.
|
|
@$(call require_tool,helm,$(HELM_VERSION))
|
|
@$(call require_command,python3)
|
|
@python3 -c 'import yaml' >/dev/null 2>&1 || { \
|
|
echo "ERROR: Python module PyYAML is required for chart identity assertions."; \
|
|
echo " install: python3 -m pip install PyYAML"; \
|
|
exit 1; \
|
|
}
|
|
@python3 ./controller/hack/chart-identity-assertions.py --chart "$(CHART)"
|
|
|
|
# helm lint and kubeconform cannot tell whether nvke-controller-config agrees
|
|
# with the controller's environment variables; this checks each key against them.
|
|
chart-controller-config-check: ## Assert nvke-controller-config loads and matches the controller's environment.
|
|
@$(call require_tool,helm,$(HELM_VERSION))
|
|
@$(call require_command,go)
|
|
@$(call require_command,yq)
|
|
@CHART="$(CHART)" ./controller/hack/chart-controller-config-assertions.sh
|
|
|
|
.PHONY: credential-alerts-check
|
|
credential-alerts-check: ## Validate credential alert rules, fixtures and the enabled PrometheusRule render.
|
|
@$(call require_tool,helm,$(HELM_VERSION))
|
|
@$(call require_tool,kubeconform,$(KUBECONFORM_VERSION))
|
|
@CHART="$(CHART)" ./controller/hack/chart-credential-alerts-assertions.sh
|
|
|
|
chart-check: chart-crds-render-check lint-chart chart-rbac-check chart-package-check chart-identity-check chart-controller-config-check credential-alerts-check ## Run every chart check enforced by CI.
|
|
|
|
# Use the same tool, Go version, waiver, and stale-waiver guard as
|
|
# CI. The helper returns 3 for an unwaived finding and preserves tool failures.
|
|
vulncheck: ## Report vulnerabilities reachable from each module. (run by the merge gate)
|
|
@$(call require_tool,govulncheck,$(GOVULNCHECK_VERSION))
|
|
@echo "- govulncheck under Go $(GOVULNCHECK_GO_VERSION), the version CI uses"
|
|
@# Download the toolchain first, or a machine that does not already
|
|
@# have it fails inside the scan with an error naming neither GOPROXY nor
|
|
@# this pin. CI is unaffected: setup-go leaves the toolchain in place.
|
|
@GOTOOLCHAIN=go$(GOVULNCHECK_GO_VERSION) go version >/dev/null 2>&1 || { \
|
|
echo "ERROR: could not obtain Go $(GOVULNCHECK_GO_VERSION), which this check pins to match CI." >&2; \
|
|
echo " It downloads once through the module proxy, so this step needs network access." >&2; \
|
|
exit 1; \
|
|
}
|
|
@fail=0; \
|
|
for m in $(WORK_MODULES); do \
|
|
echo "- $$m"; \
|
|
GOTOOLCHAIN=go$(GOVULNCHECK_GO_VERSION) \
|
|
GOVULNCHECK_WAIVED="$(GOVULNCHECK_WAIVED)" \
|
|
GOVULNCHECK_WAIVER_OWNER="$(GOVULNCHECK_WAIVER_OWNER)" \
|
|
GOVULNCHECK_WAIVER_REVIEW="$(GOVULNCHECK_WAIVER_REVIEW)" \
|
|
./hack/govulncheck-gate.sh "$$m"; \
|
|
rc=$$?; \
|
|
[ $$rc -eq 0 ] || fail=1; \
|
|
done; \
|
|
[ $$fail -eq 0 ] || exit 1
|
|
@echo " govulncheck gate passed"
|
|
|
|
# tools-check asks what is installed. This asks whether the repository still
|
|
# agrees with itself about what should be installed -- so it needs none of the
|
|
# tools present and runs anywhere.
|
|
.PHONY: tool-version-check
|
|
tool-version-check: ## Verify every tool pin is declared once, in make/tool-versions.mk.
|
|
@./hack/tool-version-check.sh
|
|
|
|
tools-check: ## Check the versions of tools used by local merge-gate targets.
|
|
@fail=0; \
|
|
./hack/check-tool-version.sh actionlint "$(ACTIONLINT_VERSION)" || fail=1; \
|
|
./hack/check-tool-version.sh shellcheck "$(SHELLCHECK_VERSION)" || fail=1; \
|
|
./hack/check-tool-version.sh helm "$(HELM_VERSION)" || fail=1; \
|
|
./hack/check-tool-version.sh kubeconform "$(KUBECONFORM_VERSION)" || fail=1; \
|
|
./hack/check-tool-version.sh govulncheck "$(GOVULNCHECK_VERSION)" || fail=1; \
|
|
[ $$fail -eq 0 ]
|
|
|
|
##@ Everything
|
|
|
|
# Every module already has fmt and lint. There was no way to run them across the
|
|
# repository: `make lint` at the root failed with "No rule to make target". CI
|
|
# still calls the module targets directly, so its seven lint jobs stay parallel.
|
|
fmt: ## Format every module.
|
|
@for m in $(FORMAT_MODULES); do \
|
|
echo "- fmt $$m"; \
|
|
$(MAKE) --no-print-directory -C $$m fmt || exit 1; \
|
|
done
|
|
|
|
lint: ## Lint every module. (run by the merge gate)
|
|
@for m in $(LINT_MODULES); do \
|
|
echo "- lint $$m"; \
|
|
$(MAKE) --no-print-directory -C $$m lint || exit 1; \
|
|
done
|
|
|
|
# One merge-gate job needs live services, and is listed below alongside the
|
|
# advisory lanes that are not part of the gate at all.
|
|
# WORK_MODULES and PRIVATE_MODULES are passed in rather than repeated in the
|
|
# script: they are already the list the workspace and the sync are built from,
|
|
# and a second copy is the drift this check exists to catch.
|
|
.PHONY: go-version-check
|
|
go-version-check: ## Verify every hand-kept Go version matches go.work.
|
|
@./hack/go-version-check.sh --modules "$(WORK_MODULES)" --private "$(PRIVATE_MODULES)"
|
|
|
|
# A tag is mutable, so an image built from one is not reproducible and not the
|
|
# thing that was scanned. The script also carries the list of development-only
|
|
# Dockerfiles that are deliberately exempt, so that stays a recorded decision
|
|
# rather than an unexplained gap.
|
|
.PHONY: base-image-check
|
|
base-image-check: ## Verify release-relevant Dockerfiles pin base images by digest.
|
|
@./hack/base-image-check.sh
|
|
|
|
# The other half of the same policy. base-image-check keeps the digests
|
|
# immutable; this follows the tags they were taken from, because Dependabot
|
|
# cannot see an ARG-named base and a pin nothing bumps goes stale instead.
|
|
# Deliberately NOT in `gate`: a republished upstream base is news, not a
|
|
# reason to fail somebody's pull request. base-image-digests.yml runs it
|
|
# weekly and opens a pull request with whatever moved.
|
|
# Pass --check to the script directly to report without writing.
|
|
.PHONY: base-image-update
|
|
base-image-update: ## Re-resolve ARG-pinned base image digests in place (needs crane).
|
|
@./hack/base-image-update.sh
|
|
|
|
# Not read-only. A Go bump moves go.work and then eleven `go` directives, and a
|
|
# fix you have to apply by hand eleven times is a fix that gets applied ten
|
|
# times.
|
|
.PHONY: go-version-sync
|
|
go-version-sync: ## Rewrite every go.mod `go` directive to match go.work.
|
|
@./hack/go-version-check.sh --fix --modules "$(WORK_MODULES)" --private "$(PRIVATE_MODULES)"
|
|
|
|
# The scan that reads .grype.yaml needs a vulnerability database and a network.
|
|
# This reads the file only, so the three rules its preamble states are checked
|
|
# on a laptop and in the merge gate, not just in the weekly scan -- including
|
|
# the review date, which is the one that goes off while nobody is looking.
|
|
.PHONY: grype-ignore-check
|
|
grype-ignore-check: ## Verify every .grype.yaml exception is scoped, owned and in date.
|
|
@./hack/grype-ignore-check.sh
|
|
|
|
.PHONY: deploy-lists-check
|
|
deploy-lists-check: ## Verify every nvke-deploy.yaml item has its directory.
|
|
@./hack/deploy-lists-check.sh
|
|
|
|
gate: ## Run the merge-gate checks that work on a laptop.
|
|
@$(MAKE) --no-print-directory tool-version-check
|
|
@$(MAKE) --no-print-directory tools-check
|
|
@$(MAKE) --no-print-directory version-check
|
|
@$(MAKE) --no-print-directory go-version-check
|
|
@$(MAKE) --no-print-directory base-image-check
|
|
@$(MAKE) --no-print-directory grype-ignore-check
|
|
@$(MAKE) --no-print-directory deploy-lists-check
|
|
@CGO_ENABLED=1 $(MAKE) --no-print-directory GO_TEST_FLAGS=-race test
|
|
@$(MAKE) --no-print-directory test-compile
|
|
@$(MAKE) --no-print-directory lint
|
|
@$(MAKE) --no-print-directory work-check
|
|
@$(MAKE) --no-print-directory license-deps-check
|
|
@$(MAKE) --no-print-directory licenses-check
|
|
@$(MAKE) --no-print-directory license-header-check
|
|
@$(MAKE) --no-print-directory lint-workflows
|
|
@$(MAKE) --no-print-directory lint-shell
|
|
@$(MAKE) --no-print-directory docs-check
|
|
@$(MAKE) --no-print-directory internal-config-check
|
|
@$(MAKE) --no-print-directory name-check
|
|
@$(MAKE) --no-print-directory -C deploy test
|
|
@$(MAKE) --no-print-directory chart-check
|
|
@$(MAKE) --no-print-directory -C controller generate-check
|
|
@$(MAKE) --no-print-directory -C cli provider-manifest-check
|
|
@$(MAKE) --no-print-directory -C cli docs-check
|
|
@$(MAKE) --no-print-directory chart-crds-check
|
|
@$(MAKE) --no-print-directory vulncheck
|
|
@echo
|
|
@echo "Merge-gate jobs not run locally:"
|
|
@echo " gofail e2e make -C controller e2e-gofail PostgreSQL, envtest and Temporal"
|
|
@echo "Workspace re-derivation needs access to the internal provider; work-check reports if it skips."
|
|
@echo "CAPD backend e2e is advisory, not part of the merge gate: make test-e2e-backend-ci"
|
|
@echo "nvkectl bootstrap e2e is advisory too, not part of the merge gate:"
|
|
@echo " make -C cli test-e2e-bootstrap (nerdctl, buildkitd, kind, and root)"
|