Skip to content

Commit a9bc7fd

Browse files
Martin Hatinadmach
authored andcommitted
drop modular locking
1 parent cabd0c3 commit a9bc7fd

File tree

9 files changed

+5
-200
lines changed

9 files changed

+5
-200
lines changed

dnf/cli/commands/module.py

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -153,37 +153,6 @@ def configure(self):
153153
def run_on_module(self):
154154
self.base.repo_module_dict.remove(self.opts.module_nsvp)
155155

156-
class LockSubCommand(SubCommand):
157-
158-
aliases = ("lock",)
159-
160-
def configure(self):
161-
demands = self.cli.demands
162-
demands.available_repos = True
163-
demands.sack_activation = True
164-
demands.root_user = True
165-
166-
def run_on_module(self):
167-
for module_n in self.opts.module_nsvp:
168-
stream, version = self.base.repo_module_dict.lock(module_n, True)
169-
logger.info("'{}' is locked (stream: {}, version: {})"
170-
.format(module_n, stream, version))
171-
172-
class UnlockSubCommand(SubCommand):
173-
174-
aliases = ("unlock",)
175-
176-
def configure(self):
177-
demands = self.cli.demands
178-
demands.available_repos = True
179-
demands.sack_activation = True
180-
demands.root_user = True
181-
182-
def run_on_module(self):
183-
for module_n in self.opts.module_nsvp:
184-
self.base.repo_module_dict.unlock(module_n, True)
185-
logger.info("'{}' is unlocked".format(module_n))
186-
187156
class ProfileInfoSubCommand(SubCommand):
188157

189158
aliases = ("profile", "profile-info")
@@ -225,8 +194,7 @@ def run_on_module(self):
225194

226195
SUBCMDS = {ListSubCommand, InfoSubCommand, EnableSubCommand,
227196
DisableSubCommand, InstallSubCommand, UpdateSubCommand,
228-
RemoveSubCommand, LockSubCommand, UnlockSubCommand,
229-
ProfileInfoSubCommand, StreamsSubCommand, ProvidesSubCommand}
197+
RemoveSubCommand, ProfileInfoSubCommand, StreamsSubCommand, ProvidesSubCommand}
230198

231199
SUBCMDS_NOT_REQUIRED_ARG = {ListSubCommand, StreamsSubCommand}
232200

dnf/conf/config.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,6 @@ def __init__(self, section=None, parser=None):
621621
self.profiles = ListOption([])
622622
# enable/disable a module
623623
self.enabled = BoolOption(True)
624-
# lock module on installed version, don't upgrade or downgrade
625-
self.locked = BoolOption(False)
626624

627625
def _write(self, fileobj):
628626
output = "[{}]\n".format(self._section)
@@ -631,6 +629,5 @@ def _write(self, fileobj):
631629
output += "version = {}\n".format(self.version._get())
632630
output += "profiles = {}\n".format(",".join(self.profiles._get()))
633631
output += "enabled = {}\n".format(self.enabled._get())
634-
output += "locked = {}\n".format(self.locked._get())
635632

636633
fileobj.write(output)

dnf/module/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818

1919
DIFFERENT_STREAM_INFO = 1
2020
NOTHING_TO_SHOW = 2
21-
VERSION_LOCKED = 3
2221
INSTALLING_NEWER_VERSION = 4
2322
ENABLED_MODULES = 5
2423
NO_PROFILE_SPECIFIED = 6
2524

2625
module_messages = {
2726
DIFFERENT_STREAM_INFO: _("Enabling different stream for '{}'."),
2827
NOTHING_TO_SHOW: _("Nothing to show."),
29-
VERSION_LOCKED: _("'{}' is locked to version: {}."),
3028
INSTALLING_NEWER_VERSION: _("Installing newer version of '{}' than specified. Reason: {}"),
3129
ENABLED_MODULES: _("Enabled modules: {}."),
3230
NO_PROFILE_SPECIFIED: _("No profile specified for '{}', please specify profile."),

dnf/module/exceptions.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ def __init__(self, module_spec):
6363
super(DifferentStreamEnabledException, self).__init__(value)
6464

6565

66-
class VersionLockedException(dnf.exceptions.Error):
67-
def __init__(self, module_spec, version):
68-
value = "'{}' is locked to version: {}".format(module_spec, version)
69-
super(VersionLockedException, self).__init__(value)
70-
71-
7266
class CannotLockVersionException(dnf.exceptions.Error):
7367
def __init__(self, module_spec, version, reason=None):
7468
value = "Cannot lock '{}' to version: {}".format(module_spec, version)

dnf/module/repo_module.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def conf(self):
4444
self._conf = ModuleConf(section=self.name, parser=ConfigParser())
4545
self._conf.name._set(self.name)
4646
self._conf.enabled._set(False)
47-
self._conf.locked._set(False)
4847
self._conf.version._set(-1)
4948

5049
return self._conf
@@ -101,12 +100,6 @@ def enable(self, stream, assumeyes=False):
101100
def disable(self):
102101
self.parent.base._module_persistor.set_data(self, enabled=False, profiles=[])
103102

104-
def lock(self, version):
105-
self.parent.base._module_persistor.set_data(self, locked=True, version=version)
106-
107-
def unlock(self):
108-
self.parent.base._module_persistor.set_data(self, locked=False)
109-
110103
def write_conf_to_file(self):
111104
output_file = os.path.join(self.parent.get_modules_dir(),
112105
"%s.module" % self.conf.name._get())

dnf/module/repo_module_dict.py

Lines changed: 4 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323

2424
from dnf.conf.read import ModuleReader
2525
from dnf.module import module_messages, NOTHING_TO_SHOW, \
26-
INSTALLING_NEWER_VERSION, ENABLED_MODULES, VERSION_LOCKED
26+
INSTALLING_NEWER_VERSION, ENABLED_MODULES
2727
from dnf.module.exceptions import NoStreamSpecifiedException, NoModuleException, \
28-
EnabledStreamException, ProfileNotInstalledException, NoProfileToRemoveException, \
29-
VersionLockedException, CannotLockVersionException, \
28+
ProfileNotInstalledException, NoProfileToRemoveException, \
3029
DifferentStreamEnabledException, InstallMultipleStreamsException
3130
from dnf.module.repo_module import RepoModule
3231
from dnf.module.subject import ModuleSubject
@@ -68,16 +67,7 @@ def use_default_stream(repo_module):
6867

6968
repo_module_stream = repo_module[stream]
7069

71-
if repo_module.conf and \
72-
repo_module.conf.locked._get() and \
73-
repo_module.conf.version._get() is not -1:
74-
if repo_module_stream.latest().version != repo_module.conf.version._get():
75-
logger.info(module_messages[VERSION_LOCKED]
76-
.format("{}:{}".format(repo_module.name, stream),
77-
repo_module.conf.version._get()))
78-
79-
repo_module_version = repo_module_stream[repo_module.conf.version._get()]
80-
elif version:
70+
if version:
8171
repo_module_version = repo_module_stream[version]
8272
else:
8373
# if version is not specified, pick the latest
@@ -126,9 +116,6 @@ def get_module_dependency(self, name, stream, visited=None):
126116
repo_module_stream = repo_module[stream]
127117

128118
versions = repo_module_stream.values()
129-
if repo_module.conf.locked._get():
130-
versions = [repo_module_stream[repo_module.conf.version._get()]]
131-
132119
for repo_module_version in versions:
133120
version_dependencies.add(repo_module_version)
134121

@@ -239,72 +226,18 @@ def disable(self, module_spec, save_immediately=False):
239226

240227
repo_module = module_version.repo_module
241228

242-
if repo_module.conf.locked._get():
243-
raise VersionLockedException(module_spec, module_version.version)
244-
245229
repo_module.disable()
246230

247231
if save_immediately:
248232
self.base._module_persistor.commit()
249233
self.base._module_persistor.save()
250234

251-
def lock(self, module_spec, save_immediately=False):
252-
subj = ModuleSubject(module_spec)
253-
module_version, module_form = subj.find_module_version(self)
254-
255-
repo_module = module_version.repo_module
256-
257-
if not repo_module.conf.enabled._get():
258-
raise EnabledStreamException(module_spec)
259-
elif repo_module.conf.locked._get() and \
260-
(repo_module.conf.stream._get() != module_version.stream or
261-
repo_module.conf.version._get() != module_version.version):
262-
raise VersionLockedException(module_spec, module_version.version)
263-
264-
version_to_lock = module_version.version
265-
if list(repo_module.conf.profiles._get()):
266-
version_to_lock = module_version.repo_module.conf.version._get()
267-
repo_module.lock(version_to_lock)
268-
269-
if module_form.version and version_to_lock != module_form.version:
270-
raise CannotLockVersionException(module_spec, module_form.version,
271-
"Different version installed.")
272-
273-
if save_immediately:
274-
self.base._module_persistor.commit()
275-
self.base._module_persistor.save()
276-
277-
return module_version.stream, version_to_lock
278-
279-
def unlock(self, module_spec, save_immediately=False):
280-
subj = ModuleSubject(module_spec)
281-
module_version, module_form = subj.find_module_version(self)
282-
283-
repo_module = module_version.repo_module
284-
285-
if not repo_module.conf.enabled._get():
286-
raise EnabledStreamException(module_spec)
287-
288-
repo_module.unlock()
289-
290-
if save_immediately:
291-
self.base._module_persistor.commit()
292-
self.base._module_persistor.save()
293-
294-
return module_version.stream, module_version.version
295-
296235
def install(self, module_specs, strict=True):
297236
versions, module_specs = self.get_best_versions(module_specs)
298237

299238
result = False
300239
for module_version, profiles, default_profiles in versions.values():
301240
conf = module_version.repo_module.conf
302-
if conf.locked._get() and conf.version._get() != module_version.version:
303-
logger.warning(module_messages[VERSION_LOCKED]
304-
.format(module_version.name,
305-
module_version.repo_module.conf.version._get()))
306-
continue
307-
308241
self.enable("{}:{}".format(module_version.name, module_version.stream))
309242

310243
self.base.sack.reset_module_excludes()
@@ -393,8 +326,6 @@ def upgrade(self, module_specs, create_goal=False):
393326
except NoStreamSpecifiedException:
394327
continue
395328

396-
if module_version.repo_module.conf.locked._get():
397-
continue
398329
if not module_version.repo_module.conf.enabled._get():
399330
for rpm in module_version.artifacts():
400331
query_for_rpm = self.base.sack.query().filter(nevra=rpm)
@@ -723,7 +654,6 @@ def create_and_fill_table(self, versions_by_repo):
723654
defaults_conf = i.repo_module.defaults
724655
default_str = ""
725656
enabled_str = ""
726-
locked_str = ""
727657
profiles_str = ""
728658
available_profiles = i.profiles
729659
installed_profiles = []
@@ -737,8 +667,6 @@ def create_and_fill_table(self, versions_by_repo):
737667
enabled_str += "[e]"
738668

739669
if i.stream == conf.stream._get() and i.version == conf.version._get():
740-
if conf.locked._get():
741-
locked_str = " [l]"
742670
installed_profiles = list(conf.profiles._get())
743671

744672
for profile in available_profiles[:2]:
@@ -750,7 +678,7 @@ def create_and_fill_table(self, versions_by_repo):
750678

751679
line[column_name] = i.name
752680
line[column_stream] = i.stream + default_str + enabled_str
753-
line[column_version] = str(i.version) + locked_str
681+
line[column_version] = str(i.version)
754682
line[column_profiles] = profiles_str
755683
line[column_info] = i.summary()
756684

dnf/module/repo_module_version.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ def __init__(self, module_metadata, base, repo):
3333
def __lt__(self, other):
3434
# for finding latest
3535
assert self.full_stream == other.full_stream
36-
if self.repo_module.conf.locked._get():
37-
return self.version < self.repo_module.conf.version._get()
3836
return self.module_metadata.peek_version() < other.module_metadata.peek_version()
3937

4038
def __repr__(self):

tests/conf/test_module_conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@ def setUp(self):
4141
self.conf.version._set(1)
4242
# profiles - empty list by default
4343
self.conf.enabled._set(1)
44-
self.conf.locked._set(0)
4544

4645
def test_options(self):
4746
self.assertEqual(self.conf.name._get(), "base-runtime")
4847
self.assertEqual(self.conf.stream._get(), "f26")
4948
self.assertEqual(self.conf.version._get(), 1)
5049
self.assertEqual(list(self.conf.profiles._get()), [])
5150
self.assertEqual(self.conf.enabled._get(), True)
52-
self.assertEqual(self.conf.locked._get(), False)
5351

5452
def test_write(self):
5553
tmp_dir = tempfile.mkdtemp()

tests/test_modules.py

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -407,75 +407,6 @@ def test_disable_invalid(self):
407407
with self.assertRaises(dnf.exceptions.Error):
408408
self.base.repo_module_dict.disable("httpd:invalid")
409409

410-
# dnf module lock
411-
412-
def test_lock_name(self):
413-
self.base.repo_module_dict.enable("httpd")
414-
self.base.repo_module_dict.lock("httpd")
415-
repo_module = self.base.repo_module_dict["httpd"]
416-
self.assertTrue(repo_module.conf.locked._get())
417-
self.assertEqual(repo_module.conf.name._get(), "httpd")
418-
self.assertEqual(repo_module.conf.stream._get(), "2.4")
419-
420-
def test_lock_name_stream(self):
421-
self.base.repo_module_dict.enable("httpd:2.4")
422-
self.base.repo_module_dict.lock("httpd:2.4")
423-
repo_module = self.base.repo_module_dict["httpd"]
424-
self.assertTrue(repo_module.conf.locked._get())
425-
self.assertEqual(repo_module.conf.name._get(), "httpd")
426-
self.assertEqual(repo_module.conf.stream._get(), "2.4")
427-
428-
def test_lock_pkgspec(self):
429-
self.base.repo_module_dict.enable("httpd:2.4:1/foo")
430-
self.base.repo_module_dict.lock("httpd:2.4:1/foo")
431-
repo_module = self.base.repo_module_dict["httpd"]
432-
self.assertTrue(repo_module.conf.locked._get())
433-
self.assertEqual(repo_module.conf.name._get(), "httpd")
434-
self.assertEqual(repo_module.conf.stream._get(), "2.4")
435-
436-
def test_lock_invalid(self):
437-
with self.assertRaises(dnf.exceptions.Error):
438-
self.base.repo_module_dict.lock("httpd:invalid")
439-
440-
# dnf module unlock
441-
442-
def test_unlock_name(self):
443-
self.base.repo_module_dict.enable("httpd")
444-
self.base.repo_module_dict.lock("httpd")
445-
446-
self.base.repo_module_dict.unlock("httpd")
447-
repo_module = self.base.repo_module_dict["httpd"]
448-
self.assertFalse(repo_module.conf.locked._get())
449-
self.assertEqual(repo_module.conf.name._get(), "httpd")
450-
self.assertEqual(repo_module.conf.stream._get(), "2.4")
451-
self.assertEqual(repo_module.conf.version._get(), 2)
452-
453-
def test_unlock_name_stream(self):
454-
self.base.repo_module_dict.enable("httpd:2.4")
455-
self.base.repo_module_dict.lock("httpd:2.4")
456-
457-
self.base.repo_module_dict.unlock("httpd:2.4")
458-
repo_module = self.base.repo_module_dict["httpd"]
459-
self.assertFalse(repo_module.conf.locked._get())
460-
self.assertEqual(repo_module.conf.name._get(), "httpd")
461-
self.assertEqual(repo_module.conf.stream._get(), "2.4")
462-
self.assertEqual(repo_module.conf.version._get(), 2)
463-
464-
def test_unlock_pkgspec(self):
465-
self.base.repo_module_dict.enable("httpd:2.4:1/foo")
466-
self.base.repo_module_dict.lock("httpd:2.4:1/foo")
467-
468-
self.base.repo_module_dict.unlock("httpd:2.4:1/foo")
469-
repo_module = self.base.repo_module_dict["httpd"]
470-
self.assertFalse(repo_module.conf.locked._get())
471-
self.assertEqual(repo_module.conf.name._get(), "httpd")
472-
self.assertEqual(repo_module.conf.stream._get(), "2.4")
473-
self.assertEqual(repo_module.conf.version._get(), 1)
474-
475-
def test_unlock_invalid(self):
476-
with self.assertRaises(dnf.exceptions.Error):
477-
self.base.repo_module_dict.unlock("httpd:invalid")
478-
479410
# dnf module info
480411

481412
def test_info_name(self):

0 commit comments

Comments
 (0)