Skip to content
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
62 changes: 60 additions & 2 deletions deploy/operator/.golangci-kal.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Kubernetes API conventions for the v1beta2 API types, checked by kube-api-linter
# Kubernetes API conventions for the CRD API types, checked by kube-api-linter
# (sigs.k8s.io/kube-api-linter). It runs through the golangci-lint build that the
# kube-api-linter module ships, so `make lint-api` uses this configuration alone.
# The enabled sub-linter set is the union of the conventions this repository
# enforces across every api/ version.

version: "2"

Expand All @@ -21,17 +23,73 @@ linters:
description: kube-api-linter checks Kubernetes API conventions.
settings:
linters:
# nofloats, nomaps, and nophase are deliberately NOT enabled: every
# existing finding would require a breaking CRD change (SLA float
# fields, map-keyed Services/Checkpoints/Components, status Phase
# enums). Revisit with a future API version.
disable:
- "*"
enable:
- conflictingmarkers
- duplicatemarkers
# Every serialized field carries exactly one of +optional or +required.
- optionalorrequired
- statussubresource
- uniquemarkers
- statusoptional
- nonullable
- forbiddenmarkers
lintersConfig:
conflictingmarkers:
conflicts:
- name: default_vs_required
sets:
- ["default", "kubebuilder:default"]
- ["required", "kubebuilder:validation:Required", "k8s:required"]
description: "A field with a default value cannot be required"
forbiddenmarkers:
# Identifiers are matched against marker names as indexed by KAL,
# which strips the leading `+` from `// +marker` comments.
markers:
- identifier: "kubebuilder:pruning:PreserveUnknownFields"
- identifier: "kubebuilder:validation:XPreserveUnknownFields"
- identifier: "kubebuilder:validation:items:XPreserveUnknownFields"
- identifier: "kubebuilder:validation:EmbeddedResource"
- identifier: "kubebuilder:validation:XEmbeddedResource"
- identifier: "kubebuilder:validation:items:XEmbeddedResource"
exclusions:
generated: strict
rules:
# kube-api-linter checks CRD API conventions; only API type packages are in scope.
# Path is matched relative to the golangci-lint run directory (deploy/operator/).
- linters:
- kubeapilinter
path-except: ^api/v1beta2/
path-except: ^api/
# These status fields intentionally keep their long-standing `required`
# CRD invariant (review, #17190): plain counters/enums where absence
# would collapse to the zero value, and consumers may rely on presence —
# including ScalingAdapterStatus.Replicas for the scale subresource.
# The K8s convention that status fields be optional is deliberately not
# applied to them.
- linters:
- kubeapilinter
text: '^statusoptional: status field "(ComponentKind|ComponentName|Replicas|UpdatedReplicas|State|Conditions|ReadyEndpoints|TotalEndpoints)"'
# The `state` fields carry +kubebuilder:default and stay +required to
# preserve the existing CRD contract. Defaulting runs before validation,
# so the default-vs-required combination cannot reject an object.
- linters:
- kubeapilinter
text: "^conflictingmarkers: field \\S+\\.State has conflicting markers: default_vs_required"
# Pre-existing intentional uses of forbiddenmarkers' opaque-schema
# markers: these files embed RawExtension/JSON parameter payloads
# (DGDR parameters, deployment candidates, checkpoint blobs), where
# pruning:PreserveUnknownFields / validation:EmbeddedResource is the
# canonical CRD pattern. The ban guards NEW files; adopting opaque
# fields elsewhere needs an explicit decision, not a silent marker.
- linters:
- kubeapilinter
path: ^api/(v1alpha1/(common|dynamocomponentdeployment_types|dynamographdeploymentrequest_types)|v1beta1/(common|dynamographdeploymentrequest_types)|v1beta2/(dynamographdeploymentcandidate_types|dynamographdeploymentrequest_types|dynamographdeploymentrun_types))\.go$
text: "^forbiddenmarkers:"

issues:
max-issues-per-linter: 0
Expand Down
4 changes: 2 additions & 2 deletions deploy/operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ RUN go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0
# Run linting
RUN golangci-lint run --timeout=5m

# Check the v1beta2 API types against Kubernetes API conventions. Keep the version in sync with
# Check the CRD API types against Kubernetes API conventions. Keep the version in sync with
# KUBE_API_LINTER_VERSION in the Makefile.
RUN go install sigs.k8s.io/kube-api-linter/cmd/golangci-lint-kube-api-linter@v0.0.0-20261012124120-79b557aa8c8d && \
golangci-lint-kube-api-linter run --timeout=5m -c .golangci-kal.yml ./api/v1beta2/...
golangci-lint-kube-api-linter run --timeout=5m -c .golangci-kal.yml ./api/...

# Test stage
FROM base AS tester
Expand Down
4 changes: 2 additions & 2 deletions deploy/operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
$(GOLANGCI_LINT) run --fix

.PHONY: lint-api
lint-api: kube-api-linter ## Check the v1beta2 API types against Kubernetes API conventions
$(KUBE_API_LINTER) run -c .golangci-kal.yml ./api/v1beta2/...
lint-api: kube-api-linter ## Check the CRD API types against Kubernetes API conventions
$(KUBE_API_LINTER) run -c .golangci-kal.yml ./api/...

##@ Build

Expand Down
2 changes: 2 additions & 0 deletions deploy/operator/api/config/v1alpha1/lpx.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ type LPXConfiguration struct {
// requires the scheduling.lpu.nvidia.com/v1alpha1 LpuPipelineRequest API to
// be installed separately.
// +kubebuilder:default=false
// +optional
Enabled bool `json:"enabled"`

// ModelRegistryURL configures the location of the LPU model registry used by LPX.
// Supported values are an absolute local path (or file:// URL) and gs:// URLs.
// +required
ModelRegistryURL string `json:"modelRegistryURL"`
}
Loading
Loading