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

pluginhandler: fix stage-snaps for v2 plugins #3211

Merged

Conversation

jhenstridge
Copy link
Contributor

@jhenstridge jhenstridge commented Jul 13, 2020

  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • Have you successfully run ./runtests.sh static?
  • Have you successfully run ./runtests.sh tests/unit?

The PluginHandler._unpack_stage_snaps method makes use of an attribute on the plugin object that does not seem to exist on v2 plugins, leading to errors like:

...
  File "/snap/snapcraft/5143/lib/python3.6/site-packages/snapcraft/internal/lifecycle/_runner.py", line 247, in _run_pull
    self._run_step(step=steps.PULL, part=part, progress="Pulling")
  File "/snap/snapcraft/5143/lib/python3.6/site-packages/snapcraft/internal/lifecycle/_runner.py", line 322, in _run_step
    self._prepare_step(step=step, part=part)
  File "/snap/snapcraft/5143/lib/python3.6/site-packages/snapcraft/internal/lifecycle/_runner.py", line 313, in _prepare_step
    preparation_function()
  File "/snap/snapcraft/5143/lib/python3.6/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 469, in prepare_pull
    self._unpack_stage_snaps()
  File "/snap/snapcraft/5143/lib/python3.6/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 434, in _unpack_stage_snaps
    logger.debug("Unpacking stage-snaps to {!r}".format(self.plugin.stage_snaps))
AttributeError: 'NilPlugin' object has no attribute 'stage_snaps'

The value being substituted into the log message doesn't really match the text of the log message, so I switched it to use self.part_install_dir instead.

cjp256
cjp256 previously approved these changes Jul 13, 2020
Copy link
Contributor

@cjp256 cjp256 left a comment

Choose a reason for hiding this comment

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

LGTM, though this indicates we need to expand our stage-snap spread test. I'll do that separately.

Thanks!

Chris Patterson added 2 commits July 13, 2020 07:33
Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
@jhenstridge jhenstridge force-pushed the plugins-v2-unpack-stage-snaps branch 5 times, most recently from be8d402 to 9ab7d3e Compare July 14, 2020 08:18
@jhenstridge jhenstridge force-pushed the plugins-v2-unpack-stage-snaps branch from 9ab7d3e to 0fe5893 Compare July 14, 2020 14:10
@jhenstridge
Copy link
Contributor Author

I merged @cjp256's spread tests in, but still saw failures. I tried some test builds with some extra debugging, which showed that while the snaps were correctly being unpacked to parts/$name/install, they were subsequently being deleted.

It looks like the culprit was prepare_build(), which clears the install dir when using a v2 plugin. It re-unpacks staged deb packages, but didn't do the same for snaps.

@sergiusens sergiusens added the bug Actual bad behavior that don't fall into maintenance or documentation label Jul 14, 2020
@sergiusens sergiusens merged commit 0870f17 into canonical:master Jul 14, 2020
abitrolly pushed a commit to abitrolly/snapcraft that referenced this pull request Mar 31, 2021
Co-authored-by: Chris Patterson <chris.patterson@canonical.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Actual bad behavior that don't fall into maintenance or documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants