Upgrading a resource vs upgrading a charm

Hello,

I am wondering if there is a mechanism that allows charm authors to determine what is being upgraded? Is the charm code being upgraded, or is a resource upgraded/attached, (in the case of multiple resources) which one?

Thank you

What I do is that I check the checksum of every resources when an upgrade happens and I react to changes based on the checksum of the files.

1 Like

Juju automatically creates a .juju-charm file in the charm directory which contains the charm URI, including revision. For example, for a charm from the store it would contain something like cs:ubuntu-15, and for a charm deployed locally, it would be something like local:focal/ubuntu-0. In either case, an upgrade of the charm code would change at least the revision portion of the URI. Any upgrade-charm hook where the contents of that file don’t change presumably is a resource update without a charm code update. But it is of course possible that both the charm code and one or more resources could be updated at the same time, so if you want to know for sure that a given resource has been updated, you do need to fetch it and compare the checksum as @maaudet suggested.

2 Likes

Oh, you should also be aware that Juju 2.8.4 and 2.8.5 (current stable) have a bug which causes the upgrade-charm hook to not be run (the start hook is incorrectly run in its place). It’s already been fixed, and is available in 2.8/edge, but is something to be aware of if you’re doing testing of charm upgrade logic.

1 Like