Fix PVC list so it's only tenant PVCs. Fix NPE on pod listing. (#764)
This commit is contained in:
@@ -1391,14 +1391,17 @@ func getTenantPodsResponse(session *models.Principal, params admin_api.GetTenant
|
||||
return nil, prepareError(err)
|
||||
}
|
||||
retval := []*models.TenantPod{}
|
||||
for i := range pods.Items {
|
||||
restarts := int64(pods.Items[i].Status.ContainerStatuses[0].RestartCount)
|
||||
retval = append(retval, &models.TenantPod{Name: &pods.Items[i].ObjectMeta.Name,
|
||||
Status: string(pods.Items[i].Status.Phase),
|
||||
TimeCreated: pods.Items[i].CreationTimestamp.Unix(),
|
||||
PodIP: pods.Items[i].Status.PodIP,
|
||||
for _, pod := range pods.Items {
|
||||
var restarts int64 = 0
|
||||
if len(pod.Status.ContainerStatuses) > 0 {
|
||||
restarts = int64(pod.Status.ContainerStatuses[0].RestartCount)
|
||||
}
|
||||
retval = append(retval, &models.TenantPod{Name: &pod.ObjectMeta.Name,
|
||||
Status: string(pod.Status.Phase),
|
||||
TimeCreated: pod.CreationTimestamp.Unix(),
|
||||
PodIP: pod.Status.PodIP,
|
||||
Restarts: restarts,
|
||||
Node: pods.Items[i].Spec.NodeName})
|
||||
Node: pod.Spec.NodeName})
|
||||
}
|
||||
return retval, nil
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ package restapi
|
||||
import (
|
||||
"context"
|
||||
|
||||
miniov1 "github.com/minio/operator/pkg/apis/minio.min.io/v1"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/minio/console/cluster"
|
||||
"github.com/minio/console/models"
|
||||
@@ -47,7 +49,10 @@ func getPVCsResponse(session *models.Principal) (*models.ListPVCsResponse, *mode
|
||||
return nil, prepareError(err)
|
||||
}
|
||||
|
||||
listOpts := metav1.ListOptions{}
|
||||
// Filter Tenant PVCs. They keep their v1 tenant annotation
|
||||
listOpts := metav1.ListOptions{
|
||||
LabelSelector: miniov1.TenantLabel,
|
||||
}
|
||||
|
||||
// List all PVCs
|
||||
listAllPvcs, err2 := clientset.CoreV1().PersistentVolumeClaims("").List(ctx, listOpts)
|
||||
|
||||
Reference in New Issue
Block a user