diff --git a/api/v1alpha1/nicclusterpolicy_types.go b/api/v1alpha1/nicclusterpolicy_types.go index 1cbd8d88..388fa9e0 100644 --- a/api/v1alpha1/nicclusterpolicy_types.go +++ b/api/v1alpha1/nicclusterpolicy_types.go @@ -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 diff --git a/config/crd/bases/mellanox.com_hostdevicenetworks.yaml b/config/crd/bases/mellanox.com_hostdevicenetworks.yaml index a41863b2..7e9efa41 100644 --- a/config/crd/bases/mellanox.com_hostdevicenetworks.yaml +++ b/config/crd/bases/mellanox.com_hostdevicenetworks.yaml @@ -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: diff --git a/config/crd/bases/mellanox.com_nicclusterpolicies.yaml b/config/crd/bases/mellanox.com_nicclusterpolicies.yaml index 3e976db3..13dd3d6b 100644 --- a/config/crd/bases/mellanox.com_nicclusterpolicies.yaml +++ b/config/crd/bases/mellanox.com_nicclusterpolicies.yaml @@ -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: diff --git a/controllers/nicclusterpolicy_controller.go b/controllers/nicclusterpolicy_controller.go index 1e5d380b..03d7c415 100644 --- a/controllers/nicclusterpolicy_controller.go +++ b/controllers/nicclusterpolicy_controller.go @@ -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 } } diff --git a/deployment/network-operator/crds/mellanox.com_hostdevicenetworks.yaml b/deployment/network-operator/crds/mellanox.com_hostdevicenetworks.yaml index a41863b2..7e9efa41 100644 --- a/deployment/network-operator/crds/mellanox.com_hostdevicenetworks.yaml +++ b/deployment/network-operator/crds/mellanox.com_hostdevicenetworks.yaml @@ -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: diff --git a/deployment/network-operator/crds/mellanox.com_nicclusterpolicies.yaml b/deployment/network-operator/crds/mellanox.com_nicclusterpolicies.yaml index 3e976db3..13dd3d6b 100644 --- a/deployment/network-operator/crds/mellanox.com_nicclusterpolicies.yaml +++ b/deployment/network-operator/crds/mellanox.com_nicclusterpolicies.yaml @@ -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: