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
19 changes: 19 additions & 0 deletions api/v1alpha1/nicclusterpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,15 @@ type NicClusterPolicyStatus struct {
Reason string `json:"reason,omitempty"`
// AppliedStates provide a finer view of the observed state
AppliedStates []AppliedState `json:"appliedStates,omitempty"`
// Conditions is a list of conditions describing the state of the NicClusterPolicy.
// Each enabled component exposes a <ComponentName>Ready condition, and the aggregate
// Ready condition summarizes the overall policy health.
// +optional
// +listType=map
// +listMapKey=type
// +patchStrategy=merge
// +patchMergeKey=type
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down Expand Up @@ -558,6 +567,16 @@ func (n *NicClusterPolicy) SetReason(reason string) {
n.Status.Reason = reason
}

// GetConditions implements ConditionHolder.
func (n *NicClusterPolicy) GetConditions() []metav1.Condition {
return n.Status.Conditions
}

// SetConditions implements ConditionHolder.
func (n *NicClusterPolicy) SetConditions(conditions []metav1.Condition) {
n.Status.Conditions = conditions
}

func init() {
SchemeBuilder.Register(&NicClusterPolicy{}, &NicClusterPolicyList{})
}
91 changes: 91 additions & 0 deletions api/v1alpha1/nicclusterpolicyconditions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
Copyright 2026 NVIDIA CORPORATION & AFFILIATES

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

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

// Per-component condition type constants.
// Each component present in the spec exposes exactly one condition of the
// form <ComponentName>Ready. Components absent from the spec are omitted.
const (
ConditionTypeOFEDDriverReady = "OFEDDriverReady"
ConditionTypeRDMASharedDevicePluginReady = "RDMASharedDevicePluginReady"
ConditionTypeSRIOVDevicePluginReady = "SRIOVDevicePluginReady"
ConditionTypeIBKubernetesReady = "IBKubernetesReady"
ConditionTypeMultusCNIReady = "MultusCNIReady"
ConditionTypeCNIPluginsReady = "CNIPluginsReady"
ConditionTypeIPoIBCNIReady = "IPoIBCNIReady"
ConditionTypeNVIPAMReady = "NVIPAMReady"
ConditionTypeNICFeatureDiscoveryReady = "NICFeatureDiscoveryReady"
ConditionTypeDOCATelemetryServiceReady = "DOCATelemetryServiceReady"
ConditionTypeNICConfigurationOperatorReady = "NICConfigurationOperatorReady"
ConditionTypeSpectrumXOperatorReady = "SpectrumXOperatorReady"

// ConditionTypeReady is the aggregate condition that is True only when every
// configured component is ready.
ConditionTypeReady = "Ready"
)

// Reason constants for per-component <ComponentName>Ready conditions.
const (
// ConditionReasonComponentReady indicates the component's workloads are fully available.
ConditionReasonComponentReady = "ComponentReady"
// ConditionReasonComponentNotReady indicates the component is deploying and expected
// to become ready without operator intervention.
ConditionReasonComponentNotReady = "ComponentNotReady"
// ConditionReasonComponentError indicates a reconcile failure that requires attention.
// Also used as a reason for the aggregate Ready condition.
ConditionReasonComponentError = "ComponentError"
)

// Reason constants for the aggregate Ready condition.
const (
// ConditionReasonAllComponentsReady indicates every configured component is ready.
ConditionReasonAllComponentsReady = "AllComponentsReady"
// ConditionReasonComponentsNotReady indicates at least one component is still deploying.
ConditionReasonComponentsNotReady = "ComponentsNotReady"
)

// StateNameToConditionType maps the Name() of a pkg/state.State to the
// corresponding per-component condition type constant.
// NicNodePolicy reconciles a subset of these entries (OFED, RDMA shared device
// plugin, SR-IOV device plugin); NicClusterPolicy reconciles all entries.
// States absent from this map (e.g. those used by network CRDs) produce no
// condition entry.
var StateNameToConditionType = map[string]string{
"state-OFED": ConditionTypeOFEDDriverReady,
"state-RDMA-device-plugin": ConditionTypeRDMASharedDevicePluginReady,
"state-SRIOV-device-plugin": ConditionTypeSRIOVDevicePluginReady,
"state-ib-kubernetes": ConditionTypeIBKubernetesReady,
"state-multus-cni": ConditionTypeMultusCNIReady,
"state-container-networking-plugins": ConditionTypeCNIPluginsReady,
"state-ipoib-cni": ConditionTypeIPoIBCNIReady,
"state-nv-ipam-cni": ConditionTypeNVIPAMReady,
"state-nic-feature-discovery": ConditionTypeNICFeatureDiscoveryReady,
"state-doca-telemetry-service": ConditionTypeDOCATelemetryServiceReady,
"state-nic-configuration-operator": ConditionTypeNICConfigurationOperatorReady,
"state-spectrum-x-operator": ConditionTypeSpectrumXOperatorReady,
}

// ConditionHolder is implemented by CRDs that carry a status.conditions array.
// NicClusterPolicy and NicNodePolicy implement this interface.
//
// +kubebuilder:object:generate=false
type ConditionHolder interface {
GetConditions() []metav1.Condition
SetConditions([]metav1.Condition)
}
22 changes: 19 additions & 3 deletions api/v1alpha1/nicnodepolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,22 @@ type NicNodePolicySpec struct {

// NicNodePolicyStatus defines the observed state of NicNodePolicy
type NicNodePolicyStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Reflects the current state of the cluster policy
// +kubebuilder:validation:Enum={"ignore", "notReady", "ready", "error"}
State State `json:"state"`
// Informative string in case the observed state is error
Reason string `json:"reason,omitempty"`
// AppliedStates provide a finer view of the observed state
AppliedStates []AppliedState `json:"appliedStates,omitempty"`
// Conditions is a list of conditions describing the state of the NicNodePolicy.
// Each enabled component exposes a <ComponentName>Ready condition, and the aggregate
// Ready condition summarizes the overall policy health.
// +optional
// +listType=map
// +listMapKey=type
// +patchStrategy=merge
// +patchMergeKey=type
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down Expand Up @@ -174,6 +180,16 @@ func (n *NicNodePolicy) SetReason(reason string) {
n.Status.Reason = reason
}

// GetConditions implements ConditionHolder.
func (n *NicNodePolicy) GetConditions() []metav1.Condition {
return n.Status.Conditions
}

// SetConditions implements ConditionHolder.
func (n *NicNodePolicy) SetConditions(conditions []metav1.Condition) {
n.Status.Conditions = conditions
}

func init() {
SchemeBuilder.Register(&NicNodePolicy{}, &NicNodePolicyList{})
}
15 changes: 15 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

63 changes: 63 additions & 0 deletions config/crd/bases/mellanox.com_nicclusterpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2101,6 +2101,69 @@ spec:
- state
type: object
type: array
conditions:
description: |-
Conditions is a list of conditions describing the state of the NicClusterPolicy.
Each enabled component exposes a <ComponentName>Ready condition, and the aggregate
Ready condition summarizes the overall policy health.
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
properties:
lastTransitionTime:
description: |-
lastTransitionTime is the last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: |-
message is a human readable message indicating details about the transition.
This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: |-
observedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: |-
reason contains a programmatic identifier indicating the reason for the condition's last transition.
Producers of specific condition types may define expected values and meanings for this field,
and whether the values are considered a guaranteed API.
The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
reason:
description: Informative string in case the observed state is error
type: string
Expand Down
63 changes: 63 additions & 0 deletions config/crd/bases/mellanox.com_nicnodepolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,69 @@ spec:
- state
type: object
type: array
conditions:
description: |-
Conditions is a list of conditions describing the state of the NicNodePolicy.
Each enabled component exposes a <ComponentName>Ready condition, and the aggregate
Ready condition summarizes the overall policy health.
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
properties:
lastTransitionTime:
description: |-
lastTransitionTime is the last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: |-
message is a human readable message indicating details about the transition.
This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: |-
observedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: |-
reason contains a programmatic identifier indicating the reason for the condition's last transition.
Producers of specific condition types may define expected values and meanings for this field,
and whether the values are considered a guaranteed API.
The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
reason:
description: Informative string in case the observed state is error
type: string
Expand Down
Loading
Loading