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
1diff --git a/Makefile b/Makefile
2index e8472b6..9e5089e 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -41,6 +41,31 @@ unittest: sysdeps lint
6 charmbuild:
7 charm build --output-dir $(BUILDDEST) --report
8
9+.PHONY: charmrelease
10+charmrelease:
11+ @echo ---------------------------------------------------------------------
12+ @echo graylog supports 'core' and 'graylog' snap resources.
13+ @echo
14+ @echo Attached resources will be processed during charm deployment. If a
15+ @echo zero-byte resource is detected, the charm will install the relevant
16+ @echo snap from the snap store.
17+ @echo
18+ @echo Charm changes do not always require new resources. Developers often
19+ @echo release new charm revisions using existing resources in the store:
20+ @echo
21+ @echo charm push $(BUILTCHARMDIR)
22+ @echo charm release \<revision\> --resource core-0 --resource graylog-3
23+ @echo
24+ @echo You could also release a charm that uses the existing empty core snap
25+ @echo resource along with a specific graylog snap:
26+ @echo
27+ @echo cd /tmp
28+ @echo snap download --channel=stable graylog
29+ @echo charm push $(BUILTCHARMDIR) --resource graylog=/tmp/graylog_*.snap
30+ @echo charm release \<revision\> --resource core-0 --resource graylog-\<n\>
31+ @echo
32+ @echo ---------------------------------------------------------------------
33+
34 .PHONY: test
35 test: check-jujumodel testdeps
36 @echo "Running functional tests (including lint and unit tests)..."
37diff --git a/layer.yaml b/layer.yaml
38index c7c211f..3d0f751 100644
39--- a/layer.yaml
40+++ b/layer.yaml
41@@ -12,5 +12,7 @@ options:
42 packages:
43 - python3-requests
44 snap:
45+ core:
46+ channel: stable
47 graylog:
48 channel: stable
49diff --git a/metadata.yaml b/metadata.yaml
50index 10426ed..ee0dbda 100644
51--- a/metadata.yaml
52+++ b/metadata.yaml
53@@ -24,6 +24,10 @@ requires:
54 mongodb:
55 interface: mongodb
56 resources:
57+ core:
58+ type: file
59+ filename: core.snap
60+ description: Snap package of core
61 graylog:
62 type: file
63 filename: graylog.snap

Subscribers

People subscribed via source and target branches

to all changes: