compat api per-revision (and non-revisioned) gives empty resources if charm was not released with resources explicitly
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Snap Store Server |
Triaged
|
High
|
Unassigned |
Bug Description
As an example, latest prometheus-
$ curl -s "https:/
{"Id":"
trying to get resources for the revision gives borked stuff:
$ curl -s "https:/
[
{
"Fingerprint": null,
"Name": "core",
"Path": "",
"Revision": -1,
"Size": 0,
"Type": "file"
},
{
"Fingerprint": null,
"Name": "prometheus-
"Path": "",
"Revision": -1,
"Size": 0,
"Type": "file"
}
]
So does hitting the revision directly:
curl -s "https:/
[
{
"Fingerprint": null,
"Name": "core",
"Path": "",
"Revision": -1,
"Size": 0,
"Type": "file"
},
{
"Fingerprint": null,
"Name": "prometheus-
"Path": "",
"Revision": -1,
"Size": 0,
"Type": "file"
}
]
The reason for this is that when releasing those revisions of the charm, the publisher did not specify the resources; so there are no resourcerevisio
As an example of how it should look, revision 11 is the last one that did have resources associated:
$ curl -s "https:/
[
{
"Description": "Core snap, prerequisite of other snaps",
"Fingerprint": "OLBgp1GsljhM2T
"Name": "core",
"Path": "core.snap",
"Revision": 0,
"Size": 0,
"Type": "file"
},
{
"Description": "Prometheus OpenStack Exporter snap",
"Fingerprint": "I13ObxYy8Lusl9
"Name": "prometheus-
"Path": "prometheus-
"Revision": 1,
"Size": 17420288,
"Type": "file"
}
]
We have seen that if a charm is released without specifying a resource, it ends up in the above situation:
charmcraft release openstack-
and the fix we've recommended is:
charmcraft release openstack-
to create the revisionresourc
The main ask for this bug is to add the same behavior to compat API as we see in the native charmhub api: that is, if a charm with declared resources and at least one resource revision uploaded and ever released with a charm revision, should give that resource when queried via the compatibility API; this is effectively the old charmstore behavior "if a resource is not explicitly associated to a charm revision, we give out the latest resource available for that charm".
I have a vague recollection that behavior already works for the native API, as mentioned above, but it bears checking because I wasn't able to confirm this for the above charm.
tags: | added: charmhub |
Changed in snapstore-server: | |
status: | New → Confirmed |
importance: | Undecided → High |
Changed in snapstore-server: | |
status: | Confirmed → Triaged |
The native charmhub API is also not returning resources:
❯ curl -X POST -H 'Content-Type: application/json' https:/ /api.charmhub. io/v2/charms/ refresh --data '{"context": [], "actions": [{"action": "install", "instance-key": "debug- lp-1971920- 1", "id": "neyN3C9rov9kvS T9H8iwdsj5nnkBR R4f", "base": {"name": "ubuntu", "channel": "20.04", "architecture": "amd64"}}]}' | jq
Dload Upload Total Spent Left Speed
"created- at": "2022-03- 17T16:21: 16.904439+ 00:00",
"hash- sha-256" : "922589c904fa39 90bd1b20d7972d4 1c8756e5b5d9eee bba21c9b0b773af 3ad40", /api.charmhub. io/api/ v1/charms/ download/ neyN3C9rov9kvST 9H8iwdsj5nnkBRR 4f_21.charm" T9H8iwdsj5nnkBR R4f", openstack- exporter" ,
"publisher" : {
"display- name": "Llama (LMA) Charmers", v5K5WOQERYKqV8q JuW",
"username" : "llama-charmers",
"validation" : "unproven"
"resources" : [], effective- channel" : "stable", T9H8iwdsj5nnkBR R4f", instance- key": "this-is- a-test- 1234", openstack- exporter" , released- at": "2022-04- 28T04:38: 42.544691+ 00:00",
% Total % Received % Xferd Average Speed Time Time Time Current
100 1061 100 856 100 205 1009 241 --:--:-- --:--:-- --:--:-- 1249
{
"error-list": [],
"results": [
{
"charm": {
"download": {
"size": 5334417,
"url": "https:/
},
"id": "neyN3C9rov9kvS
"license": "",
"name": "prometheus-
"id": "DmP1D2nqZmxqKF
},
"revision": 21,
"summary": "Openstack exporter for Prometheus",
"type": "charm",
"version": "4456fe0"
},
"
"id": "neyN3C9rov9kvS
"
"name": "prometheus-
"
"result": "install"
}
]
}