1 |
snakeoil-0.9.6, which has recently been released and stablised in the |
2 |
tree, removes osutils.FsLock that catalyst uses, causing builds to |
3 |
fail. |
4 |
|
5 |
https://github.com/pkgcore/snakeoil/commit/d7c9c2a40fd6fdf7e62d2f041b7dee3765abbf5f |
6 |
|
7 |
ERROR : CatalystError: Target "stage1" not available. |
8 |
Traceback (most recent call last): |
9 |
File "/substrate/master/catalyst/catalyst/main.py", line 78, in build_target |
10 |
module = import_module(target) |
11 |
File "/substrate/master/catalyst/catalyst/main.py", line 69, in import_module |
12 |
module = __import__(mod_name, [], [], ["not empty"]) |
13 |
File "/substrate/master/catalyst/catalyst/targets/stage1.py", line 9, in <module> |
14 |
from catalyst.base.stagebase import StageBase |
15 |
File "/substrate/master/catalyst/catalyst/base/stagebase.py", line 28, in <module> |
16 |
from catalyst.lock import LockDir, LockInUse |
17 |
File "/substrate/master/catalyst/catalyst/lock.py", line 11, in <module> |
18 |
LockInUse = osutils.LockException |
19 |
AttributeError: module 'snakeoil.osutils' has no attribute 'LockException' |
20 |
ERROR:catalyst:CatalystError: Target "stage1" not available. |
21 |
Traceback (most recent call last): |
22 |
File "/substrate/master/catalyst/catalyst/main.py", line 78, in build_target |
23 |
module = import_module(target) |
24 |
File "/substrate/master/catalyst/catalyst/main.py", line 69, in import_module |
25 |
module = __import__(mod_name, [], [], ["not empty"]) |
26 |
File "/substrate/master/catalyst/catalyst/targets/stage1.py", line 9, in <module> |
27 |
from catalyst.base.stagebase import StageBase |
28 |
File "/substrate/master/catalyst/catalyst/base/stagebase.py", line 28, in <module> |
29 |
from catalyst.lock import LockDir, LockInUse |
30 |
File "/substrate/master/catalyst/catalyst/lock.py", line 11, in <module> |
31 |
LockInUse = osutils.LockException |
32 |
AttributeError: module 'snakeoil.osutils' has no attribute 'LockException' |
33 |
Traceback (most recent call last): |
34 |
File "/substrate/master/catalyst/catalyst/main.py", line 78, in build_target |
35 |
module = import_module(target) |
36 |
File "/substrate/master/catalyst/catalyst/main.py", line 69, in import_module |
37 |
module = __import__(mod_name, [], [], ["not empty"]) |
38 |
File "/substrate/master/catalyst/catalyst/targets/stage1.py", line 9, in <module> |
39 |
from catalyst.base.stagebase import StageBase |
40 |
File "/substrate/master/catalyst/catalyst/base/stagebase.py", line 28, in <module> |
41 |
from catalyst.lock import LockDir, LockInUse |
42 |
File "/substrate/master/catalyst/catalyst/lock.py", line 11, in <module> |
43 |
LockInUse = osutils.LockException |
44 |
AttributeError: module 'snakeoil.osutils' has no attribute 'LockException' |
45 |
|
46 |
The above exception was the direct cause of the following exception: |
47 |
|
48 |
Traceback (most recent call last): |
49 |
File "/substrate/master/catalyst/bin/catalyst", line 27, in <module> |
50 |
main(sys.argv[1:]) |
51 |
File "/substrate/master/catalyst/catalyst/main.py", line 256, in main |
52 |
return _main(parser, opts) |
53 |
File "/substrate/master/catalyst/catalyst/main.py", line 366, in _main |
54 |
success = build_target(addlargs) |
55 |
File "/substrate/master/catalyst/catalyst/main.py", line 81, in build_target |
56 |
raise CatalystError( |
57 |
catalyst.support.CatalystError: Target "stage1" not available. |
58 |
|
59 |
The following patch just removes all of the locks and resolves the issue for me, |
60 |
but I'm sure locking was added for a reason and affects other users. |
61 |
|
62 |
--- |
63 |
catalyst/base/clearbase.py | 2 -- |
64 |
catalyst/base/stagebase.py | 7 ------ |
65 |
catalyst/lock.py | 58 ---------------------------------------------- |
66 |
3 files changed, 67 deletions(-) |
67 |
|
68 |
diff --git a/catalyst/base/clearbase.py b/catalyst/base/clearbase.py |
69 |
index dcf6c523..6218330e 100644 |
70 |
--- a/catalyst/base/clearbase.py |
71 |
+++ b/catalyst/base/clearbase.py |
72 |
@@ -27,12 +27,10 @@ class ClearBase(): |
73 |
self.resume.clear_all(remove=True) |
74 |
|
75 |
def clear_chroot(self): |
76 |
- self.chroot_lock.unlock() |
77 |
log.notice('Clearing the chroot path ...') |
78 |
clear_dir(self.settings["chroot_path"], mode=0o755) |
79 |
|
80 |
def remove_chroot(self): |
81 |
- self.chroot_lock.unlock() |
82 |
log.notice('Removing the chroot path ...') |
83 |
clear_dir(self.settings["chroot_path"], mode=0o755, remove=True) |
84 |
|
85 |
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py |
86 |
index 448d6265..4959bab3 100644 |
87 |
--- a/catalyst/base/stagebase.py |
88 |
+++ b/catalyst/base/stagebase.py |
89 |
@@ -25,7 +25,6 @@ from catalyst.support import (CatalystError, file_locate, normpath, |
90 |
from catalyst.base.targetbase import TargetBase |
91 |
from catalyst.base.clearbase import ClearBase |
92 |
from catalyst.base.genbase import GenBase |
93 |
-from catalyst.lock import LockDir, LockInUse |
94 |
from catalyst.fileops import ensure_dirs, clear_dir, clear_path |
95 |
from catalyst.base.resume import AutoResume |
96 |
|
97 |
@@ -36,9 +35,6 @@ def run_sequence(sequence): |
98 |
sys.stdout.flush() |
99 |
try: |
100 |
func() |
101 |
- except LockInUse: |
102 |
- log.error('Unable to aquire the lock...') |
103 |
- return False |
104 |
except Exception: |
105 |
log.error('Exception running action sequence %s', |
106 |
func.__name__, exc_info=True) |
107 |
@@ -478,7 +474,6 @@ class StageBase(TargetBase, ClearBase, GenBase): |
108 |
""" |
109 |
self.settings["chroot_path"] = normpath(self.settings["storedir"] + |
110 |
"/tmp/" + self.settings["target_subpath"].rstrip('/')) |
111 |
- self.chroot_lock = LockDir(self.settings["chroot_path"]) |
112 |
|
113 |
def set_autoresume_path(self): |
114 |
self.settings["autoresume_path"] = normpath(pjoin( |
115 |
@@ -1366,8 +1361,6 @@ class StageBase(TargetBase, ClearBase, GenBase): |
116 |
pass |
117 |
|
118 |
def run(self): |
119 |
- self.chroot_lock.write_lock() |
120 |
- |
121 |
if "clear-autoresume" in self.settings["options"]: |
122 |
self.clear_autoresume() |
123 |
|
124 |
diff --git a/catalyst/lock.py b/catalyst/lock.py |
125 |
deleted file mode 100644 |
126 |
index e31745b2..00000000 |
127 |
--- a/catalyst/lock.py |
128 |
+++ /dev/null |
129 |
@@ -1,58 +0,0 @@ |
130 |
- |
131 |
-import os |
132 |
- |
133 |
-from contextlib import contextmanager |
134 |
- |
135 |
-from snakeoil import fileutils |
136 |
-from snakeoil import osutils |
137 |
-from catalyst.fileops import ensure_dirs |
138 |
- |
139 |
- |
140 |
-LockInUse = osutils.LockException |
141 |
- |
142 |
-class Lock: |
143 |
- """ |
144 |
- A fnctl-based filesystem lock |
145 |
- """ |
146 |
- def __init__(self, lockfile): |
147 |
- fileutils.touch(lockfile, mode=0o664) |
148 |
- os.chown(lockfile, uid=-1, gid=250) |
149 |
- self.lock = osutils.FsLock(lockfile) |
150 |
- |
151 |
- def read_lock(self): |
152 |
- self.lock.acquire_read_lock() |
153 |
- |
154 |
- def write_lock(self): |
155 |
- self.lock.acquire_write_lock() |
156 |
- |
157 |
- def unlock(self): |
158 |
- # Releasing a write lock is the same as a read lock. |
159 |
- self.lock.release_write_lock() |
160 |
- |
161 |
-class LockDir(Lock): |
162 |
- """ |
163 |
- A fnctl-based filesystem lock in a directory |
164 |
- """ |
165 |
- def __init__(self, lockdir): |
166 |
- ensure_dirs(lockdir) |
167 |
- lockfile = os.path.join(lockdir, '.catalyst_lock') |
168 |
- |
169 |
- Lock.__init__(self, lockfile) |
170 |
- |
171 |
-@contextmanager |
172 |
-def read_lock(filename): |
173 |
- lock = Lock(filename) |
174 |
- lock.read_lock() |
175 |
- try: |
176 |
- yield |
177 |
- finally: |
178 |
- lock.unlock() |
179 |
- |
180 |
-@contextmanager |
181 |
-def write_lock(filename): |
182 |
- lock = Lock(filename) |
183 |
- lock.write_lock() |
184 |
- try: |
185 |
- yield |
186 |
- finally: |
187 |
- lock.unlock() |