func matchWorkloadStatus(patterns []string, workloadStatus status.Status, agentStatus status.Status) (bool, bool, error) { oneValidStatus := false for _, p := range patterns { // If the pattern isn't a known status, ignore it. ps := status.Status(p) if !ps.KnownWorkloadStatus() { continue } oneValidStatus = true // To preserve current expected behaviour, we only report on workload status // if the agent itself is not in error. if agentStatus != status.Error && workloadStatus.WorkloadMatches(ps) { return true, true, nil } } return false, oneValidStatus, nil }