From b3fe5915cbd68b62b533af833eebda771dd5d899 Mon Sep 17 00:00:00 2001 From: Lukasz Rajewski Date: Fri, 6 Aug 2021 14:49:29 +0200 Subject: Fixed issue in Status handler Fixed issue in Status handler when reading status of not ready resource Issue-ID: MULTICLOUD-1372 Signed-off-by: Lukasz Rajewski Change-Id: I3739bb30a7ab28f6bb4b6648c522bddee37db96b --- src/k8splugin/internal/app/instance.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/k8splugin/internal/app/instance.go b/src/k8splugin/internal/app/instance.go index caf756a0..c12b0a68 100644 --- a/src/k8splugin/internal/app/instance.go +++ b/src/k8splugin/internal/app/instance.go @@ -22,6 +22,10 @@ import ( "context" "encoding/json" + "log" + "strings" + "time" + appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" @@ -29,9 +33,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/cli-runtime/pkg/resource" - "log" - "strings" - "time" "github.com/onap/multicloud-k8s/src/k8splugin/internal/db" "github.com/onap/multicloud-k8s/src/k8splugin/internal/helm" @@ -313,14 +314,18 @@ Main: if !ready || err != nil { isReady = false - cumulatedErrorMsg = append(cumulatedErrorMsg, err.Error()) - break + if err != nil { + cumulatedErrorMsg = append(cumulatedErrorMsg, err.Error()) + } else { + apiVersion, kind := oneResource.GVK.ToAPIVersionAndKind() + cumulatedErrorMsg = append(cumulatedErrorMsg, kind+"/"+apiVersion+" ("+oneResource.Name+") is not ready") + } } } resp := InstanceStatus{ Request: resResp.Request, ResourceCount: int32(len(generalStatus) + len(podsStatus)), - Ready: isReady, //FIXME To determine readiness, some parsing of status fields is necessary + Ready: isReady, ResourcesStatus: append(generalStatus, podsStatus...), } @@ -334,7 +339,7 @@ Main: return resp, nil } -func (v *InstanceClient) checkRssStatus(rss helm.KubernetesResource, k8sClient KubernetesClient, namespace string, status ResourceStatus) (bool, error){ +func (v *InstanceClient) checkRssStatus(rss helm.KubernetesResource, k8sClient KubernetesClient, namespace string, status ResourceStatus) (bool, error) { readyChecker := statuscheck.NewReadyChecker(k8sClient.clientSet, statuscheck.PausedAsReady(true), statuscheck.CheckJobs(true)) ctx, cancel := context.WithTimeout(context.Background(), time.Duration(60)*time.Second) defer cancel() -- cgit 1.2.3-korg