Skip to content

installer.py: don't dereference stage before installing from binaries#41986

Merged
alalazo merged 6 commits intospack:developfrom
haampie:fix/delay-stage
Jan 9, 2024
Merged

installer.py: don't dereference stage before installing from binaries#41986
alalazo merged 6 commits intospack:developfrom
haampie:fix/delay-stage

Conversation

@haampie
Copy link
Copy Markdown
Member

@haampie haampie commented Jan 8, 2024

This fixes an issue where pkg.stage throws because a patch cannot be found,
but the patch is redundant because the spec is reused from a build cache and
will be installed from existing binaries.

@spackbot-app spackbot-app bot added the core PR affects Spack core functionality label Jan 8, 2024
# The subprocess *may* have removed the build stage. Mark it
# not created so that the next time pkg.stage is invoked, we
# check the filesystem for it.
pkg.stage.created = False
Copy link
Copy Markdown
Member Author

@haampie haampie Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant because restage is true by default, so we hit stage.destroy() in BuildProcessInstaller.run().

Necessary to remove, because this path is followed for binary installs too.

tty.debug(f"{task.pkg_id} is partially installed")

# Destroy the stage for a locally installed, non-DIYStage, package
if restage and task.pkg.stage.managed_by_spack:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is moved into BuildProcessInstaller.run() so we don't dereference task.pkg.stage when doing binary installs

@alalazo alalazo mentioned this pull request Jan 8, 2024
36 tasks
@spackbot-app spackbot-app bot added the tests General test capability(ies) label Jan 8, 2024

s.package.do_install(restage=True)
assert rm_prefix_checker.removed
assert s.package.stage.test_destroyed
Copy link
Copy Markdown
Member Author

@haampie haampie Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MockStage is copied to a sub-process and mutated there, so checking s.package.stage properties is completely broken.

I guess the intention of the test was to check whether a previous stage is destroyed before attempting a new build. However, this is broken too, since the stage is always destroyed on a successful install, so it would always pass.

With these changes, we're testing that an install after a partial install works (prefix exists, but it wasn't registered in the db), also it tests that the stage is deleted afterwards (which happens in all tests...). We're not testing whether the previous stage is destroyed before running a new install.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I passed through here while resolving a conflict with #41373, although I don't think there's any conflicts there, I found this comment confusing)

MockStage is copied to a sub-process and mutated there, so checking s.package.stage properties is completely broken.

Before this PR, the stage destruction operations we care about for this test were performed in prepare_for_install (in the parent process). So this PR created the situation you describe (and ideally resolves it). As far as fragility goes: subprocesses are not a major threat to default-false-and-search-for-something-that-set-it-true-style tests.

also it tests that the stage is deleted afterwards (which happens in all tests...).

Hopefully not for --keep-stage tests

We're not testing whether the previous stage is destroyed before running a new install.

That's what this check was intending to test, and what we'd still like to test - is this a current gap in our tests (i.e. to clarify, are you saying this never tested and still doesn't? or are you saying it didn't and now does?).

s.package.stage = MockStage(s.package.stage)
s.package.do_install(keep_prefix=True)
assert s.package.spec.installed
assert not s.package.stage.test_destroyed
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, this property can't be tested. If it's set to true, it would be in a sub-process and we would never know in the test.

@haampie haampie added this to the v0.21.1 milestone Jan 8, 2024
@haampie
Copy link
Copy Markdown
Member Author

haampie commented Jan 8, 2024

I've submitted separate PRs for some bug fixes that were necessary along the way

#41990 #41989

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Jan 8, 2024

Have to check what test_cdash_upload_build_error is about.

Comment on lines +1685 to +1687
# Create stage object now and let it be serialized for the child process. That
# way monkeypatch in tests works correctly.
pkg.stage
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This screams for a later refactor (attribute access with side effects 😮)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but it's effectively pkg.stage()

@alalazo alalazo merged commit d3fb298 into spack:develop Jan 9, 2024
@haampie haampie deleted the fix/delay-stage branch January 9, 2024 16:58
haampie added a commit that referenced this pull request Jan 10, 2024
…#41986)

This fixes an issue where pkg.stage throws because a patch cannot be found,
but the patch is redundant because the spec is reused from a build cache and
will be installed from existing binaries.
alalazo pushed a commit that referenced this pull request Jan 10, 2024
…#41986)

This fixes an issue where pkg.stage throws because a patch cannot be found,
but the patch is redundant because the spec is reused from a build cache and
will be installed from existing binaries.
haampie added a commit that referenced this pull request Jan 11, 2024
…#41986)

This fixes an issue where pkg.stage throws because a patch cannot be found,
but the patch is redundant because the spec is reused from a build cache and
will be installed from existing binaries.
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Jan 25, 2024
…spack#41986)

This fixes an issue where pkg.stage throws because a patch cannot be found,
but the patch is redundant because the spec is reused from a build cache and
will be installed from existing binaries.
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Jan 31, 2024
…spack#41986)

This fixes an issue where pkg.stage throws because a patch cannot be found,
but the patch is redundant because the spec is reused from a build cache and
will be installed from existing binaries.
greenc-FNAL pushed a commit to FNALssi/spack that referenced this pull request Mar 21, 2024
…spack#41986)

This fixes an issue where pkg.stage throws because a patch cannot be found,
but the patch is redundant because the spec is reused from a build cache and
will be installed from existing binaries.
capitalaslash pushed a commit to capitalaslash/spack that referenced this pull request May 22, 2024
…spack#41986)

This fixes an issue where pkg.stage throws because a patch cannot be found,
but the patch is redundant because the spec is reused from a build cache and
will be installed from existing binaries.
capitalaslash pushed a commit to capitalaslash/spack that referenced this pull request Jul 8, 2024
…spack#41986)

This fixes an issue where pkg.stage throws because a patch cannot be found,
but the patch is redundant because the spec is reused from a build cache and
will be installed from existing binaries.
kwryankrattiger pushed a commit to kwryankrattiger/spack that referenced this pull request Jul 9, 2024
…spack#41986)

This fixes an issue where pkg.stage throws because a patch cannot be found,
but the patch is redundant because the spec is reused from a build cache and
will be installed from existing binaries.
capitalaslash pushed a commit to capitalaslash/spack that referenced this pull request Sep 25, 2024
…spack#41986)

This fixes an issue where pkg.stage throws because a patch cannot be found,
but the patch is redundant because the spec is reused from a build cache and
will be installed from existing binaries.
vjranagit pushed a commit to vjranagit/spack that referenced this pull request Jan 18, 2026
…spack#41986)

This fixes an issue where pkg.stage throws because a patch cannot be found,
but the patch is redundant because the spec is reused from a build cache and
will be installed from existing binaries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-environment core PR affects Spack core functionality tests General test capability(ies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants