* [gentoo-catalyst] snakeoil-0.9.6 removes FsLock
@ 2021-04-30 6:31 Daniel Cordero
0 siblings, 0 replies; only message in thread
From: Daniel Cordero @ 2021-04-30 6:31 UTC (permalink / raw
To: gentoo-catalyst
snakeoil-0.9.6, which has recently been released and stablised in the
tree, removes osutils.FsLock that catalyst uses, causing builds to
fail.
https://github.com/pkgcore/snakeoil/commit/d7c9c2a40fd6fdf7e62d2f041b7dee3765abbf5f
ERROR : CatalystError: Target "stage1" not available.
Traceback (most recent call last):
File "/substrate/master/catalyst/catalyst/main.py", line 78, in build_target
module = import_module(target)
File "/substrate/master/catalyst/catalyst/main.py", line 69, in import_module
module = __import__(mod_name, [], [], ["not empty"])
File "/substrate/master/catalyst/catalyst/targets/stage1.py", line 9, in <module>
from catalyst.base.stagebase import StageBase
File "/substrate/master/catalyst/catalyst/base/stagebase.py", line 28, in <module>
from catalyst.lock import LockDir, LockInUse
File "/substrate/master/catalyst/catalyst/lock.py", line 11, in <module>
LockInUse = osutils.LockException
AttributeError: module 'snakeoil.osutils' has no attribute 'LockException'
ERROR:catalyst:CatalystError: Target "stage1" not available.
Traceback (most recent call last):
File "/substrate/master/catalyst/catalyst/main.py", line 78, in build_target
module = import_module(target)
File "/substrate/master/catalyst/catalyst/main.py", line 69, in import_module
module = __import__(mod_name, [], [], ["not empty"])
File "/substrate/master/catalyst/catalyst/targets/stage1.py", line 9, in <module>
from catalyst.base.stagebase import StageBase
File "/substrate/master/catalyst/catalyst/base/stagebase.py", line 28, in <module>
from catalyst.lock import LockDir, LockInUse
File "/substrate/master/catalyst/catalyst/lock.py", line 11, in <module>
LockInUse = osutils.LockException
AttributeError: module 'snakeoil.osutils' has no attribute 'LockException'
Traceback (most recent call last):
File "/substrate/master/catalyst/catalyst/main.py", line 78, in build_target
module = import_module(target)
File "/substrate/master/catalyst/catalyst/main.py", line 69, in import_module
module = __import__(mod_name, [], [], ["not empty"])
File "/substrate/master/catalyst/catalyst/targets/stage1.py", line 9, in <module>
from catalyst.base.stagebase import StageBase
File "/substrate/master/catalyst/catalyst/base/stagebase.py", line 28, in <module>
from catalyst.lock import LockDir, LockInUse
File "/substrate/master/catalyst/catalyst/lock.py", line 11, in <module>
LockInUse = osutils.LockException
AttributeError: module 'snakeoil.osutils' has no attribute 'LockException'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/substrate/master/catalyst/bin/catalyst", line 27, in <module>
main(sys.argv[1:])
File "/substrate/master/catalyst/catalyst/main.py", line 256, in main
return _main(parser, opts)
File "/substrate/master/catalyst/catalyst/main.py", line 366, in _main
success = build_target(addlargs)
File "/substrate/master/catalyst/catalyst/main.py", line 81, in build_target
raise CatalystError(
catalyst.support.CatalystError: Target "stage1" not available.
The following patch just removes all of the locks and resolves the issue for me,
but I'm sure locking was added for a reason and affects other users.
---
catalyst/base/clearbase.py | 2 --
catalyst/base/stagebase.py | 7 ------
catalyst/lock.py | 58 ----------------------------------------------
3 files changed, 67 deletions(-)
diff --git a/catalyst/base/clearbase.py b/catalyst/base/clearbase.py
index dcf6c523..6218330e 100644
--- a/catalyst/base/clearbase.py
+++ b/catalyst/base/clearbase.py
@@ -27,12 +27,10 @@ class ClearBase():
self.resume.clear_all(remove=True)
def clear_chroot(self):
- self.chroot_lock.unlock()
log.notice('Clearing the chroot path ...')
clear_dir(self.settings["chroot_path"], mode=0o755)
def remove_chroot(self):
- self.chroot_lock.unlock()
log.notice('Removing the chroot path ...')
clear_dir(self.settings["chroot_path"], mode=0o755, remove=True)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 448d6265..4959bab3 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -25,7 +25,6 @@ from catalyst.support import (CatalystError, file_locate, normpath,
from catalyst.base.targetbase import TargetBase
from catalyst.base.clearbase import ClearBase
from catalyst.base.genbase import GenBase
-from catalyst.lock import LockDir, LockInUse
from catalyst.fileops import ensure_dirs, clear_dir, clear_path
from catalyst.base.resume import AutoResume
@@ -36,9 +35,6 @@ def run_sequence(sequence):
sys.stdout.flush()
try:
func()
- except LockInUse:
- log.error('Unable to aquire the lock...')
- return False
except Exception:
log.error('Exception running action sequence %s',
func.__name__, exc_info=True)
@@ -478,7 +474,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
"""
self.settings["chroot_path"] = normpath(self.settings["storedir"] +
"/tmp/" + self.settings["target_subpath"].rstrip('/'))
- self.chroot_lock = LockDir(self.settings["chroot_path"])
def set_autoresume_path(self):
self.settings["autoresume_path"] = normpath(pjoin(
@@ -1366,8 +1361,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
pass
def run(self):
- self.chroot_lock.write_lock()
-
if "clear-autoresume" in self.settings["options"]:
self.clear_autoresume()
diff --git a/catalyst/lock.py b/catalyst/lock.py
deleted file mode 100644
index e31745b2..00000000
--- a/catalyst/lock.py
+++ /dev/null
@@ -1,58 +0,0 @@
-
-import os
-
-from contextlib import contextmanager
-
-from snakeoil import fileutils
-from snakeoil import osutils
-from catalyst.fileops import ensure_dirs
-
-
-LockInUse = osutils.LockException
-
-class Lock:
- """
- A fnctl-based filesystem lock
- """
- def __init__(self, lockfile):
- fileutils.touch(lockfile, mode=0o664)
- os.chown(lockfile, uid=-1, gid=250)
- self.lock = osutils.FsLock(lockfile)
-
- def read_lock(self):
- self.lock.acquire_read_lock()
-
- def write_lock(self):
- self.lock.acquire_write_lock()
-
- def unlock(self):
- # Releasing a write lock is the same as a read lock.
- self.lock.release_write_lock()
-
-class LockDir(Lock):
- """
- A fnctl-based filesystem lock in a directory
- """
- def __init__(self, lockdir):
- ensure_dirs(lockdir)
- lockfile = os.path.join(lockdir, '.catalyst_lock')
-
- Lock.__init__(self, lockfile)
-
-@contextmanager
-def read_lock(filename):
- lock = Lock(filename)
- lock.read_lock()
- try:
- yield
- finally:
- lock.unlock()
-
-@contextmanager
-def write_lock(filename):
- lock = Lock(filename)
- lock.write_lock()
- try:
- yield
- finally:
- lock.unlock()
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-30 6:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-30 6:31 [gentoo-catalyst] snakeoil-0.9.6 removes FsLock Daniel Cordero
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox