Local charms not de-duped when deployed multiple times

Bug #1579887 reported by Cheryl Jennings
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
High
Unassigned
juju-core
Won't Fix
High
Unassigned
1.25
Won't Fix
High
Unassigned

Bug Description

When deploying local charms multiple times, the charm is stored each time it is deployed, even if the charm has not changed.

Removing the service also does not remove the charm, so repeatedly deploying / destroying the same charm can lead to disk space exhaustion.

Tags: 2.0
Revision history for this message
Cheryl Jennings (cherylj) wrote :

Verified that this happens on both 1.25.5 and current master.

Revision history for this message
Ian Booth (wallyworld) wrote :

The bundle sha is different each time. I deployed 2 charms from the same local directory:

$ juju deploy ./mysql
$ juju deploy ./mysql mysql2

The charm collection in the Juju database now has 2 charm entries with different charm urls. One of the fields in the bundleSHA. For each charm entry, this was different. So no de-duping could possibly occur.

Revision history for this message
Ian Booth (wallyworld) wrote :

And yet, the zips generated as part of AddLocalCharm(), and uploaded to mongo, appear the same, at least on the machine from which the deploy is done.

Revision history for this message
Ian Booth (wallyworld) wrote :

So, the reason is that on the server side, the charm archive is unpacked and then repacked with the revision from the charm url. The charm url revision is incremented on each deploy. This behaviour is I'm guessing as per the original design. I'm guessing this is because the charm url has the revision in it, and we want to ensure the charm archive has a matching revision.

Revision history for this message
Ian Booth (wallyworld) wrote :

I'm really not sure there's a bug as such here. All local charm deployments get a new incremented revision number. This is embedded in the archive. The archive thus has a different checksum.

We could maybe add a new feature to allow local charms with the same name to re-use an existing previously uploaded charm if the checksums match. Thus the same url as a previous upload would be used and no additional storage would be needed.

Revision history for this message
Richard Harding (rharding) wrote :

We've killed off using the revision file I thought? is this based on the local: url? I'm not getting why the zips should be different. Is it new timestamps since it's unzipped and rezipped?

Revision history for this message
Ian Booth (wallyworld) wrote :

The behaviour is that the revision as determined by the generated local: url is incremented server side when the charm archive is processed on upload. And that incremented revision number is set against the archive prior to sending to mongo. So what mongo gets is different each time even if the bytes on disk are the same. This behaviour has been around since forever from what I can see.

Looking at the code, the only place I can see the archive's revision attribute being used is when the archive is unpacked to a directory (and yes, the revision attr is written to the revision file). Is the revision file used? I'm not sure - how do we know what external code or tools depend on this file? eg one use is when a charm is downloaded from the charm store, via charm download, the charm is unpacked and the revision file written. If we really have killed off the revision file, we could ignore this revision attribute of the archive and the bytes would be the same (the charm url would still be incremented though). We would not write any revision file when expanding a charm.

Having said all that, maybe timestamps play a part too. We'd have to verify that if we decide to remove the revision attribute.

Revision history for this message
Cheryl Jennings (cherylj) wrote :

The de-dupe behavior is a non trivial change and will not be backported to 1.25. Instead, cached local charms should be deleted when the service is removed. Bug #1580418 will be used to track that work.

Curtis Hovey (sinzui)
Changed in juju-core:
milestone: 2.0-beta7 → 2.0-beta8
Changed in juju-core:
milestone: 2.0-beta8 → 2.0-beta9
Curtis Hovey (sinzui)
Changed in juju-core:
milestone: 2.0-beta9 → 2.0-beta10
Curtis Hovey (sinzui)
Changed in juju-core:
milestone: 2.0-beta10 → 2.0-beta11
Curtis Hovey (sinzui)
Changed in juju-core:
milestone: 2.0-beta11 → 2.0-beta12
Changed in juju-core:
milestone: 2.0-beta12 → 2.0-beta13
tags: added: 2.0
Curtis Hovey (sinzui)
Changed in juju-core:
milestone: 2.0-beta13 → 2.0-beta14
Curtis Hovey (sinzui)
Changed in juju-core:
milestone: 2.0-beta14 → 2.0-beta15
Changed in juju-core:
milestone: 2.0-beta15 → 2.0-beta16
Changed in juju-core:
milestone: 2.0-beta16 → 2.0-beta17
affects: juju-core → juju
Changed in juju:
milestone: 2.0-beta17 → none
milestone: none → 2.0-beta17
Changed in juju-core:
importance: Undecided → High
status: New → Won't Fix
Changed in juju:
milestone: 2.0-beta17 → 2.0-beta18
Curtis Hovey (sinzui)
Changed in juju:
milestone: 2.0-beta18 → 2.0-beta19
Changed in juju:
milestone: 2.0-beta19 → 2.0-rc1
Changed in juju:
milestone: 2.0-rc1 → 2.0.1
Curtis Hovey (sinzui)
Changed in juju:
milestone: 2.0.1 → none
Revision history for this message
Anastasia (anastasia-macmood) wrote :

Since the issue has been reported, it has been fixed and Released. Marking this as such.

Changed in juju:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.