Skip to content

Commit

Permalink
controlllers/sts: changes match labels selector for resize PVC
Browse files Browse the repository at this point in the history
sts.spec.selector.matchLabels must always match correspond PVC for statefulset.
it should fix bug with incorrect resizing
  • Loading branch information
f41gh7 committed Jan 16, 2023
1 parent 6c26786 commit e7b57dd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion controllers/factory/k8stools/expansion.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func growSTSPVC(ctx context.Context, rclient client.Client, sts *appsv1.Stateful
return err
}

return growPVCs(ctx, rclient, pvc.Spec.Resources.Requests.Storage(), sts.Namespace, sts.Spec.Template.Labels, isExpandable)
return growPVCs(ctx, rclient, pvc.Spec.Resources.Requests.Storage(), sts.Namespace, sts.Spec.Selector.MatchLabels, isExpandable)
}

// isStorageClassExpandable check is it possible to update size of given pvc
Expand Down Expand Up @@ -211,6 +211,9 @@ func growPVCs(ctx context.Context, rclient client.Client, size *resource.Quantit
if err := rclient.List(ctx, &pvcs, opts); err != nil {
return err
}
if len(pvcs.Items) == 0 {
log.Info("PVCs select call returned 0 pvcs, it could be a bug, inspect selectors", "want match", selector, "namespace", ns)
}
for i := range pvcs.Items {
pvc := pvcs.Items[i]
if mayGrow(size, pvc.Spec.Resources.Requests.Storage()) {
Expand Down

0 comments on commit e7b57dd

Please sign in to comment.