Skip to content

Commit

Permalink
Merge branch 'master' into gh-953
Browse files Browse the repository at this point in the history
  • Loading branch information
f41gh7 committed May 21, 2024
2 parents 7d801f9 + a1823a7 commit 6e1c970
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
19 changes: 10 additions & 9 deletions controllers/factory/reconcile/statefulset_pvc_expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ func growSTSPVC(ctx context.Context, rclient client.Client, sts *appsv1.Stateful
logger.WithContext(ctx).Info("cannot find target pvc in new statefulset, please check if the old one is still needed", "pvc", pvc.Name, "sts", sts.Name, "claimName", stsClaimName)
continue
}
// check if pvc need to grow
newSize := stsClaim.Spec.Resources.Requests.Storage()
oldSize := pvc.Spec.Resources.Requests.Storage()
if !mayGrow(ctx, newSize, oldSize) {
continue
}
logger.WithContext(ctx).Info("need to expand pvc size", "name", pvc.Name, "from", oldSize, "to", newSize)
// check if storage class is expandable
isExpandable, err := isStorageClassExpandable(ctx, rclient, stsClaim)
if err != nil {
Expand All @@ -195,11 +202,10 @@ func growSTSPVC(ctx context.Context, rclient client.Client, sts *appsv1.Stateful
logger.WithContext(ctx).Info("storage class for PVC doesn't support live resizing", "pvc", pvc.Name)
continue
}
err = growPVCs(ctx, rclient, stsClaim.Spec.Resources.Requests.Storage(), &pvc)
err = growPVCs(ctx, rclient, newSize, &pvc)
if err != nil {
return fmt.Errorf("failed to expand size for pvc %s: %v", pvc.Name, err)
}

}
return nil
}
Expand Down Expand Up @@ -265,13 +271,8 @@ func isStorageClassExpandable(ctx context.Context, rclient client.Client, pvc *c
}

func growPVCs(ctx context.Context, rclient client.Client, size *resource.Quantity, pvc *corev1.PersistentVolumeClaim) error {
var err error
if mayGrow(ctx, size, pvc.Spec.Resources.Requests.Storage()) {
logger.WithContext(ctx).Info("need to expand pvc size", "name", pvc.Name, "from", pvc.Spec.Resources.Requests.Storage(), "to", size.String())
pvc.Spec.Resources.Requests[corev1.ResourceStorage] = *size
err = rclient.Update(ctx, pvc)
}
return err
pvc.Spec.Resources.Requests[corev1.ResourceStorage] = *size
return rclient.Update(ctx, pvc)
}

// checks is pvc needs to be resized.
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ aliases:

- [vmalertmanager](./api.md#vmalertmanager): ignores content of `cr.spec.configSecret` if it's name clashes with secret used by operator for storing alertmanager config. See this [issue](https://github.com/VictoriaMetrics/operator/issues/954) for details.
- [operator](./README.md): remove finalizer for child objects with non-empty `DeletetionTimestamp`. See this [issue](https://github.com/VictoriaMetrics/operator/issues/953) for details.
- [operator](./README.md): skip storageClass check if there is no PVC size change. See this [issue](https://github.com/VictoriaMetrics/operator/issues/957) for details.

## [v0.44.0](https://github.com/VictoriaMetrics/operator/releases/tag/v0.44.0) - 9 May 2024

Expand Down

0 comments on commit 6e1c970

Please sign in to comment.