summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2022-08-05 19:19:51 +0200
committerGitHub <noreply@github.com>2022-08-05 19:19:51 +0200
commit65a4125dd0c10c79aea36b5fda214f6bbed00914 (patch)
treebf384581a11a92268d85bdd01bea7469371d99a9 /lib
parentfefab26f01640c476d21ab444db46647f6edc121 (diff)
downloadspack-65a4125dd0c10c79aea36b5fda214f6bbed00914.tar.gz
spack-65a4125dd0c10c79aea36b5fda214f6bbed00914.tar.bz2
spack-65a4125dd0c10c79aea36b5fda214f6bbed00914.tar.xz
spack-65a4125dd0c10c79aea36b5fda214f6bbed00914.zip
spack mirror: skip non-concretizable specs (#31897)
fixes #31736 Catch errors when concretizing specs and report them as debug messages. The corresponding spec is skipped. Co-authored-by: Greg Becker <becker33@llnl.gov>
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/mirror.py24
-rw-r--r--lib/spack/spack/test/mirror.py16
2 files changed, 38 insertions, 2 deletions
diff --git a/lib/spack/spack/mirror.py b/lib/spack/spack/mirror.py
index 1957ef223d..7d352fe5fe 100644
--- a/lib/spack/spack/mirror.py
+++ b/lib/spack/spack/mirror.py
@@ -632,9 +632,26 @@ class MirrorStats(object):
def _add_single_spec(spec, mirror, mirror_stats):
+ """Add a single spec to a mirror.
+
+ Args:
+ spec (spack.spec.Spec): spec to be added. If not concrete it will
+ be concretized.
+ mirror (spack.mirror.Mirror): mirror where to add the spec.
+ mirror_stats (spack.mirror.MirrorStats): statistics on the current mirror
+
+ Return:
+ True if the spec was added successfully, False otherwise
+ """
# Ensure that the spec is concrete, since we'll stage it later
- if not spec.concrete:
- spec = spec.concretized()
+ try:
+ if not spec.concrete:
+ spec = spec.concretized()
+ except Exception as e:
+ msg = "Skipping '{0}', as it fails to concretize [{1}]".format(spec, str(e))
+ tty.debug(msg)
+ mirror_stats.error()
+ return False
tty.msg("Adding package {pkg} to mirror".format(pkg=spec.format("{name}{@version}")))
num_retries = 3
@@ -662,6 +679,9 @@ def _add_single_spec(spec, mirror, mirror_stats):
getattr(exception, "message", exception),
)
mirror_stats.error()
+ return False
+
+ return True
def push_url_from_directory(output_directory):
diff --git a/lib/spack/spack/test/mirror.py b/lib/spack/spack/test/mirror.py
index c156db867c..191cbb9705 100644
--- a/lib/spack/spack/test/mirror.py
+++ b/lib/spack/spack/test/mirror.py
@@ -311,3 +311,19 @@ def test_get_all_versions(specs, expected_specs):
output_list = [str(x) for x in output_list]
# Compare sets since order is not important
assert set(output_list) == set(expected_specs)
+
+
+@pytest.mark.regression("31736")
+def test_non_concretizable_spec_does_not_raise():
+ s = Spec("doesnotexist")
+
+ class Stats(object):
+ called = False
+
+ def error(self):
+ self.called = True
+
+ mirror_stats = Stats()
+ result = spack.mirror._add_single_spec(s, mirror=None, mirror_stats=mirror_stats)
+ assert result is False
+ assert mirror_stats.called is True