lando / platformsh

The Official Platform.sh Lando Plugin
https://docs.lando.dev/platformsh
GNU General Public License v3.0
6 stars 4 forks source link

Deploy hook fails (permission denied) #177

Open aimfeld opened 1 year ago

aimfeld commented 1 year ago

After upgrading linux mint from 20 to 21, I had to update docker as well (Docker version 20.10.19). After that, I noticed that the deploy hook configured in .platform.app.yaml is not being run when I do a lando rebuild (I'm using lando v3.6.4). I tried downgrading docker to 20.10.18, 20.10.16, and 20.10.13, but the problem persists (earlier docker versions are not avaible for ubuntu jammy it seems). When I lando ssh into the container and run the commands in the deploy hook section manually, my local build works.

I checked the logs in .lando/logs, and I don't any errors or relevant info.

aimfeld commented 1 year ago

When running a verbose rebuild with lando rebuild -y -vvvv, I see a permission denied error when the deploy hook is executed: Permission denied: '/sys/fs/cgroup/systemd/notify/default/tasks'. The error has nothing to do with the specific commands in the deploy hook, it occurs even if I remove the commands.

2022-10-14 07:57:08,017 platformsh.agent.service INFO Executing deploy hook: set -e
cd
# Wait a few seconds until DB container is running, otherwise phinx migrate fails on lando
if [ "$PLATFORM_ENVIRONMENT" = "lando" ]; then echo "Sleeping to wait for DB container..."; sleep 15; fi
vendor/bin/phing run-migrations
vendor/bin/phing clear-data
vendor/bin/doctrine orm:generate-proxies
vendor/bin/phing clear-caches
vendor/bin/phing import-project
vendor/bin/phing reset-accounts

2022-10-14 07:57:08,019 platformsh.agent.service ERROR Deploy hook failed: [Errno 13] Permission denied: '/sys/fs/cgroup/systemd/notify/default/tasks'
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/platformsh_app/service.py", line 1307, in _post_deploy
    self._execute_logged("/var/log/deploy.log", deploy_hook, "default")
  File "/usr/lib/python2.7/dist-packages/platformsh_app/service.py", line 1478, in _execute_logged
    self._execute_logged_child(where, cmd, cgroup_id)
  File "/usr/lib/python2.7/dist-packages/platformsh_app/service.py", line 1451, in _execute_logged_child
    with open("/sys/fs/cgroup/systemd/notify/%s/tasks" % cgroup_id, "wb") as tasks:
  File "/usr/lib/python2.7/dist-packages/platformsh_gevent/__init__.py", line 251, in friendly_open
    return io.open(name, mode=mode, buffering=_cap_bufsize(buffering))
  File "/usr/lib/python2.7/dist-packages/platformsh_gevent/__init__.py", line 83, in io_open
    fileobj = blocking_io_open(file, mode_binary, buffering=0, closefd=closefd)
IOError: [Errno 13] Permission denied: '/sys/fs/cgroup/systemd/notify/default/tasks'
2022-10-14 07:57:08,024 platformsh.agent ERROR Control returned to log_and_load() in child process
{"php": {"scheme": "http", "port": 80}, "http": {"scheme": "http", "port": 80}}2022-10-14 07:57:08,057 platformsh.agent.service ERROR Deploy hook failed: Child #186 exited with non-zero code: 256
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/platformsh_app/service.py", line 1307, in _post_deploy
    self._execute_logged("/var/log/deploy.log", deploy_hook, "default")
  File "/usr/lib/python2.7/dist-packages/platformsh_app/service.py", line 1476, in _execute_logged
    self._execute_logged_parent(pid, cgroup_id)
  File "/usr/lib/python2.7/dist-packages/platformsh_app/service.py", line 1437, in _execute_logged_parent
    raise Exception("Child #%d exited with non-zero code: %d" % (pid, code))
Exception: Child #186 exited with non-zero code: 256
aimfeld commented 1 year ago

As a workaround, I tried running the code in the platform.sh deploy hook from the lando run build step instead. That doesn't work either, because the platform.sh environment variables (such as PLATFORM_RELATIONSHIPS) are not available in the build step for some reason. Therefore, the DB migrations fail because of missing DB credentials.