Permission denied when writing a file to the filesystem in Python

Issue Summary: Flask App Failing to Write Protobuf File Post-Update

Environment: Flask application
Affected Component: File writing operation
File Path: ./ingest/<filename>.pb
Issue Start Date: Two days ago following an update

Description

Our Flask application, which has been running smoothly for months, recently encountered an issue where it fails to write a protobuf file to a designated path (./ingest/<filename>.pb). This problem surfaced after an update was deployed two days ago. It’s critical to note that the update did not modify any functionality related to file writing operations.

Error Encountered

When attempting to write the protobuf file, the application logs the following error:

ERROR - Unexpected error: [Errno 13] Permission denied: 'ingest/20552478.pb'

Troubleshooting Steps Taken

  1. Manual File Creation: SSH was used to access the machine, and an attempt to manually create the file at the specified path succeeded without any issues.

  2. Permission Adjustment: Changed the folder’s permissions to chmod 777. Despite this adjustment, the error persisted, indicating that permission settings might not be the root cause.

Request for Assistance

We urgently require assistance to resolve this issue as it impacts our application’s functionality. Any insights or recommendations on how to troubleshoot or fix this problem would be greatly appreciated.

My Fly.toml file

primary_region = "ams"

[build]
  builder = "paketobuildpacks/builder:base"
  
[processes]
  app = "python -m gunicorn app:app --timeout 90 --access-logfile '-'"

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 2
  processes = ["app"]

Additional Notes

  • The issue only appeared after a recent update, which did not alter the file writing logic.
  • Adjusting folder permissions did not resolve the error.
  • Manual file creation via SSH does not encounter the same permission issue.

Thank you for your prompt attention to this matter.

In the past 24 hours we have had three reports of permission denied results after a deploy where minimal and unrelated changes were made to their application.

The common thread: each was using a buildpack. If nothing else materially changed, it is quite possible that the change was in the buildpack. If this is urgent, seeking out the authors of the buildpack might be worthwhile.

I would recommend exploring a Dockerfile. The following will get you started: https://community.fly.io/t/flask-app-deploy-error-smoke-checks-error-app-crashing/18487/5 . If you have any questions, you can ask them here.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.