aboutsummaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/k8splugin/internal/app')
-rw-r--r--src/k8splugin/internal/app/client.go1
-rw-r--r--src/k8splugin/internal/app/instance.go44
-rw-r--r--src/k8splugin/internal/app/query.go6
3 files changed, 45 insertions, 6 deletions
diff --git a/src/k8splugin/internal/app/client.go b/src/k8splugin/internal/app/client.go
index f70dc0a5..a2868cd5 100644
--- a/src/k8splugin/internal/app/client.go
+++ b/src/k8splugin/internal/app/client.go
@@ -256,6 +256,7 @@ func (k *KubernetesClient) queryResources(apiVersion, kind, labelSelector, names
LabelSelector: labelSelector,
}
var unstrList *unstructured.UnstructuredList
+ dynClient.Resource(gvr).Namespace(namespace).List(context.TODO(), opts)
switch mapping.Scope.Name() {
case meta.RESTScopeNameNamespace:
unstrList, err = dynClient.Resource(gvr).Namespace(namespace).List(context.TODO(), opts)
diff --git a/src/k8splugin/internal/app/instance.go b/src/k8splugin/internal/app/instance.go
index c4cce5ed..e50a59e5 100644
--- a/src/k8splugin/internal/app/instance.go
+++ b/src/k8splugin/internal/app/instance.go
@@ -34,6 +34,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/resource"
+ "github.com/onap/multicloud-k8s/src/k8splugin/internal/config"
"github.com/onap/multicloud-k8s/src/k8splugin/internal/db"
"github.com/onap/multicloud-k8s/src/k8splugin/internal/helm"
"github.com/onap/multicloud-k8s/src/k8splugin/internal/namegenerator"
@@ -461,7 +462,15 @@ func (v *InstanceClient) Query(id, apiVersion, kind, name, labels string) (Insta
return InstanceStatus{}, pkgerrors.Wrap(err, "Unmarshaling Instance Value")
}
- resources, err := queryClient.Query(resResp.Namespace, resResp.Request.CloudRegion, apiVersion, kind, name, labels, id)
+ if labels == "" || strings.Contains(strings.ToLower(labels), config.GetConfiguration().KubernetesLabelName) == false {
+ labelValue := config.GetConfiguration().KubernetesLabelName + "=" + id
+ if labels != "" {
+ labels = labels + ","
+ }
+ labels = labels + labelValue
+ }
+
+ resources, err := queryClient.Query(resResp.Namespace, resResp.Request.CloudRegion, apiVersion, kind, name, labels)
if err != nil {
return InstanceStatus{}, pkgerrors.Wrap(err, "Querying Resources")
}
@@ -502,6 +511,11 @@ func (v *InstanceClient) Status(id string) (InstanceStatus, error) {
if err != nil {
return InstanceStatus{}, pkgerrors.Wrap(err, "Getting CloudRegion Information")
}
+ req := resResp.Request
+ profile, err := rb.NewProfileClient().Get(req.RBName, req.RBVersion, req.ProfileName)
+ if err != nil {
+ return InstanceStatus{}, pkgerrors.New("Unable to find Profile instance status")
+ }
cumulatedErrorMsg := make([]string, 0)
podsStatus, err := k8sClient.getPodsByLabel(resResp.Namespace)
@@ -534,12 +548,36 @@ Main:
}
}
}
+ generalStatus = append(generalStatus, podsStatus...)
+
+ if profile.ExtraResourceTypes != nil && len(profile.ExtraResourceTypes) > 0 {
+ queryClient := NewQueryClient()
+ labelValue := config.GetConfiguration().KubernetesLabelName + "=" + id
+ for _, extraType := range profile.ExtraResourceTypes {
+ queryStatus, err := queryClient.Query(resResp.Namespace, resResp.Request.CloudRegion, extraType.GroupVersion().Identifier(), extraType.Kind, "", labelValue)
+ if err != nil {
+ return InstanceStatus{}, pkgerrors.Wrap(err, "Querying Resources")
+ }
+ for _, rs := range queryStatus.ResourcesStatus {
+ foundRes := false
+ for _, res := range generalStatus {
+ if res.GVK == rs.GVK && res.Name == rs.Name {
+ foundRes = true
+ break
+ }
+ }
+ if !foundRes {
+ generalStatus = append(generalStatus, rs)
+ }
+ }
+ }
+ }
//We still need to iterate through rss list even the status is not DONE, to gather status of rss + pod for the response
resp := InstanceStatus{
Request: resResp.Request,
- ResourceCount: int32(len(generalStatus) + len(podsStatus)),
+ ResourceCount: int32(len(generalStatus)),
Ready: isReady && resResp.Status == "DONE",
- ResourcesStatus: append(generalStatus, podsStatus...),
+ ResourcesStatus: generalStatus,
}
if len(cumulatedErrorMsg) != 0 {
diff --git a/src/k8splugin/internal/app/query.go b/src/k8splugin/internal/app/query.go
index cb645afd..251b14e6 100644
--- a/src/k8splugin/internal/app/query.go
+++ b/src/k8splugin/internal/app/query.go
@@ -33,7 +33,7 @@ type QueryStatus struct {
// QueryManager is an interface exposes the instantiation functionality
type QueryManager interface {
- Query(namespace, cloudRegion, apiVersion, kind, name, labels, id string) (QueryStatus, error)
+ Query(namespace, cloudRegion, apiVersion, kind, name, labels string) (QueryStatus, error)
}
// QueryClient implements the InstanceManager interface
@@ -53,12 +53,12 @@ func NewQueryClient() *QueryClient {
}
// Query returns state of instance's filtered resources
-func (v *QueryClient) Query(namespace, cloudRegion, apiVersion, kind, name, labels, id string) (QueryStatus, error) {
+func (v *QueryClient) Query(namespace, cloudRegion, apiVersion, kind, name, labels string) (QueryStatus, error) {
//Read the status from the DD
k8sClient := KubernetesClient{}
- err := k8sClient.Init(cloudRegion, id)
+ err := k8sClient.Init(cloudRegion, "dummy") //we don't care about instance id in this request
if err != nil {
return QueryStatus{}, pkgerrors.Wrap(err, "Getting CloudRegion Information")
}