Skip to content

Commit

Permalink
list pvc_autoresizer pods with labelselector
Browse files Browse the repository at this point in the history
Signed-off-by: hellokg21 <[email protected]>
  • Loading branch information
hellokg21 committed Jan 7, 2024
1 parent dabd40a commit ca6b9a8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/install/pvcautoresizer/pvc_autoresizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,18 @@ func (m *PVCAutoResizerMaintainer) Ensure() (*hwameistoriov1alpha1.Cluster, erro
}

var podList corev1.PodList
if err := m.Client.List(context.TODO(), &podList, &client.ListOptions{Namespace: deployToCreate.Namespace}); err != nil {
selector, err := metav1.LabelSelectorAsSelector(deployToCreate.Spec.Selector)
if err != nil {
log.Errorf("convert LabelSelector to Selector err: %v", err)
}
if err := m.Client.List(context.TODO(), &podList, &client.ListOptions{LabelSelector: selector}); err != nil {
log.Errorf("List pods err: %v", err)
return newClusterInstance, err
}

var podsManaged []corev1.Pod
for _, pod := range podList.Items {
if pod.Labels[pvcAutoResizerLabelSelectorKey] == pvcAutoResizerLabelSelectorValue {
podsManaged = append(podsManaged, pod)
}
podsManaged = append(podsManaged, pod)
}

if len(podsManaged) > int(gotten.Status.Replicas) {
Expand Down

0 comments on commit ca6b9a8

Please sign in to comment.