cloudfoundry / php-buildpack

A Cloud Foundry Buildpack for PHP.
Apache License 2.0
142 stars 346 forks source link

Directory symlinks are not moved properly and throwing an OSError #604

Closed bcubk closed 1 year ago

bcubk commented 2 years ago

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?

{
   "api_version": "2.166.0",
   "osbapi_version": "2.15",
}

cf version 6.53.0+8e2b70a4a.2020-10-01

What version of the buildpack you are using?

php_buildpack-cached-cflinuxfs3-v4.4.56.zip

If you were attempting to accomplish a task, what was it you were attempting to do?

cf push -f manifest.yml

What did you expect to happen?

That my app is deployed on CF with all sources and directory symlinks

What was the actual behavior?

Deployment failed with following error log:

2022-02-21T09:25:19.11+0100 [API/0] OUT Updated app with guid ebdf2ad5-3407-4bd8-b3ef-d9d90096bd0d ({"state"=>"STOPPED"})
   2022-02-21T09:25:19.35+0100 [API/0] OUT Creating build for app with guid ebdf2ad5-3407-4bd8-b3ef-d9d90096bd0d
   2022-02-21T09:25:19.80+0100 [API/0] OUT Updated app with guid ebdf2ad5-3407-4bd8-b3ef-d9d90096bd0d ({"state"=>"STARTED"})
   2022-02-21T09:25:19.81+0100 [STG/0] OUT Downloading php_buildpack...
   2022-02-21T09:25:19.87+0100 [STG/0] OUT Downloaded php_buildpack
   2022-02-21T09:25:19.87+0100 [STG/0] OUT Cell 10eb0039-d601-4cd0-ab97-1dcbef3fbdcf creating container for instance 0245f5e5-bc65-4c25-ba7c-d92637be930d
   2022-02-21T09:25:20.20+0100 [STG/0] OUT Cell 10eb0039-d601-4cd0-ab97-1dcbef3fbdcf successfully created container for instance 0245f5e5-bc65-4c25-ba7c-d92637be930d
   2022-02-21T09:25:20.37+0100 [STG/0] OUT Downloading build artifacts cache...
   2022-02-21T09:25:20.37+0100 [STG/0] OUT Downloading app package...
   2022-02-21T09:25:20.44+0100 [STG/0] OUT Downloaded build artifacts cache (216B)
   2022-02-21T09:25:21.03+0100 [STG/0] OUT Downloaded app package (13.2M)
   2022-02-21T09:25:21.12+0100 [STG/0] OUT -------> Buildpack version 4.4.55
   2022-02-21T09:25:21.95+0100 [STG/0] ERR Traceback (most recent call last):
   2022-02-21T09:25:21.95+0100 [STG/0] ERR   File "/tmp/buildpacks/f355b313dbac5d42c24291e3843fe85d/scripts/compile.py", line 32, in <module>
   2022-02-21T09:25:21.95+0100 [STG/0] ERR     .method(setup_webdir_if_it_doesnt_exist)
   2022-02-21T09:25:21.95+0100 [STG/0] ERR   File "/tmp/buildpacks/f355b313dbac5d42c24291e3843fe85d/lib/build_pack_utils/builder.py", line 516, in method
   2022-02-21T09:25:21.95+0100 [STG/0] ERR     execute(self.builder._ctx)
   2022-02-21T09:25:21.95+0100 [STG/0] ERR   File "/tmp/buildpacks/f355b313dbac5d42c24291e3843fe85d/lib/compile_helpers.py", line 64, in setup_webdir_if_it_doesnt_exist
   2022-02-21T09:25:21.95+0100 [STG/0] ERR     fu.done()
   2022-02-21T09:25:21.95+0100 [STG/0] ERR   File "/tmp/buildpacks/f355b313dbac5d42c24291e3843fe85d/lib/build_pack_utils/builder.py", line 644, in done
   2022-02-21T09:25:21.95+0100 [STG/0] ERR     os.rmdir(dirPath)
   2022-02-21T09:25:21.95+0100 [STG/0] ERR OSError: [Errno 20] Not a directory: '/tmp/app/web/404'
   2022-02-21T09:25:21.96+0100 [STG/0] ERR Failed to compile droplet: Failed to run finalize script: exit status 1
   2022-02-21T09:25:21.97+0100 [STG/0] OUT Exit status 223
   2022-02-21T09:25:22.28+0100 [STG/0] OUT Cell 10eb0039-d601-4cd0-ab97-1dcbef3fbdcf stopping instance 0245f5e5-bc65-4c25-ba7c-d92637be930d
   2022-02-21T09:25:22.28+0100 [STG/0] OUT Cell 10eb0039-d601-4cd0-ab97-1dcbef3fbdcf destroying container for instance 0245f5e5-bc65-4c25-ba7c-d92637be930d
   2022-02-21T09:25:22.39+0100 [API/0] ERR Failed to stage build: staging failed
   2022-02-21T09:25:22.66+0100 [STG/0] OUT Cell 10eb0039-d601-4cd0-ab97-1dcbef3fbdcf successfully destroyed container for instance 0245f5e5-bc65-4c25-ba7c-d92637be930d
   2022-02-21T09:25:24.67+0100 [CELL/SSHD/0] OUT Exit status 0
   2022-02-21T09:25:35.68+0100 [CELL/0] OUT Cell 10eb0039-d601-4cd0-ab97-1dcbef3fbdcf destroying container for instance 4eb5ffb7-b4e9-4d29-7432-d1cd
   2022-02-21T09:25:35.87+0100 [PROXY/0] OUT Exit status 137
   2022-02-21T09:25:36.00+0100 [CELL/0] OUT Cell 10eb0039-d601-4cd0-ab97-1dcbef3fbdcf successfully destroyed container for instance 4eb5ffb7-b4e9-4d29-7432-d1cd

Steps to reproduce:

1) Create project with following structure:

|-- mainfest.yml
`-- web
    |-- 404 -> www.some.app
    |-- index.html
    `-- www.some.app
        `-- index.html

2) The manifest file includes basic settings:

applications:
  - buildpacks: 
      - php_buildpack
    name: symlink-test
    memory: 1G
    random-route: true

2) Deploy it with cf push -f manifest.yml

Please confirm where necessary:

arjun024 commented 2 years ago

I believe all your symlink targets should be within the root app directory (outside which buildpacks have no visibility). Can you try that?