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
4 changes: 0 additions & 4 deletions api/v1alpha1/clusterpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,3 @@ type ClusterPolicyList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []ClusterPolicy `json:"items"`
}

func init() {
SchemeBuilder.Register(&ClusterPolicy{}, &ClusterPolicyList{})
}
31 changes: 7 additions & 24 deletions api/v1alpha1/clusterpolicy_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ import (
"regexp"
"strings"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

"github.com/distribution/reference"
Expand All @@ -43,7 +41,7 @@ const (

// SetupClusterPolicyWebhookWithManager registers the webhook for ClusterPolicy in the manager.
func SetupClusterPolicyWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).For(&ClusterPolicy{}).
return ctrl.NewWebhookManagedBy(mgr, &ClusterPolicy{}).
WithDefaulter(&ClusterPolicyCustomDefaulter{}).
WithValidator(&ClusterPolicyCustomValidator{}).
Complete()
Expand All @@ -54,16 +52,11 @@ func SetupClusterPolicyWebhookWithManager(mgr ctrl.Manager) error {
// ClusterPolicyCustomDefaulter sets default image values on ClusterPolicy resources.
type ClusterPolicyCustomDefaulter struct{}

var _ webhook.CustomDefaulter = &ClusterPolicyCustomDefaulter{}
var _ admission.Defaulter[*ClusterPolicy] = &ClusterPolicyCustomDefaulter{}

// Default implements webhook.CustomDefaulter. It fills in missing image references
// with the pinned known-good images shipped with this version of the operator.
func (d *ClusterPolicyCustomDefaulter) Default(_ context.Context, obj runtime.Object) error {
cp, ok := obj.(*ClusterPolicy)
if !ok {
return fmt.Errorf("expected a ClusterPolicy object")
}

func (d *ClusterPolicyCustomDefaulter) Default(_ context.Context, cp *ClusterPolicy) error {
spec := &cp.Spec

if spec.DevicePluginSpec.PluginImage == "" {
Expand All @@ -90,7 +83,7 @@ func (d *ClusterPolicyCustomDefaulter) Default(_ context.Context, obj runtime.Ob
// ClusterPolicyCustomValidator validates ClusterPolicy resources on create and update.
type ClusterPolicyCustomValidator struct{}

var _ webhook.CustomValidator = &ClusterPolicyCustomValidator{}
var _ admission.Validator[*ClusterPolicy] = &ClusterPolicyCustomValidator{}

var pciIDRegexp = regexp.MustCompile(`^0x[0-9a-f]{4}$`)

Expand Down Expand Up @@ -244,26 +237,16 @@ func warnHealthSpec(spec *ClusterPolicySpec) string {
}

// ValidateCreate implements webhook.CustomValidator.
func (v *ClusterPolicyCustomValidator) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
cp, ok := obj.(*ClusterPolicy)
if !ok {
return nil, fmt.Errorf("expected a ClusterPolicy object")
}

func (v *ClusterPolicyCustomValidator) ValidateCreate(_ context.Context, cp *ClusterPolicy) (admission.Warnings, error) {
return validateClusterPolicySpec(&cp.Spec)
}

// ValidateUpdate implements webhook.CustomValidator.
func (v *ClusterPolicyCustomValidator) ValidateUpdate(_ context.Context, _, newObj runtime.Object) (admission.Warnings, error) {
cp, ok := newObj.(*ClusterPolicy)
if !ok {
return nil, fmt.Errorf("expected a ClusterPolicy object")
}

func (v *ClusterPolicyCustomValidator) ValidateUpdate(_ context.Context, _ *ClusterPolicy, cp *ClusterPolicy) (admission.Warnings, error) {
return validateClusterPolicySpec(&cp.Spec)
}

// ValidateDelete implements webhook.CustomValidator.
func (v *ClusterPolicyCustomValidator) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
func (v *ClusterPolicyCustomValidator) ValidateDelete(_ context.Context, _ *ClusterPolicy) (admission.Warnings, error) {
return nil, nil
}
4 changes: 0 additions & 4 deletions api/v1alpha1/gpufirmwareupdate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,3 @@ type GPUFirmwareUpdateSubsetStatus struct {
Error []string `json:"errorNodes,omitempty"`
Jobs []string `json:"jobs,omitempty"`
}

func init() {
SchemeBuilder.Register(&GPUFirmwareUpdate{}, &GPUFirmwareUpdateList{})
}
27 changes: 5 additions & 22 deletions api/v1alpha1/gpufirmwareupdate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ import (
"regexp"
"strings"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

"github.com/distribution/reference"
)

// SetupGPUFirmwareUpdateWebhookWithManager registers the webhook for GPUFirmwareUpdate in the manager.
func SetupGPUFirmwareUpdateWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).For(&GPUFirmwareUpdate{}).
return ctrl.NewWebhookManagedBy(mgr, &GPUFirmwareUpdate{}).
WithValidator(&GPUFirmwareUpdateCustomValidator{}).
Complete()
}
Expand All @@ -59,7 +57,7 @@ var inProgressStates = map[string]bool{
"error_cleanup": true,
}

var _ webhook.CustomValidator = &GPUFirmwareUpdateCustomValidator{}
var _ admission.Validator[*GPUFirmwareUpdate] = &GPUFirmwareUpdateCustomValidator{}

func validateInputs(spec *GPUFirmwareUpdateSpec) error {
fileNameReg := regexp.MustCompile(`^[a-zA-Z0-9._-]+$`)
Expand Down Expand Up @@ -125,27 +123,12 @@ func validateInputs(spec *GPUFirmwareUpdateSpec) error {
}

// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type GPUFirmwareUpdate.
func (v *GPUFirmwareUpdateCustomValidator) ValidateCreate(newObj context.Context, obj runtime.Object) (admission.Warnings, error) {
newFU, ok := obj.(*GPUFirmwareUpdate)
if !ok {
return nil, fmt.Errorf("expected a GPUFirmwareUpdate object")
}

func (v *GPUFirmwareUpdateCustomValidator) ValidateCreate(newObj context.Context, newFU *GPUFirmwareUpdate) (admission.Warnings, error) {
return nil, validateInputs(&newFU.Spec)
}

// ValidateUpdate rejects changes to fields that are immutable once an update is in progress.
func (v *GPUFirmwareUpdateCustomValidator) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
oldFU, ok := oldObj.(*GPUFirmwareUpdate)
if !ok {
return nil, fmt.Errorf("expected a GPUFirmwareUpdate object for old object")
}

newFU, ok := newObj.(*GPUFirmwareUpdate)
if !ok {
return nil, fmt.Errorf("expected a GPUFirmwareUpdate object for new object")
}

func (v *GPUFirmwareUpdateCustomValidator) ValidateUpdate(_ context.Context, oldFU, newFU *GPUFirmwareUpdate) (admission.Warnings, error) {
if !inProgressStates[oldFU.Status.State] {
return nil, nil
}
Expand Down Expand Up @@ -176,6 +159,6 @@ func (v *GPUFirmwareUpdateCustomValidator) ValidateUpdate(_ context.Context, old
}

// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type GPUFirmwareUpdate.
func (v *GPUFirmwareUpdateCustomValidator) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
func (v *GPUFirmwareUpdateCustomValidator) ValidateDelete(ctx context.Context, obj *GPUFirmwareUpdate) (admission.Warnings, error) {
return nil, nil
}
17 changes: 15 additions & 2 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,30 @@ limitations under the License.
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "intel.com", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

func addKnownTypes(s *runtime.Scheme) error {
s.AddKnownTypes(GroupVersion,
&ClusterPolicy{},
&ClusterPolicyList{},
&GPUFirmwareUpdate{},
&GPUFirmwareUpdateList{},
)
metav1.AddToGroupVersion(s, GroupVersion)

return nil
}
4 changes: 2 additions & 2 deletions build/operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ARG BASE_IMAGE=gcr.io/distroless/static:nonroot

# Build the manager binary
FROM golang:1.25 AS builder
FROM golang:1.26 AS builder
ARG TARGETOS
ARG TARGETARCH
ARG GITINFO
Expand All @@ -13,7 +13,7 @@ ARG PKGNAME
ENV GO111MODULE=on
ENV CGOFLAGS="-trimpath"
ENV GCFLAGS="all=-spectre=all"
ENV ASMFLAGS="all=-spectre=all"
ENV ASMFLAGS="-spectre=all"
ENV LDFLAGS="all=-w -s -X ${PKGNAME}/internal/version.gitInfo=${GITINFO} -X ${PKGNAME}/internal/version.buildDate=${BUILDDATE}"

WORKDIR /workspace
Expand Down
3 changes: 2 additions & 1 deletion charts/gpu-base-operator/crds/clusterpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,10 @@ spec:
operator:
description: |-
Operator represents a key's relationship to the value.
Valid operators are Exists and Equal. Defaults to Equal.
Valid operators are Exists, Equal, Lt, and Gt. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod can
tolerate all taints of a particular category.
Lt and Gt perform numeric comparisons (requires feature gate TaintTolerationComparisonOperators).
type: string
tolerationSeconds:
description: |-
Expand Down
3 changes: 2 additions & 1 deletion charts/gpu-base-operator/crds/gpufirmwareupdates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ spec:
operator:
description: |-
Operator represents a key's relationship to the value.
Valid operators are Exists and Equal. Defaults to Equal.
Valid operators are Exists, Equal, Lt, and Gt. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod can
tolerate all taints of a particular category.
Lt and Gt perform numeric comparisons (requires feature gate TaintTolerationComparisonOperators).
type: string
tolerationSeconds:
description: |-
Expand Down
3 changes: 2 additions & 1 deletion config/crd/bases/intel.com_clusterpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,10 @@ spec:
operator:
description: |-
Operator represents a key's relationship to the value.
Valid operators are Exists and Equal. Defaults to Equal.
Valid operators are Exists, Equal, Lt, and Gt. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod can
tolerate all taints of a particular category.
Lt and Gt perform numeric comparisons (requires feature gate TaintTolerationComparisonOperators).
type: string
tolerationSeconds:
description: |-
Expand Down
3 changes: 2 additions & 1 deletion config/crd/bases/intel.com_gpufirmwareupdates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ spec:
operator:
description: |-
Operator represents a key's relationship to the value.
Valid operators are Exists and Equal. Defaults to Equal.
Valid operators are Exists, Equal, Lt, and Gt. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod can
tolerate all taints of a particular category.
Lt and Gt perform numeric comparisons (requires feature gate TaintTolerationComparisonOperators).
type: string
tolerationSeconds:
description: |-
Expand Down
51 changes: 25 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/intel/gpu-base-operator

go 1.25.0
go 1.26.0

require (
github.com/distribution/reference v0.6.0
Expand All @@ -9,13 +9,13 @@ require (
github.com/onsi/ginkgo/v2 v2.29.0
github.com/onsi/gomega v1.40.0
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.85.0
k8s.io/api v0.34.2
k8s.io/apiextensions-apiserver v0.34.2
k8s.io/apimachinery v0.34.2
k8s.io/client-go v0.34.2
k8s.io/klog/v2 v2.130.1
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4
sigs.k8s.io/controller-runtime v0.22.4
k8s.io/api v0.36.0
k8s.io/apiextensions-apiserver v0.36.0
k8s.io/apimachinery v0.36.0
k8s.io/client-go v0.36.0
k8s.io/klog/v2 v2.140.0
k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2
sigs.k8s.io/controller-runtime v0.24.1
sigs.k8s.io/kueue v0.15.2
sigs.k8s.io/node-feature-discovery/api/nfd v0.17.3
sigs.k8s.io/yaml v1.6.0
Expand Down Expand Up @@ -56,13 +56,11 @@ require (
github.com/go-openapi/swag/typeutils v0.25.4 // indirect
github.com/go-openapi/swag/yamlutils v0.25.4 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/cel-go v0.26.0 // indirect
github.com/google/gnostic-models v0.7.1 // indirect
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.7 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.18.5 // indirect
Expand All @@ -75,28 +73,28 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.17.0 // indirect
github.com/prometheus/common v0.67.5 // indirect
github.com/prometheus/procfs v0.19.2 // indirect
github.com/sirupsen/logrus v1.9.4 // indirect
github.com/spf13/cobra v1.10.2 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/stoewer/go-strcase v1.3.1 // indirect
github.com/vbatts/tar-split v0.12.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.65.0 // indirect
go.opentelemetry.io/otel v1.43.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.37.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.40.0 // indirect
go.opentelemetry.io/otel/metric v1.43.0 // indirect
go.opentelemetry.io/otel/sdk v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.43.0 // indirect
go.opentelemetry.io/proto/otlp v1.7.0 // indirect
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.1 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/exp v0.0.0-20250718183923-645b1fa84792 // indirect
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 // indirect
golang.org/x/mod v0.35.0 // indirect
golang.org/x/net v0.53.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
Expand All @@ -107,18 +105,19 @@ require (
golang.org/x/time v0.14.0 // indirect
golang.org/x/tools v0.44.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect
google.golang.org/grpc v1.79.3 // indirect
google.golang.org/protobuf v1.36.10 // indirect
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gotest.tools/v3 v3.5.2 // indirect
k8s.io/apiserver v0.34.2 // indirect
k8s.io/component-base v0.34.2 // indirect
k8s.io/kube-openapi v0.0.0-20251125145642-4e65d59e963e // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.33.0 // indirect
k8s.io/apiserver v0.36.0 // indirect
k8s.io/component-base v0.36.0 // indirect
k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a // indirect
k8s.io/streaming v0.36.0 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.1 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.2 // indirect
)
Loading