From 75806e29b06e0949587d9947163cc68466c85996 Mon Sep 17 00:00:00 2001 From: richardxz Date: Thu, 21 Jun 2018 14:43:23 +0800 Subject: [PATCH] add pvc status submit function --- pkg/models/controllers/pods.go | 2 +- pkg/models/controllers/types.go | 1 + pkg/models/resources.go | 11 +++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/models/controllers/pods.go b/pkg/models/controllers/pods.go index fd929ad4b..f0fff7aa7 100644 --- a/pkg/models/controllers/pods.go +++ b/pkg/models/controllers/pods.go @@ -29,7 +29,7 @@ import ( "k8s.io/client-go/tools/cache" ) -const inUse = "in_use_pods" +const inUse = "kubesphere.io/in_use_pods" func (ctl *PodCtl) addAnnotationToPvc(item v1.Pod) { volumes := item.Spec.Volumes diff --git a/pkg/models/controllers/types.go b/pkg/models/controllers/types.go index 4c924ad25..9ddce4762 100644 --- a/pkg/models/controllers/types.go +++ b/pkg/models/controllers/types.go @@ -33,6 +33,7 @@ import ( const ( resyncCircle = 180 Stopped = "stopped" + PvcPending = "Pending" Running = "running" Updating = "updating" tablePods = "pods" diff --git a/pkg/models/resources.go b/pkg/models/resources.go index 1d80a69b6..1080b52d7 100644 --- a/pkg/models/resources.go +++ b/pkg/models/resources.go @@ -140,15 +140,18 @@ type workLoadStatus struct { } func GetNamespacesResourceStatus(namespace string) (*workLoadStatus, error) { - res := workLoadStatus{Count: make(map[string]int), NameSpace: namespace, Items: make(map[string]interface{})} var status *ResourceList var err error - for _, resource := range []string{controllers.Deployments, controllers.Statefulsets, controllers.Daemonsets} { + for _, resource := range []string{controllers.Deployments, controllers.Statefulsets, controllers.Daemonsets, controllers.PersistentVolumeClaim} { + resourceStatus := controllers.Updating + if resource == controllers.PersistentVolumeClaim { + resourceStatus = controllers.PvcPending + } if len(namespace) > 0 { - status, err = ListResource(resource, fmt.Sprintf("status=%s,namespace=%s", controllers.Updating, namespace), "") + status, err = ListResource(resource, fmt.Sprintf("status=%s,namespace=%s", resourceStatus, namespace), "") } else { - status, err = ListResource(resource, fmt.Sprintf("status=%s", controllers.Updating), "") + status, err = ListResource(resource, fmt.Sprintf("status=%s", resourceStatus), "") } if err != nil {