未验证 提交 2a388ad4 编写于 作者: K KubeSphere CI Bot 提交者: GitHub

Merge pull request #2533 from min-zh/storage

fix pvc count of sc
......@@ -90,13 +90,10 @@ func (s *storageClassesSearcher) Search(namespace string, conditions *params.Con
r := make([]interface{}, 0)
for _, i := range result {
count := s.countPersistentVolumeClaims(i.Name)
isSnapshotAllow := s.isSnapshotAllowed(i.Provisioner)
if i.Annotations == nil {
i.Annotations = make(map[string]string)
i.Annotations["kubesphere.io/pvc-count"] = string(count)
i.Annotations["kubesphere.io/allow-snapshot"] = strconv.FormatBool(isSnapshotAllow)
}
i.Annotations["kubesphere.io/pvc-count"] = strconv.Itoa(count)
r = append(r, i)
}
return r, nil
......@@ -117,20 +114,3 @@ func (s *storageClassesSearcher) countPersistentVolumeClaims(name string) int {
return count
}
func (s *storageClassesSearcher) isSnapshotAllowed(provisioner string) bool {
if len(provisioner) == 0 {
return false
}
volumeSnapshotClasses, err := s.snapshotInformers.Snapshot().V1beta1().VolumeSnapshotClasses().Lister().List(labels.Everything())
if err != nil {
return false
}
for _, volumeSnapshotClass := range volumeSnapshotClasses {
if volumeSnapshotClass.Driver == provisioner {
return true
}
}
return false
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册