How to Resize tenantfs With Error: "field can not be less than previous value"

James Ressler
James Ressler
  • Updated

Author: James Ressler

Date: May 10, 2024

Audience: Everyone

Environmental details: Self-hosted, Replicated - KOTS

Issue

While trying to lower or unset the value in Admin Console > Config > Assets Size, shown below

Screenshot 2024-05-10 at 3.59.00 PM.png

You encounter the following error when redeploying under Deploy Logs > helmStderr:

UPGRADE FAILED: cannot patch "tenantfs" with kind PersistentVolumeClaim: PersistentVolumeClaim "tenantfs" is invalid: spec.resources.requests.storage: Forbidden: field can not be less than previous value

Solution

First, please note that the standard behavior of KOTS prevents reducing the size of a Persistent Volume (PV). Unless you absolutely need to reduce or unset this value, it is recommended that you only increase this value. To reduce the size of the PV, please follow the steps that follow.

Backup Your Tenant Assets

Since we will be deleting the tenantfs Persistent Volume Claim (PVC), there is a chance for data loss if we do not backup the tenant assets first. To backup the tenant assets, 

Exec into the running core-0 pod

kubectl exec -it core-0 -- /bin/bash

Change directories to where your assets are stored

cd /home/contour/tenant/<TENANT-NAME>

Make an archive of the assets

tar -czvf assets.tar.gz avatars/ attachments/ diagrams/ reports/ equations/ tempreports/

Exit your session on the running core-0 pod

exit

Copy the archive off the running core-0 pod

kubectl cp core-0:/home/contour/tenant/<TENANT-NAME>/assets.tar.gz ./assets.tar.gz

Finally, move the archive file off the application server for safety.

Delete the Old tenantfs PVC and Redeploy

Run the following command on the application server to delete the core statefulset and the tenantfs PVC:

kubectl delete sts/core pvc/tenantfs

Redeploy your config with the lowered Asset Size value from the KOTS Admin Console. After the application comes back up, the error in hemlStderror should be gone.

Restore Your Tenant Assets From An Archive File

It may be necessary to restore your assets from the .tar.gz file created earlier. Move the file back onto your application server.

Set the environment variable for your tenant name

export TENANT_NAME=<TENANT-NAME>

Copy the archive file onto the running core-0 pod

kubectl cp -c core /path/to/assets.tar.gz default/core-0:/home/contour/tenant/${TENANT_NAME}/

Unpack the archive file

kubectl exec --tty -c core pods/core-0 -- tar -xvzf /home/contour/tenant/${TENANT_NAME}/assets.tar.gz -C /home/contour/tenant/${TENANT_NAME}/

Change the permissions of the assets directory

kubectl exec --tty -c core pods/core-0 -- chmod -R 755 /home/contour

Change the ownership of the assets directory

kubectl exec --tty -c core pods/core-0 -- chown -R tomcat:tomcat /home/contour

Delete the core statefulset

kubectl delete sts/core

Redeploy the application from the KOTS Admin Console.

Related to

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.