Skip to content

Commit a24dba3

Browse files
armrumnencia
andauthored
feat: remove Azure CSI driver resize workaround (#7297)
This commit removes `ENABLE_AZURE_PVC_UPDATES` configuration and the related status field. The configuration is no longer needed for the operator to resize Azure volumes correctly. This change has been incorporated in the Azure CSI driver since version 1.11.0. Closes #7296 Signed-off-by: Armando Ruocco <[email protected]> Signed-off-by: Marco Nenciarini <[email protected]> Co-authored-by: Marco Nenciarini <[email protected]>
1 parent 9d9caf2 commit a24dba3

8 files changed

Lines changed: 0 additions & 152 deletions

File tree

‎api/v1/cluster_types.go‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -936,10 +936,6 @@ type ClusterStatus struct {
936936
// +optional
937937
OnlineUpdateEnabled bool `json:"onlineUpdateEnabled,omitempty"`
938938

939-
// AzurePVCUpdateEnabled shows if the PVC online upgrade is enabled for this cluster
940-
// +optional
941-
AzurePVCUpdateEnabled bool `json:"azurePVCUpdateEnabled,omitempty"`
942-
943939
// Image contains the image name used by the pods
944940
// +optional
945941
Image string `json:"image,omitempty"`

‎config/crd/bases/postgresql.cnpg.io_clusters.yaml‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5927,10 +5927,6 @@ spec:
59275927
- hash
59285928
type: object
59295929
type: array
5930-
azurePVCUpdateEnabled:
5931-
description: AzurePVCUpdateEnabled shows if the PVC online upgrade
5932-
is enabled for this cluster
5933-
type: boolean
59345930
certificates:
59355931
description: The configuration for the CA and related certificates,
59365932
initialized with defaults.

‎docs/src/cloudnative-pg.v1.md‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,13 +2251,6 @@ This field is reported when <code>.spec.failoverDelay</code> is populated or dur
22512251
<p>OnlineUpdateEnabled shows if the online upgrade is enabled inside the cluster</p>
22522252
</td>
22532253
</tr>
2254-
<tr><td><code>azurePVCUpdateEnabled</code><br/>
2255-
<i>bool</i>
2256-
</td>
2257-
<td>
2258-
<p>AzurePVCUpdateEnabled shows if the PVC online upgrade is enabled for this cluster</p>
2259-
</td>
2260-
</tr>
22612254
<tr><td><code>image</code><br/>
22622255
<i>string</i>
22632256
</td>

‎docs/src/operator_conf.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Name | Description
3939
`CERTIFICATE_DURATION` | Determines the lifetime of the generated certificates in days. Default is 90.
4040
`CLUSTERS_ROLLOUT_DELAY` | The duration (in seconds) to wait between the roll-outs of different clusters during an operator upgrade. This setting controls the timing of upgrades across clusters, spreading them out to reduce system impact. The default value is `0` which means no delay between PostgreSQL cluster upgrades.
4141
`CREATE_ANY_SERVICE` | When set to `true`, will create `-any` service for the cluster. Default is `false`
42-
`ENABLE_AZURE_PVC_UPDATES` | Enables to delete Postgres pod if its PVC is stuck in Resizing condition. This feature is mainly for the Azure environment (default `false`)
4342
`ENABLE_INSTANCE_MANAGER_INPLACE_UPDATES` | When set to `true`, enables in-place updates of the instance manager after an update of the operator, avoiding rolling updates of the cluster (default `false`)
4443
`EXPIRING_CHECK_THRESHOLD` | Determines the threshold, in days, for identifying a certificate as expiring. Default is 7.
4544
`INCLUDE_PLUGINS` | A comma-separated list of plugins to be always included in the Cluster's reconciliation.

‎docs/src/storage.md‎

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -259,110 +259,6 @@ doesn't support that, you must delete the pod to trigger the resize.
259259
The best way to proceed is to delete one pod at a time, starting from replicas
260260
and waiting for each pod to be back up.
261261

262-
### Expanding PVC volumes on AKS
263-
264-
Currently, [Azure can resize the PVC's volume without restarting the pod only on specific regions](https://learn.microsoft.com/en-us/azure/aks/azure-disk-csi#resize-a-persistent-volume-without-downtime).
265-
CloudNativePG has overcome this limitation through the
266-
`ENABLE_AZURE_PVC_UPDATES` environment variable in the
267-
[operator configuration](operator_conf.md#available-options).
268-
When set to `true`, CloudNativePG triggers a rolling update of the
269-
Postgres cluster.
270-
271-
Alternatively, you can use the following workaround to manually resize the
272-
volume in AKS.
273-
274-
#### Workaround for volume expansion on AKS
275-
276-
You can manually resize a PVC on AKS. As an example, suppose you have a cluster
277-
with three replicas:
278-
279-
```
280-
$ kubectl get pods
281-
NAME READY STATUS RESTARTS AGE
282-
cluster-example-1 1/1 Running 0 2m37s
283-
cluster-example-2 1/1 Running 0 2m22s
284-
cluster-example-3 1/1 Running 0 2m10s
285-
```
286-
287-
An Azure disk can be expanded only while in "unattached" state, as described in the
288-
[Kubernetes documentation](https://github.com/kubernetes-sigs/azuredisk-csi-driver/blob/master/docs/known-issues/sizegrow.md). <!-- wokeignore:rule=master -->
289-
This means that, to resize a disk used by a PostgreSQL cluster, you need to
290-
perform a manual rollout, first cordoning the node that hosts the pod using the
291-
PVC bound to the disk. This prevents the operator from re-creating the pod and
292-
immediately reattaching it to its PVC before the background disk resizing is
293-
complete.
294-
295-
First, edit the cluster definition, applying the new size. In this example, the
296-
new size is `2Gi`.
297-
298-
```
299-
apiVersion: postgresql.cnpg.io/v1
300-
kind: Cluster
301-
metadata:
302-
name: cluster-example
303-
spec:
304-
instances: 3
305-
306-
storage:
307-
storageClass: default
308-
size: 2Gi
309-
```
310-
311-
Assuming the `cluster-example-1` pod is the cluster's primary, you can proceed
312-
with the replicas first. For example, start with cordoning the Kubernetes node
313-
that hosts the `cluster-example-3` pod:
314-
315-
```
316-
kubectl cordon <node of cluster-example-3>
317-
```
318-
319-
Then delete the `cluster-example-3` pod:
320-
321-
```
322-
$ kubectl delete pod/cluster-example-3
323-
```
324-
325-
Run the following command:
326-
327-
```
328-
kubectl get pvc -w -o=jsonpath='{.status.conditions[].message}' cluster-example-3
329-
```
330-
331-
Wait until you see the following output:
332-
333-
```
334-
Waiting for user to (re-)start a Pod to finish file system resize of volume on node.
335-
```
336-
337-
Then, you can uncordon the node:
338-
339-
```
340-
kubectl uncordon <node of cluster-example-3>
341-
```
342-
343-
Wait for the pod to be re-created correctly and get in a "Running and Ready" state:
344-
345-
```
346-
kubectl get pods -w cluster-example-3
347-
cluster-example-3 0/1 Init:0/1 0 12m
348-
cluster-example-3 1/1 Running 0 12m
349-
```
350-
351-
Verify the PVC expansion by running the following command, which returns `2Gi`
352-
as configured:
353-
354-
```
355-
kubectl get pvc cluster-example-3 -o=jsonpath='{.status.capacity.storage}'
356-
```
357-
358-
You can repeat these steps for the remaining pods.
359-
360-
!!! Important
361-
Leave the resizing of the disk associated with the primary instance as the
362-
last disk, after promoting through a switchover a new resized pod, using
363-
`kubectl cnpg promote`. For example, use `kubectl cnpg promote cluster-example 3`
364-
to promote `cluster-example-3` to primary.
365-
366262
### Re-creating storage
367263

368264
If the storage class doesn't support volume expansion, you can still regenerate

‎internal/configuration/configuration.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ type Data struct {
124124
// replacing the executable in a pod without restarting
125125
EnableInstanceManagerInplaceUpdates bool `json:"enableInstanceManagerInplaceUpdates" env:"ENABLE_INSTANCE_MANAGER_INPLACE_UPDATES"` //nolint
126126

127-
// EnableAzurePVCUpdates enables the live update of PVC in Azure environment
128-
EnableAzurePVCUpdates bool `json:"enableAzurePVCUpdates" env:"ENABLE_AZURE_PVC_UPDATES"`
129-
130127
// This is the lifetime of the generated certificates
131128
CertificateDuration int `json:"certificateDuration" env:"CERTIFICATE_DURATION"`
132129

‎internal/controller/cluster_create.go‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,19 +1345,6 @@ func (r *ClusterReconciler) ensureInstancesAreCreated(
13451345
)
13461346
return ctrl.Result{RequeueAfter: 1 * time.Second}, ErrNextLoop
13471347
}
1348-
1349-
if configuration.Current.EnableAzurePVCUpdates {
1350-
for _, resizingPVC := range cluster.Status.ResizingPVC {
1351-
// if the pvc is in resizing state we requeue and wait
1352-
if resizingPVC == instancePVC.Name {
1353-
contextLogger.Info(
1354-
"PVC is in resizing status, retrying in 5 seconds",
1355-
"instance", instanceToCreate.Name,
1356-
)
1357-
return ctrl.Result{RequeueAfter: 5 * time.Second}, ErrNextLoop
1358-
}
1359-
}
1360-
}
13611348
}
13621349

13631350
// If this cluster has been restarted, mark the Pod with the latest restart time

‎internal/controller/cluster_upgrade.go‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ func isPodNeedingRollout(
357357

358358
checkers := map[string]rolloutChecker{
359359
"pod has missing PVCs": checkHasMissingPVCs,
360-
"pod has PVC requiring resizing": checkHasResizingPVC,
361360
"pod projected volume is outdated": checkProjectedVolumeIsOutdated,
362361
"pod image is outdated": checkPodImageIsOutdated,
363362
"cluster has different restart annotation": checkClusterHasDifferentRestartAnnotation,
@@ -407,21 +406,6 @@ func hasValidPodSpec(pod *corev1.Pod) bool {
407406
return err == nil
408407
}
409408

410-
func checkHasResizingPVC(_ context.Context, pod *corev1.Pod, cluster *apiv1.Cluster) (rollout, error) {
411-
if configuration.Current.EnableAzurePVCUpdates {
412-
for _, pvcName := range cluster.Status.ResizingPVC {
413-
// This code works on the assumption that the PVC begins with the name of the pod using it.
414-
if persistentvolumeclaim.BelongToInstance(cluster, pod.Name, pvcName) {
415-
return rollout{
416-
required: true,
417-
reason: fmt.Sprintf("rebooting pod to complete the resizing of the following PVC: '%s'", pvcName),
418-
}, nil
419-
}
420-
}
421-
}
422-
return rollout{}, nil
423-
}
424-
425409
func checkPodNeedsUpdatedTopology(_ context.Context, pod *corev1.Pod, cluster *apiv1.Cluster) (rollout, error) {
426410
if reflect.DeepEqual(cluster.Spec.TopologySpreadConstraints, pod.Spec.TopologySpreadConstraints) {
427411
return rollout{}, nil

0 commit comments

Comments
 (0)