Merge ~graylog-charmers/charm-graylog:core-resource into ~graylog-charmers/charm-graylog:master

Proposed by Kevin W Monroe
Status: Merged
Approved by: Kevin W Monroe
Approved revision: 9d710af3c27605ce2353b6ef57e09834339e20ed
Merged at revision: f233dad8109e352ae4fb923a1deb9e5d47336b75
Proposed branch: ~graylog-charmers/charm-graylog:core-resource
Merge into: ~graylog-charmers/charm-graylog:master
Diff against target: 63 lines (+31/-0)
3 files modified
Makefile (+25/-0)
layer.yaml (+2/-0)
metadata.yaml (+4/-0)
Reviewer Review Type Date Requested Status
Stuart Bishop (community) canonical-is-reviewers Approve
George Kraft (community) Approve
Canonical IS Reviewers Pending
Review via email: mp+367201@code.launchpad.net

Commit message

lp:1828063 add a core.snap resource to facilitate offline installs

Description of the change

The core snap is required by the graylog snap. To facilitate offline deployment, users need the ability to attach a core.snap resource in addition to the graylog.snap resource.

A downside of this is that future graylog charm releases will need to have a zero-byte core.snap resource attached, as in:

rm /tmp/core.snap && touch /tmp/core.snap
charm push /path/to/graylog-charm --resource core=/tmp/core.snap
charm release <graylog-X> --resource core-0 --resource graylog-Y

For normal deployments, layer-snap will recognize that core.snap is a 0-byte resource and will fall back to installing from the snap store. For offline deployments, users will need to attach the desired core.snap, as in:

juju deploy /path/to/graylog-charm \
  --resource core=/path/to/real/core.snap \
  --resource graylog=/path/to/real/graylog.snap

Also in offline deployments, we need to ensure the coren.snap is installed prior to graylog.snap, hence this is dependent on:

https://github.com/stub42/layer-snap/pull/22.

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
George Kraft (cynerva) wrote :
Revision history for this message
Kevin W Monroe (kwmonroe) wrote :

We did something similar to this MP for prometheus; during that review, stub requested a helper for developers to know how to use these snap resources:

https://code.launchpad.net/~prometheus-charmers/prometheus2-charm/+git/prometheus2-charm/+merge/367206

I added something similar here:

$ make charmrelease
---------------------------------------------------------------------
graylog supports core and graylog snap resources.

Attached resources will be processed during charm deployment. If a
zero-byte resource is found, the charm will install the relevant snap
from the store. This provides flexibility in choosing which snaps will
be installed by the charm.

For example, release a charm that uses the core snap from the store
(0-byte resource attached) along with a specific graylog snap:

cd /tmp
rm empty-core.snap && touch empty-core.snap
snap download --channel=stable graylog
charm push /Users/kwmonroe/charms/builds/graylog --resource core=/tmp/empty-core.snap --resource graylog=/tmp/graylog_*.snap
charm release <revision> --resource core-<m> --resource graylog-<n>

If the resources you want already exist in the charm store, omit the
declarations during 'charm push' and specify resource revisions
during 'charm release':

charm push /Users/kwmonroe/charms/builds/graylog
charm release <revision> --resource core-0 --resource graylog-3
---------------------------------------------------------------------

Revision history for this message
George Kraft (cynerva) :
review: Approve
Revision history for this message
Stuart Bishop (stub) wrote :

Code changes are fine. I think the text to 'charmrelease' will confuse less experienced people tasked with publishing the charm to edge or stable channels and can be reworked, reworded from their perspective (as a newly employed CRE thrown in at the deep end, I want to publish a new graylog charm containing the fix I just landed).

review: Approve
Revision history for this message
Stuart Bishop (stub) :
review: Approve (canonical-is-reviewers)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision f233dad8109e352ae4fb923a1deb9e5d47336b75

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/Makefile b/Makefile
index e8472b6..9e5089e 100644
--- a/Makefile
+++ b/Makefile
@@ -41,6 +41,31 @@ unittest: sysdeps lint
41charmbuild:41charmbuild:
42 charm build --output-dir $(BUILDDEST) --report42 charm build --output-dir $(BUILDDEST) --report
4343
44.PHONY: charmrelease
45charmrelease:
46 @echo ---------------------------------------------------------------------
47 @echo graylog supports 'core' and 'graylog' snap resources.
48 @echo
49 @echo Attached resources will be processed during charm deployment. If a
50 @echo zero-byte resource is detected, the charm will install the relevant
51 @echo snap from the snap store.
52 @echo
53 @echo Charm changes do not always require new resources. Developers often
54 @echo release new charm revisions using existing resources in the store:
55 @echo
56 @echo charm push $(BUILTCHARMDIR)
57 @echo charm release \<revision\> --resource core-0 --resource graylog-3
58 @echo
59 @echo You could also release a charm that uses the existing empty core snap
60 @echo resource along with a specific graylog snap:
61 @echo
62 @echo cd /tmp
63 @echo snap download --channel=stable graylog
64 @echo charm push $(BUILTCHARMDIR) --resource graylog=/tmp/graylog_*.snap
65 @echo charm release \<revision\> --resource core-0 --resource graylog-\<n\>
66 @echo
67 @echo ---------------------------------------------------------------------
68
44.PHONY: test69.PHONY: test
45test: check-jujumodel testdeps70test: check-jujumodel testdeps
46 @echo "Running functional tests (including lint and unit tests)..."71 @echo "Running functional tests (including lint and unit tests)..."
diff --git a/layer.yaml b/layer.yaml
index c7c211f..3d0f751 100644
--- a/layer.yaml
+++ b/layer.yaml
@@ -12,5 +12,7 @@ options:
12 packages:12 packages:
13 - python3-requests13 - python3-requests
14 snap:14 snap:
15 core:
16 channel: stable
15 graylog:17 graylog:
16 channel: stable18 channel: stable
diff --git a/metadata.yaml b/metadata.yaml
index 10426ed..ee0dbda 100644
--- a/metadata.yaml
+++ b/metadata.yaml
@@ -24,6 +24,10 @@ requires:
24 mongodb:24 mongodb:
25 interface: mongodb25 interface: mongodb
26resources:26resources:
27 core:
28 type: file
29 filename: core.snap
30 description: Snap package of core
27 graylog:31 graylog:
28 type: file32 type: file
29 filename: graylog.snap33 filename: graylog.snap

Subscribers

People subscribed via source and target branches

to all changes: