Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error message if batou is already running #446

Closed
frlan opened this issue Mar 25, 2024 · 2 comments
Closed

Better error message if batou is already running #446

frlan opened this issue Mar 25, 2024 · 2 comments
Milestone

Comments

@frlan
Copy link
Member

frlan commented Mar 25, 2024

I was running a deployment in shell 1 and wanted to start a second one in shell 2

./batou deploy -P production
batou/2.4.1 (cpython 3.11.8-final0, Darwin 23.4.0 arm64)
Could not acquire lock .batou-lock
Traceback (most recent call last):
  File "/Users/me/myprj/.appenv/a2ac3148/lib/python3.11/site-packages/batou/utils.py", line 71, in locked
    fcntl.lockf(lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
BlockingIOError: [Errno 35] Resource temporarily unavailable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/me/myprj/./.appenv/a2ac3148/bin/batou", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/me/myprj/.appenv/a2ac3148/lib/python3.11/site-packages/batou/main.py", line 221, in main
    return args.func(**func_args)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/me/myprj/.appenv/a2ac3148/lib/python3.11/site-packages/batou/deploy.py", line 364, in main
    with locked(".batou-lock"):
  File "/Users/flanitz/.nix-profile/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/Users/me/myprj/.appenv/a2ac3148/lib/python3.11/site-packages/batou/utils.py", line 74, in locked
    raise RuntimeError(
RuntimeError: ('cannot create lock "<_io.TextIOWrapper name=\'.batou-lock\' mode=\'a+\' encoding=\'UTF-8\'>": more than one instance running concurrently?', <_io.TextIOWrapper name='.batou-lock' mode='a+' encoding='UTF-8'>)
@zagy zagy added this to the batou 2.6 milestone Apr 26, 2024
@elikoga
Copy link
Member

elikoga commented Aug 13, 2024

Currently, batou is locking the deployment host, so that only one pid can deploy the project on a host. Since frlan wanted to deploy two projects at the same time, the lock mechanism seems to be too restrictive.

We are currently locking on the deployment host, so that only one pid can deploy the project on a host. We are not locking on the target systems, and also not environment-granular.

What should be the semantics of the lock mechanism? I think a good design would be a lock per environment, so that only one deployment can run in an environment at a time, as well as a lock per target system, so that only one deployment can run on a target system at a time, which is #450

@frlan
Copy link
Member Author

frlan commented Aug 20, 2024

This report was intended not about the locking itself but of the handling of the (expected) exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants