public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
From: Daniel Cordero <gentoo.catalyst@xxoo.ws>
To: gentoo-catalyst@lists.gentoo.org
Subject: [gentoo-catalyst] snakeoil-0.9.6 removes FsLock
Date: Fri, 30 Apr 2021 06:31:31 +0000	[thread overview]
Message-ID: <YIukQ4obSsObti13@pulsar.localdomain> (raw)

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()


                 reply	other threads:[~2021-04-30  6:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YIukQ4obSsObti13@pulsar.localdomain \
    --to=gentoo.catalyst@xxoo.ws \
    --cc=gentoo-catalyst@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox