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

Enter blocked status if resource and snap_channel #115

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ config:
The charmed-openstack-exporter snap is by default installed from the latest/stable channel.
This option allows the selection of a different channel.

In case the openStack-exporter resource has been attached, this option has no effect.
If the snap file has been attached via the openstack-exporter resource, this option has no effect.


links:
Expand All @@ -92,4 +92,5 @@ resources:
ignore an empty file resource and normally install the snap from the snap store, but a
custom snap can also be provided here if needed.

This resource has top priority. If the resource is present, the snap_channel option will have no effect.
This resource has priority: if this resource is present,
the snap will be installed from the resource, and the snap_channel option will have no effect.
10 changes: 10 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,16 @@ def _on_collect_unit_status(self, event: ops.CollectStatusEvent) -> None:

snap_service = get_installed_snap_service(SNAP_NAME)

# The snap_channel config option is ignored if there is a snap resource,
# so warn the user.
if self.model.config["snap_channel"] != "latest/stable" and self.get_resource():
chanchiwai-ray marked this conversation as resolved.
Show resolved Hide resolved
event.add_status(
BlockedStatus(
"The snap_channel option is unused when snap resource is provided. "
f"Please unset it: juju config {self.app.name} --unset snap_channel"
)
)

if not snap_service.present:
event.add_status(
BlockedStatus(
Expand Down
Loading