What do I do if data cannot be written to a non-/tmp directory?
In most cases, data cannot be written to a non-/tmp directory because the function instance is started by a non-root user. Two configurations can cause a function instance to start as a non-root user:
The function was created before August 2022.
The Apsara File Storage NAS (NAS) configuration uses a non-root user ID or user group ID.
Cause 1: Function created before August 2022
Functions created before August 2022 run as a non-root user with a user ID (UID) of 10000 or higher by default. Because the file system is owned by root, writes to non-/tmp directories fail.
For details on when this default changed, see August 2022 release notes.
Solution
Create a new function and migrate your code and configurations to it. New functions run as root (UID=0) by default and can write to all directories.
Cause 2: NAS configuration uses a non-root user ID or user group ID
When you mount a NAS file system, Function Compute starts the function instance using the user ID and user group ID specified in the NAS configuration. If either value is non-zero, the instance runs as a non-root user and cannot write to non-/tmp directories.
Solution
In the NAS configuration, set the user ID to root (UID=0) and the user group ID to root group (GID=0). This makes function instances run as root and grants write access to all directories.
For configuration steps, see Configure a NAS file system.