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
lifecycle: only warn when a default provider snap is missing #2885
Merged
+111
−7
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,23 +82,32 @@ def execute( | |
"The repo backend is not returning the list of installed packages" | ||
) | ||
|
||
build_snaps = project_config.build_snaps | ||
content_snaps = project_config.project._get_content_snaps() | ||
required_snaps = project_config.build_snaps | content_snaps | ||
|
||
if common.is_process_container(): | ||
if common.is_process_container() and build_snaps: | ||
installed_snaps: List[str] = [] | ||
logger.warning( | ||
( | ||
"The following snaps are required but not installed as snapcraft " | ||
"is running inside docker or podman container: {}.\n" | ||
"Please ensure the environment is properly setup before continuing.\n" | ||
"Ignore this message if the appropriate measures have already been taken".format( | ||
", ".join(required_snaps) | ||
", ".join(build_snaps) | ||
) | ||
) | ||
) | ||
else: | ||
installed_snaps = repo.snaps.install_snaps(required_snaps) | ||
installed_snaps = repo.snaps.install_snaps(build_snaps) | ||
for content_snap in content_snaps: | ||
try: | ||
installed_snaps += repo.snaps.install_snaps([content_snap]) | ||
except repo.snaps.errors.SnapUnavailableError: | ||
logger.warning( | ||
f"Could not install snap defined in a plug {content_snap!r}. " | ||
"The missing library report may have false positives listed if those " | ||
"libraries were to be provided by the content snap." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: s/were to be/are |
||
) | ||
|
||
try: | ||
global_state = states.GlobalState.load( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/spread/general/content-interface-provider-found/snaps/provider/snap/snapcraft.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: content-test | ||
version: '0.1' | ||
summary: snap using a plug with a content interface should install | ||
description: | | ||
Defining a plug using the content interface should install the snap | ||
listed under default-provider. | ||
grade: devel | ||
confinement: devmode | ||
|
||
plugs: | ||
content-interface: | ||
content: content-interface | ||
interface: content | ||
target: $SNAP/content | ||
default-provider: hello | ||
|
||
parts: | ||
empty: | ||
plugin: nil |
28 changes: 28 additions & 0 deletions
28
tests/spread/general/content-interface-provider-found/task.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
summary: Build a snap that uses the content interface | ||
|
||
environment: | ||
SNAP_DIR: snaps/provider | ||
|
||
prepare: | | ||
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh | ||
. "$TOOLS_DIR/snapcraft-yaml.sh" | ||
set_base "$SNAP_DIR/snap/snapcraft.yaml" | ||
|
||
restore: | | ||
cd "$SNAP_DIR" | ||
snapcraft clean | ||
|
||
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh | ||
. "$TOOLS_DIR/snapcraft-yaml.sh" | ||
restore_yaml "snap/snapcraft.yaml" | ||
|
||
execute: | | ||
cd "$SNAP_DIR" | ||
|
||
snapcraft prime | ||
|
||
if ! snap list hello; then | ||
echo "snap listed as default provider was not installed" | ||
exit 1 | ||
fi | ||
|
20 changes: 20 additions & 0 deletions
20
tests/spread/general/content-interface-provider-not-found/snaps/provider/snap/snapcraft.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: content-test | ||
version: '0.1' | ||
summary: snap using a plug with a content interface that cannot be found | ||
description: | | ||
Defining a plug using the content interface should only warn when it | ||
cannot find the snap listed under default-provider. | ||
grade: devel | ||
confinement: devmode | ||
|
||
plugs: | ||
content-interface: | ||
content: content-interface | ||
interface: content | ||
target: $SNAP/content | ||
default-provider: unknown-content-snap | ||
|
||
parts: | ||
empty: | ||
plugin: nil |
22 changes: 22 additions & 0 deletions
22
tests/spread/general/content-interface-provider-not-found/task.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
summary: Build a snap that uses the content interface with a non published snap | ||
|
||
environment: | ||
SNAP_DIR: snaps/provider | ||
|
||
prepare: | | ||
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh | ||
. "$TOOLS_DIR/snapcraft-yaml.sh" | ||
set_base "$SNAP_DIR/snap/snapcraft.yaml" | ||
|
||
restore: | | ||
cd "$SNAP_DIR" | ||
snapcraft clean | ||
|
||
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh | ||
. "$TOOLS_DIR/snapcraft-yaml.sh" | ||
restore_yaml "snap/snapcraft.yaml" | ||
|
||
execute: | | ||
cd "$SNAP_DIR" | ||
|
||
snapcraft prime | MATCH "Could not install snap defined in a plug" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/in a plug/in plug/