reflect health status for recording the healthy state of the current resource running in the member cluster
Signed-off-by: changzhen <changzhen5@huawei.com>
This commit is contained in:
parent
4657282293
commit
afca732825
|
@ -294,6 +294,18 @@ func (c *WorkStatusController) reflectStatus(work *workv1alpha1.Work, clusterObj
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var resourceHealth workv1alpha1.ResourceHealth
|
||||||
|
// When an unregistered resource kind is requested with the ResourceInterpreter,
|
||||||
|
// the interpreter will return an error, we treat its health status as Unknown.
|
||||||
|
healthy, err := c.ResourceInterpreter.InterpretHealth(clusterObj)
|
||||||
|
if err != nil {
|
||||||
|
resourceHealth = workv1alpha1.ResourceUnknown
|
||||||
|
} else if healthy {
|
||||||
|
resourceHealth = workv1alpha1.ResourceHealthy
|
||||||
|
} else {
|
||||||
|
resourceHealth = workv1alpha1.ResourceUnhealthy
|
||||||
|
}
|
||||||
|
|
||||||
identifier, err := c.buildStatusIdentifier(work, clusterObj)
|
identifier, err := c.buildStatusIdentifier(work, clusterObj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -302,6 +314,7 @@ func (c *WorkStatusController) reflectStatus(work *workv1alpha1.Work, clusterObj
|
||||||
manifestStatus := workv1alpha1.ManifestStatus{
|
manifestStatus := workv1alpha1.ManifestStatus{
|
||||||
Identifier: *identifier,
|
Identifier: *identifier,
|
||||||
Status: statusRaw,
|
Status: statusRaw,
|
||||||
|
Health: resourceHealth,
|
||||||
}
|
}
|
||||||
|
|
||||||
workCopy := work.DeepCopy()
|
workCopy := work.DeepCopy()
|
||||||
|
|
|
@ -63,7 +63,9 @@ func (e *DefaultInterpreter) HookEnabled(kind schema.GroupVersionKind, operation
|
||||||
case configv1alpha1.InterpreterOperationInterpretStatus:
|
case configv1alpha1.InterpreterOperationInterpretStatus:
|
||||||
return true
|
return true
|
||||||
case configv1alpha1.InterpreterOperationInterpretHealth:
|
case configv1alpha1.InterpreterOperationInterpretHealth:
|
||||||
return true
|
if _, exist := e.healthHandlers[kind]; exist {
|
||||||
|
return true
|
||||||
|
}
|
||||||
// TODO(RainbowMango): more cases should be added here
|
// TODO(RainbowMango): more cases should be added here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,7 @@ func assembleWorkStatus(works []workv1alpha1.Work, workload *unstructured.Unstru
|
||||||
ClusterName: clusterName,
|
ClusterName: clusterName,
|
||||||
Applied: applied,
|
Applied: applied,
|
||||||
AppliedMessage: appliedMsg,
|
AppliedMessage: appliedMsg,
|
||||||
|
Health: workv1alpha2.ResourceUnknown,
|
||||||
}
|
}
|
||||||
statuses = append(statuses, aggregatedStatus)
|
statuses = append(statuses, aggregatedStatus)
|
||||||
continue
|
continue
|
||||||
|
@ -176,6 +177,7 @@ func assembleWorkStatus(works []workv1alpha1.Work, workload *unstructured.Unstru
|
||||||
aggregatedStatus := workv1alpha2.AggregatedStatusItem{
|
aggregatedStatus := workv1alpha2.AggregatedStatusItem{
|
||||||
ClusterName: clusterName,
|
ClusterName: clusterName,
|
||||||
Applied: applied,
|
Applied: applied,
|
||||||
|
Health: workv1alpha2.ResourceUnknown,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, manifestStatus := range work.Status.ManifestStatuses {
|
for _, manifestStatus := range work.Status.ManifestStatuses {
|
||||||
|
@ -185,6 +187,7 @@ func assembleWorkStatus(works []workv1alpha1.Work, workload *unstructured.Unstru
|
||||||
}
|
}
|
||||||
if equal {
|
if equal {
|
||||||
aggregatedStatus.Status = manifestStatus.Status
|
aggregatedStatus.Status = manifestStatus.Status
|
||||||
|
aggregatedStatus.Health = workv1alpha2.ResourceHealth(manifestStatus.Health)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue