How do upgrades handle resources?

Cory Johns cory.johns at canonical.com
Wed Aug 2 22:14:23 UTC 2017


Merlijn,

I agree that the documentation around that could be clearer.  The way that
it works is that, just like charms, resources have revisions, and both are
specified when releasing a charm to a channel.  Then, `juju upgrade-charm`
will update both to the current version for the channel you're using, and
the charm's upgrade-charm hook will get fired if either had changed.

So, in more detail, let's say you push a charm to the store that specifies
resources in its metadata.yaml.  You then cannot release that charm
revision to any channel without specifying which resource revision to use
for every resource specified in the charm's metadata.yaml.

To get a resource revision, you have to upload the resource file to the
store using `charm attach`.  The messages you get from charm-attach can be
a bit confusing, though, because you have to specify a revision or channel
of the charm when attaching a resource, but that channel or revision are
ignored as far as I can tell.  You can also specify a resource file when
pushing a new charm revision using the --resource option for `charm push`.

Note that, because you can't release a charm rev to a channel without
providing a resource rev, all charms are required to have *some* file in
the store for the resource, even if it's an empty file.  This decision was
made to ensure that charms using resources could always be deployed from
the store and that using a placeholder resource would have to be a
conscious decision and not an accidental one.

Once you have a resource revision as well as a charm revision, you can
release both to a channel with, e.g., `charm release --channel=edge
cs:~johnsca/test-1 --resource foo-0`.  Then, anyone who deploys or upgrades
to that charm rev will also get the foo-0 resource.  If you decide that you
need to update the resource without updating the charm code, you can use
`charm attach` again to get a foo-1 resource, and then release to edge with
the same charm rev but the new resource rev (`charm release --channel=edge
cs:~johnsca/test-1 --resource foo-1`), or vice-versa to update just the
charm code and keep the same resource.

If the juju admin uses `juju attach` (or `juju deploy --resource`) to
provide a local file to use as the resource, it will of course bypass
whatever's specified in the store and will always trigger the upgrade-charm
hook with the new resource.


On Fri, Jul 28, 2017 at 10:34 AM, Merlijn Sebrechts <
merlijn.sebrechts at gmail.com> wrote:

> Hi all
>
>
> I'm not sure how resources and upgrades work together. I see that the
> kubernetes layers use resources, but you upgrade kubernetes using `juju
> upgrade-charm`. How does that work? Does each charm version have a "default
> resource" attached?
>
> The resources docs don't really explain this either.. https://jujucharms.
> com/docs/2.1/developer-resources
>
>
>
> Kind regards
> Merlijn
>
> --
> Juju mailing list
> Juju at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/juju
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20170802/0f478fb1/attachment.html>


More information about the Juju mailing list