Skip to content

Commit

Permalink
feat: Support errors on NCP status
Browse files Browse the repository at this point in the history
Fixes Mellanox#533

Signed-off-by: Fred Rolland <frolland@nvidia.com>
  • Loading branch information
rollandf committed Apr 17, 2024
1 parent cb5b6c3 commit 10cb4ee
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/v1alpha1/nicclusterpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ type AppliedState struct {
Name string `json:"name"`
// +kubebuilder:validation:Enum={"ready", "notReady", "ignore", "error"}
State State `json:"state"`
// Error string in case the state is error
Error string `json:"error,omitempty"`
}

// NicClusterPolicyStatus defines the observed state of NicClusterPolicy
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/mellanox.com_hostdevicenetworks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ spec:
description: AppliedState defines a finer-grained view of the observed
state of NicClusterPolicy
properties:
error:
description: Error string in case the state is error
type: string
name:
type: string
state:
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/mellanox.com_nicclusterpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,9 @@ spec:
description: AppliedState defines a finer-grained view of the observed
state of NicClusterPolicy
properties:
error:
description: Error string in case the state is error
type: string
name:
type: string
state:
Expand Down
5 changes: 5 additions & 0 deletions controllers/nicclusterpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ NextResult:
for i := range cr.Status.AppliedStates {
if cr.Status.AppliedStates[i].Name == stateStatus.StateName {
cr.Status.AppliedStates[i].State = mellanoxv1alpha1.State(stateStatus.Status)
if stateStatus.ErrInfo != nil {
cr.Status.AppliedStates[i].Error = stateStatus.ErrInfo.Error()
} else {
cr.Status.AppliedStates[i].Error = ""
}
continue NextResult
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ spec:
description: AppliedState defines a finer-grained view of the observed
state of NicClusterPolicy
properties:
error:
description: Error string in case the state is error
type: string
name:
type: string
state:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,9 @@ spec:
description: AppliedState defines a finer-grained view of the observed
state of NicClusterPolicy
properties:
error:
description: Error string in case the state is error
type: string
name:
type: string
state:
Expand Down

0 comments on commit 10cb4ee

Please sign in to comment.