# Modifying Autoscaling Volumes

{% hint style="success" %}
Modifying the size of autoscaling volumes is supported from agent version 1.36.0
{% endhint %}

## Modifying an Autoscaling Volume

There are two options for modifying the size of an autoscaling volume:

1. [On EC2](/volume-lifecycle/modify-a-volumes-parameters.md#volumes-attached-to-ec2-instances) - Use the Datafy [modify](/resources/api.md#post-api-v1-volumes-volumeid-modify) API instead of the AWS modify API
2. [In Kubernetes](/volume-lifecycle/modify-a-volumes-parameters.md#pvcs-in-kubernetes) - Edit the size of the PVC that the volume is associated with

{% hint style="danger" %}
Do not modify autoscaling volumes directly through the AWS console or API. This can cause unexpected behaviors in your volumes and is not supported.
{% endhint %}

{% hint style="info" %}
After autoscaling has been deactivated for a volume, you can use the AWS `ModifyVolume` API directly. As always, a reboot is recommended after [deactivation](/volume-lifecycle/managing-autoscaling-volumes.md#deactivating-autoscaling) in order to ensure expected behavior, especially if also uninstalling AutoScaler.
{% endhint %}

### Volumes Attached to EC2 Instances

Call the Datafy [`modify`](/resources/api.md#post-api-v1-volumes-volumeid-modify) endpoint with the volume ID of the original volume managed by Datafy (as it appears in the [Datafy app](https://app.datafy.io)). You should call the Datafy API wherever you currently call the AWS `ModifyVolume` API.

The modify request will change the size of the volume. In order to provide your application with access to this new size you need to expand the filesystem as well:

1. Manually - after the modification completes, resize the filesystem like you would any volume.
2. Automatically - pass `expandFilesystem=true` in your modify request and the AutoScaler agent will expand the filesystem for you.

{% hint style="info" %}
A success response means the request was accepted and the modify is in progress, check the size of the volume to confirm that it has completed successfully.
{% endhint %}

### PVCs in Kubernetes

Datafy integrates directly with the [Kubernetes CSI volume expansion](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#expanding-persistent-volumes-claims) flow. Resizing a PersistentVolumeClaim works exactly as it does for any other EBS-backed PVC ~~-~~ edit the PVC's `spec.resources.requests.storage` and the CSI driver applies the change. For autoscaling volumes, Datafy's CSI integration intercepts and handles the resize request.

No additional configuration is required beyond the standard Kubernetes prerequisites for PVC expansion (`allowVolumeExpansion: true` on the StorageClass).

{% hint style="info" %}
Kubernetes retries failed expansion requests indefinitely until they succeed or the PVC's size is edited back. Errors from individual attempts are available in the CSI controller pod logs.
{% endhint %}

{% hint style="warning" %}
Modifying autoscaling volumes works only on attached volumes. If a PVC resize is issued while the underlying volume is detached - for example, during pod rescheduling - the request will fail. The request will be retried by Kubernetes and applied once the volume is reattached.&#x20;
{% endhint %}

## What Happens When A Volume's Size is Modified

Modifying the size of an autoscaling volume will increase its **Original Size** - the size the volume would be without Datafy, as shown in the Datafy app. The **Current Size** will change depending on the state of the volume:

* **If the volume's current size is smaller than its Original Size** - Only the Original Size updates. The autoscaling logic will use the new Original Size as the maximum size when growing the volume as usage increases. In this state, no cooldown limitations apply, and you can modify the volume size at any time.
* **If the volume has already grown to its full size** - The Original Size updates, and the current size increases to keep the volume at full size. This involves modifying the underlying Datafy volumes, so the [AWS cooldown](https://docs.aws.amazon.com/ebs/latest/userguide/modify-volume-requirements.html) applies. A subsequent modify at full size will only succeed once the cooldown has elapsed, or after a [shrink](/how-it-works/how-autoscaler-works.md#shrinking) action (when the underlying volumes are replaced).

#### Interaction With Ongoing Actions

A modify request interrupts any ongoing autoscaling activation, deactivation, or shrink,  so your size change is applied right away: AutoScaler stops the action mid-flight, then applies the modify. To resume the action after the modify completes:

* **Autoscaling Activation** - the volume will return to a non-autoscaling state. Re-enable autoscaling by turning the AutoScale toggle on for the volume, or by [clearing the exception](/volume-lifecycle/autoscaling-rules.md#clearing-exceptions) from autoscaling rules if they apply to the volume.
* **Autoscaling Deactivation** - the volume is still autoscaling. [Deactivate autoscaling](/volume-lifecycle/managing-autoscaling-volumes.md#deactivating-autoscaling) again with the AutoScale toggle or API.
* **Shrink** - the volume stays at its pre-shrink Current Size. No action is needed, shrink will begin again automatically if [conditions](/how-it-works/how-autoscaler-works.md) match.

{% hint style="success" %}
To check whether a volume has an ongoing action before you modify it, use the Optimization Actions table in the [Reports](https://app.datafy.io/reports) page or in the volume's details page.

Ongoing grow actions will be completed before the modify take place.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.datafy.io/volume-lifecycle/modify-a-volumes-parameters.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
