Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ dist/
# IDE & Editor Configurations
# ============================================================================


### JetBrains IDEs (GoLand, PyCharm, IntelliJ) ###
### JetBrains IDEs (GoLand, PyCharm, IntelliJ) ###
# User-specific stuff
Expand Down
1 change: 1 addition & 0 deletions .versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ go_tools:
setup_envtest: 'latest'
goimports: 'v0.30.0'
crane: 'v0.20.2'
controller_gen: 'v0.20.0'

# Protocol Buffers / gRPC
protobuf:
Expand Down
26 changes: 26 additions & 0 deletions data-models/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,36 @@ DOCKER_EXTRA_ARGS :=
include ../make/common.mk
include ../make/go.mk

# API and CRD paths
API_DIR := api/v1alpha1
CRD_OUTPUT_DIR := $(REPO_ROOT)/distros/kubernetes/nvsentinel/crds


# =============================================================================
# MODULE-SPECIFIC TARGETS
# =============================================================================

# generate: Generate deepcopy, CRD types, and other Kubernetes boilerplate
# Depends on tools being installed
.PHONY: generate
generate: ## Generate CRDs and move them to Helm chart directory
@echo "Generating CRDs for $(API_DIR)..."
@# Install controller-gen if not present
@which controller-gen > /dev/null || (echo "Installing controller-gen..." && \
go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION))
@# Generate deepcopy files for API types
go run sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION) object paths=./$(API_DIR)
@# Generate CRDs directly into API_DIR
go run sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION) \
crd paths=./$(API_DIR) output:crd:dir=./$(API_DIR)
@# Move generated CRDs to Helm chart directory
@echo "Moving generated CRDs to $(CRD_OUTPUT_DIR)..."
@mkdir -p $(CRD_OUTPUT_DIR)
@mv ./$(API_DIR)/*.yaml $(CRD_OUTPUT_DIR)/ || true
@echo "CRDs generated and moved to $(CRD_OUTPUT_DIR)"
@ls -1 $(CRD_OUTPUT_DIR)/*.yaml || echo "No CRD YAMLs generated"


# Generate Go protobuf files for data-models (shared across all Go modules)
.PHONY: protos-generate
protos-generate: protos-clean
Expand Down
34 changes: 34 additions & 0 deletions data-models/api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package v1alpha1 contains API Schema definitions for the healthevents v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=healthevents.dgxc.nvidia.com
package v1alpha1

import (
"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: "healthevents.dgxc.nvidia.com", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
107 changes: 107 additions & 0 deletions data-models/api/v1alpha1/healthevent_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +kubebuilder:validation:Enum=NotStarted;InProgress;Failed;Succeeded;AlreadyDrained;UnQuarantined;Quarantined;AlreadyQuarantined;Cancelled
type Status string

const (
StatusNotStarted Status = "NotStarted"
StatusInProgress Status = "InProgress"
StatusFailed Status = "Failed"
StatusSucceeded Status = "Succeeded"
StatusAlreadyDrained Status = "AlreadyDrained"

StatusUnQuarantined Status = "UnQuarantined"
StatusQuarantined Status = "Quarantined"
StatusAlreadyQuarantined Status = "AlreadyQuarantined"
StatusCancelled Status = "Cancelled"
)

// +kubebuilder:validation:Enum=NONE;COMPONENT_RESET;CONTACT_SUPPORT;RUN_FIELDDIAG;RESTART_VM;RESTART_BM;REPLACE_VM;RUN_DCGMEUD;UNKNOWN
type RecommendedAction string

const (
RecommendedActionNone RecommendedAction = "NONE"
RecommendedActionComponentReset RecommendedAction = "COMPONENT_RESET"
RecommendedActionContactSupport RecommendedAction = "CONTACT_SUPPORT"
RecommendedActionRunFieldDiag RecommendedAction = "RUN_FIELDDIAG"
RecommendedActionRestartVM RecommendedAction = "RESTART_VM"
RecommendedActionRestartBM RecommendedAction = "RESTART_BM"
RecommendedActionReplaceVM RecommendedAction = "REPLACE_VM"
RecommendedActionRunDCGMEUD RecommendedAction = "RUN_DCGMEUD"
RecommendedActionUnknown RecommendedAction = "UNKNOWN"
)

// OperationStatus represents the status of a sub-operation
type OperationStatus struct {
// +kubebuilder:validation:Required
Status Status `json:"status,omitempty"`

Message string `json:"message,omitempty"`
}

//
// =======================
// HealthEvent Status
// =======================
//

// HealthEventStatus defines the observed state of HealthEvent
type HealthEventStatus struct {
// Whether the node has been quarantined
NodeQuarantined *Status `json:"nodeQuarantined,omitempty"`

// Status of user pod eviction
UserPodsEvictionStatus OperationStatus `json:"userPodsEvictionStatus"`

// Whether the fault has been remediated
FaultRemediated *bool `json:"faultRemediated,omitempty"`

// Timestamp of the last remediation attempt
LastRemediationTimestamp *metav1.Time `json:"lastRemediationTimestamp,omitempty"`
}

//
// =======================
// HealthEvent Spec
// =======================
//

// HealthEventSpec defines the desired state of HealthEvent
type HealthEventSpec struct {
// NodeName is the name of the target node
NodeName string `json:"nodeName,omitempty"`

// Recommended remediation action
RecommendedAction RecommendedAction `json:"recommendedAction,omitempty"`

// Whether the fault is fatal
IsFatal *bool `json:"isFatal,omitempty"`

// Whether the system is healthy
IsHealthy *bool `json:"isHealthy,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
type HealthEvent struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec HealthEventSpec `json:"spec,omitempty"`
Status HealthEventStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
type HealthEventList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []HealthEvent `json:"items"`
}

func init() {
SchemeBuilder.Register(&HealthEvent{}, &HealthEventList{})
}
138 changes: 138 additions & 0 deletions data-models/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 26 additions & 4 deletions data-models/go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
module github.com/nvidia/nvsentinel/data-models

go 1.25
go 1.25.0

toolchain go1.25.3

require (
google.golang.org/grpc v1.77.0
google.golang.org/protobuf v1.36.11
k8s.io/apimachinery v0.35.0
sigs.k8s.io/controller-runtime v0.22.4
)

require (
golang.org/x/net v0.47.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/text v0.31.0 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/onsi/gomega v1.38.3 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/text v0.32.0 // indirect
golang.org/x/tools v0.40.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
k8s.io/api v0.35.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // 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.0 // indirect
)

// Local replacements for internal modules
Loading