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
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -302,6 +314,7 @@ func (c *WorkStatusController) reflectStatus(work *workv1alpha1.Work, clusterObj
|
|||
manifestStatus := workv1alpha1.ManifestStatus{
|
||||
Identifier: *identifier,
|
||||
Status: statusRaw,
|
||||
Health: resourceHealth,
|
||||
}
|
||||
|
||||
workCopy := work.DeepCopy()
|
||||
|
|
|
@ -63,7 +63,9 @@ func (e *DefaultInterpreter) HookEnabled(kind schema.GroupVersionKind, operation
|
|||
case configv1alpha1.InterpreterOperationInterpretStatus:
|
||||
return true
|
||||
case configv1alpha1.InterpreterOperationInterpretHealth:
|
||||
if _, exist := e.healthHandlers[kind]; exist {
|
||||
return true
|
||||
}
|
||||
// TODO(RainbowMango): more cases should be added here
|
||||
}
|
||||
|
||||
|
|
|
@ -167,6 +167,7 @@ func assembleWorkStatus(works []workv1alpha1.Work, workload *unstructured.Unstru
|
|||
ClusterName: clusterName,
|
||||
Applied: applied,
|
||||
AppliedMessage: appliedMsg,
|
||||
Health: workv1alpha2.ResourceUnknown,
|
||||
}
|
||||
statuses = append(statuses, aggregatedStatus)
|
||||
continue
|
||||
|
@ -176,6 +177,7 @@ func assembleWorkStatus(works []workv1alpha1.Work, workload *unstructured.Unstru
|
|||
aggregatedStatus := workv1alpha2.AggregatedStatusItem{
|
||||
ClusterName: clusterName,
|
||||
Applied: applied,
|
||||
Health: workv1alpha2.ResourceUnknown,
|
||||
}
|
||||
|
||||
for _, manifestStatus := range work.Status.ManifestStatuses {
|
||||
|
@ -185,6 +187,7 @@ func assembleWorkStatus(works []workv1alpha1.Work, workload *unstructured.Unstru
|
|||
}
|
||||
if equal {
|
||||
aggregatedStatus.Status = manifestStatus.Status
|
||||
aggregatedStatus.Health = workv1alpha2.ResourceHealth(manifestStatus.Health)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue