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

remove deprecated --wait-on-lock option #4239

Merged
merged 3 commits into from
Apr 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion easybuild/tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
'test_report_env_filter',
'testoutput',
'umask',
'wait_on_lock',
'zip_logs',
],
False: [
Expand Down
21 changes: 2 additions & 19 deletions easybuild/tools/filetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@
from easybuild.tools import run
# import build_log must stay, to use of EasyBuildLog
from easybuild.tools.build_log import EasyBuildError, dry_run_msg, print_msg, print_warning
from easybuild.tools.config import DEFAULT_WAIT_ON_LOCK_INTERVAL, ERROR, GENERIC_EASYBLOCK_PKG, IGNORE, WARN
from easybuild.tools.config import build_option, install_path
from easybuild.tools.config import ERROR, GENERIC_EASYBLOCK_PKG, IGNORE, WARN, build_option, install_path
from easybuild.tools.output import PROGRESS_BAR_DOWNLOAD_ONE, start_progress_bar, stop_progress_bar, update_progress_bar
from easybuild.tools.utilities import natural_keys, nub, remove_unwanted_chars, trace_msg

Expand Down Expand Up @@ -1963,7 +1962,7 @@ def check_lock(lock_name):
Check whether a lock with specified name already exists.

If it exists, either wait until it's released, or raise an error
(depending on --wait-on-lock configuration option).
(depending on --wait-on-lock-* configuration option).
"""
lock_path = det_lock_path(lock_name)
if os.path.exists(lock_path):
Expand All @@ -1972,22 +1971,6 @@ def check_lock(lock_name):
wait_interval = build_option('wait_on_lock_interval')
wait_limit = build_option('wait_on_lock_limit')

# --wait-on-lock is deprecated, should use --wait-on-lock-limit and --wait-on-lock-interval instead
wait_on_lock = build_option('wait_on_lock')
if wait_on_lock is not None:
depr_msg = "Use of --wait-on-lock is deprecated, use --wait-on-lock-limit and --wait-on-lock-interval"
_log.deprecated(depr_msg, '5.0')

# if --wait-on-lock-interval has default value and --wait-on-lock is specified too, the latter wins
# (required for backwards compatibility)
if wait_interval == DEFAULT_WAIT_ON_LOCK_INTERVAL and wait_on_lock > 0:
wait_interval = wait_on_lock

# if --wait-on-lock-limit is not specified we need to wait indefinitely if --wait-on-lock is specified,
# since the original semantics of --wait-on-lock was that it specified the waiting time interval (no limit)
if not wait_limit:
wait_limit = -1

# wait limit could be zero (no waiting), -1 (no waiting limit) or non-zero value (waiting limit in seconds)
if wait_limit != 0:
wait_time = 0
Expand Down
4 changes: 0 additions & 4 deletions easybuild/tools/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,6 @@ def override_options(self):
None, 'store_true', False),
'verify-easyconfig-filenames': ("Verify whether filename of specified easyconfigs matches with contents",
None, 'store_true', False),
'wait-on-lock': ("Wait for lock to be released; 0 implies no waiting (exit with an error if the lock "
"already exists), non-zero value specified waiting interval [DEPRECATED: "
"use --wait-on-lock-interval and --wait-on-lock-limit instead]",
int, 'store_or_None', None),
'wait-on-lock-interval': ("Wait interval (in seconds) to use when waiting for existing lock to be removed",
int, 'store', DEFAULT_WAIT_ON_LOCK_INTERVAL),
'wait-on-lock-limit': ("Maximum amount of time (in seconds) to wait until lock is released (0 means no "
Expand Down
18 changes: 2 additions & 16 deletions test/framework/toy_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3476,28 +3476,17 @@ def __exit__(self, type, value, traceback):
signal.alarm(0)

# wait for lock to be removed, with 1 second interval of checking;
# check with both --wait-on-lock-interval and deprecated --wait-on-lock options

wait_regex = re.compile("^== lock .*_software_toy_0.0.lock exists, waiting 1 seconds", re.M)
ok_regex = re.compile("^== COMPLETED: Installation ended successfully", re.M)

test_cases = [
['--wait-on-lock=1'],
['--wait-on-lock=1', '--wait-on-lock-interval=60'],
['--wait-on-lock=100', '--wait-on-lock-interval=1'],
['--wait-on-lock-limit=100', '--wait-on-lock=1'],
['--wait-on-lock-limit=100', '--wait-on-lock-interval=1'],
['--wait-on-lock-limit=-1', '--wait-on-lock=1'],
['--wait-on-lock-limit=-1', '--wait-on-lock-interval=1'],
]

for opts in test_cases:

if any('--wait-on-lock=' in x for x in opts):
self.allow_deprecated_behaviour()
else:
self.disallow_deprecated_behaviour()

if not os.path.exists(toy_lock_path):
mkdir(toy_lock_path)

Expand All @@ -3514,10 +3503,7 @@ def __exit__(self, type, value, traceback):
self.mock_stderr(False)
self.mock_stdout(False)

if any('--wait-on-lock=' in x for x in all_args):
self.assertIn("Use of --wait-on-lock is deprecated", stderr)
else:
self.assertEqual(stderr, '')
self.assertEqual(stderr, '')

wait_matches = wait_regex.findall(stdout)
# we can't rely on an exact number of 'waiting' messages, so let's go with a range...
Expand All @@ -3542,7 +3528,7 @@ def __exit__(self, type, value, traceback):

# when there is no lock in place, --wait-on-lock* has no impact
remove_dir(toy_lock_path)
for opt in ['--wait-on-lock=1', '--wait-on-lock-limit=3', '--wait-on-lock-interval=1']:
for opt in ['--wait-on-lock-limit=3', '--wait-on-lock-interval=1']:
all_args = extra_args + [opt]
self.assertNotExists(toy_lock_path)
self.mock_stderr(True)
Expand Down