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
1 change: 0 additions & 1 deletion api/restHandler/AppListingRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,6 @@ func (handler AppListingRestHandlerImpl) fetchResourceTree(w http.ResponseWriter
}
}
appDetail.ResourceTree = util2.InterfaceToMapAdapter(resp)
handler.logger.Debugw("application environment status", "appId", appId, "envId", envId, "resp", resp)
if resp.Status == string(health.HealthStatusHealthy) {
err = handler.cdApplicationStatusUpdateHandler.SyncPipelineStatusForResourceTreeCall(acdAppName, appId, envId)
if err != nil {
Expand Down
33 changes: 33 additions & 0 deletions client/argocdServer/application/Application.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ func (c ServiceClientImpl) ResourceTree(ctxt context.Context, query *application
if app != nil {
appResp, err := app.Recv()
if err == nil {
// https://github.com/argoproj/argo-cd/issues/11234 workaround
c.updateNodeHealthStatus(resp, appResp)

status = string(appResp.Application.Status.Health.Status)
hash = appResp.Application.Status.Sync.Revision
conditions = appResp.Application.Status.Conditions
Expand All @@ -410,6 +413,36 @@ func (c ServiceClientImpl) ResourceTree(ctxt context.Context, query *application
return &ResourceTreeResponse{resp, newReplicaSets, status, hash, podMetadata, conditions}, err
}

// fill the health status in node from app resources
func (c ServiceClientImpl) updateNodeHealthStatus(resp *v1alpha1.ApplicationTree, appResp *v1alpha1.ApplicationWatchEvent) {
if resp == nil || len(resp.Nodes) == 0 || appResp == nil || len(appResp.Application.Status.Resources) == 0 {
return
}

for index, node := range resp.Nodes {
if node.Health != nil {
continue
}
for _, resource := range appResp.Application.Status.Resources {
if node.Group != resource.Group || node.Version != resource.Version || node.Kind != resource.Kind ||
node.Name != resource.Name || node.Namespace != resource.Namespace {
continue
}
resourceHealth := resource.Health
if resourceHealth != nil {
node.Health = &v1alpha1.HealthStatus{
Message: resourceHealth.Message,
Status: resourceHealth.Status,
}
// updating the element in slice
// https://medium.com/@xcoulon/3-ways-to-update-elements-in-a-slice-d5df54c9b2f8
resp.Nodes[index] = node
}
break
}
}
}

func (c ServiceClientImpl) buildPodMetadata(resp *v1alpha1.ApplicationTree, responses []*Result) (podMetaData []*PodMetadata, newReplicaSets []string) {
rolloutManifests := make([]map[string]interface{}, 0)
statefulSetManifest := make(map[string]interface{})
Expand Down