cloudfoundry / python-buildpack

Cloud Foundry buildpack for the Python Language
http://docs.cloudfoundry.org/buildpacks/
Apache License 2.0
119 stars 277 forks source link

`No such file or directory` during app start #800

Closed johha closed 2 months ago

johha commented 1 year ago

I have a python web application which is pushed with cf push -f manifest.yml --strategy rolling. The app has the following structure:

<repo-root>
├── Procfile
├── app
│   ├── app.py
│   └── common.py
├── manifest.yml
├── pyproject.toml
├── requirements.txt
└── runtime.txt

Profile

web: python app/app.py

runtime.txt

python-3.10.x

manifest.yml

applications:
- buildpacks:
  - python_buildpack
  disk_quota: 1GB
  env:
    DEBUG: false
  health-check-http-endpoint: /
  health-check-invocation-timeout: 10
  health-check-type: http
  instances: 1
  memory: 1GB
  name: monitor-app
  routes:
  - route: monitor-app.<my-domain>
  stack: cflinuxfs4

This app has been running like this for multiple months. Recently I renamed the app directory to src including updating the Procfile (web: python src/app.py). I was able to push the app with the changes on multiple foundations BUT on some foundations cf push -f manifest.yml --strategy rolling failed with errors like: can't open file '/home/vcap/app/./app/app.py': [Errno 2] No such file or directory can't open file '/home/vcap/app/app/app.py': [Errno 2] No such file or directory.

Obviously the path for app.py is wrong and should contain src. Unfortunately I wasn't able to reproduce the issue. I could work around the issue by renaming src back to app. ¯_(ツ)_/¯

Question: Why is the app.py path wrong? I could also imagine that this is caused by Diego or CAPI but maybe you have some hints what to look out for.

What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version?

robdimsdale commented 1 year ago

Honestly I have no idea. It sounds like some sort of caching issue - there are some stale references to the previous directory inside CF. I don't see any hard-coded references to app or src inside of this buildpack.

I'd probably proceed by ruling out caching - using a strategy other than rolling, pushing new apps with a src directory and trying to revert to app, picking completely different names for the directories to ensure there's no magic going on, etc.

robdimsdale commented 2 months ago

I'm going to close this out as there's been no response in over a year.