REST API Update Published Local Repo/Switch Published Snapshot (PUT) returns 200 OK, but does not actually switch the snapshot
Detailed Description
Tried with latest aptly (version: 1.5.0+207+g372ce3c4) and using the REST api to switch the published snapshot (PUT /api/publish/:prefix/:distribution) with following body:
{
"SourceKind": "snapshot",
"Sources": [
{
"Component": "main",
"Name": "focal-merged-20240823"
}
],
"Distribution": "focal",
"Architectures": [
"amd64"
],
"Signing": {
"Batch": true,
"PassphraseFile": "passgpg"
}
}
response is 200 OK, but it is telling that snapshot was not switched, as in i.e.
{
"AcquireByHash": false,
"Architectures": [
"amd64"
],
"ButAutomaticUpgrades": "",
"Codename": "",
"Distribution": "focal",
"Label": "",
"NotAutomatic": "",
"Origin": "",
"Path": "eventim/focal",
"Prefix": "eventim",
"SkipContents": false,
"SourceKind": "snapshot",
"Sources": [
{
"Component": "main",
"Name": "focal-merged-20240822"
}
],
"Storage": "",
"Suite": ""
}
Browsing through other tickets, I noticed some mentions of gpg sign failing silently as also this is seen in aptly log
Signing file 'Release' with gpg, please enter your passphrase when prompted:
Clearsigning file 'Release' with gpg, please enter your passphrase when prompted:
[GIN] 2024/08/23 - 10:43:29 | 200 | 3.844885601s | 10.10.10.10 | PUT "/api/publish/example/focal"
but putting gpg-agent log to max debug, it is all good, actually signs and completes.
Also, when try to use DELETE and POST (meaning to drop and create the publish), REST api succeeds and publish is successfully created and signed.
Additionally, using aptly cmd, as in i.e.:
aptly publish -passphrase-file="passgpg" switch focal example focal-merged-20240823
says "Publish for snapshot .. has been successfully switched to new snapshot" and truly action is successfully done.
I would like to hear out whether someone can confirm the issue is present, then I can also dig a little bit into debugging.
Context
This is probably just a small bug and would be beneficial to fix due full publish lifecycle is then possible to maintain via REST api.
Your Environment
Ubuntu 22 linux
thanks for reporting, I will try to reproduce it...
Could you maybe paste the full log of the api call ?
I was unable to reproduce it with aptly 1.6.0~beta1+20241101194523.74364544 (see new apt source in https://github.com/aptly-dev/aptly/discussions/1345 ):
Creating a gpg key:
echo "Key-Type: RSA
Key-Length: 2048
Key-Usage: encrypt, sign
Subkey-Type: RSA
Subkey-Length: 2048
Subkey-Usage: encrypt, sign
Name-Real: Name
Name-Comment: none
Name-Email: gpg@email
Expire-Date: 0
Passphrase: test123
%commit
" | gpg --no-tty --no-default-keyring --keyring=trustedkeys.gpg --no-permission-warning --batch --gen-key
Creating a repo:
curl -X 'POST' \
'http://localhost:3142/api/repos' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"DefaultComponent": "main",
"DefaultDistribution": "stable",
"Name": "repo1"
}'
Add packages:
curl -X 'POST' \
'http://localhost:3142/api/files/upl' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'files=@aptly-dbg_1.6.0~beta1+20241101201028.0b6514dc_amd64.deb;type=application/vnd.debian.binary-package'
curl -X 'POST' \
'http://localhost:3142/api/repos/repo1/file/upl' \
-H 'accept: application/json' \
-d ''
Snapshot:
curl -X 'POST' \
'http://localhost:3142/api/repos/repo1/snapshots' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"description": "string",
"name": "snap2"
}'
Publish:
curl -X 'POST' \
'http://localhost:3142/api/publish/test' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"AcquireByHash": false,
"Architectures": [
"amd64",
"armhf"
],
"ButAutomaticUpgrades": "",
"Distribution": "bookworm",
"ForceOverwrite": false,
"Label": "",
"MultiDist": false,
"NotAutomatic": "",
"Origin": "",
"Signing": {
"Keyring": "trustedkeys.gpg",
"PassphraseFile": "passphrase"
},
"SkipBz2": false,
"SkipCleanup": false,
"SkipContents": false,
"SourceKind": "snapshot",
"Sources": [
{
"Component": "main",
"Name": "snap2"
}
]
}'
Publish Logs:
Signing file 'Release' with gpg, please enter your passphrase when prompted:
Clearsigning file 'Release' with gpg, please enter your passphrase when prompted:
[GIN] 2024/11/03 - 14:51:10 | 201 | 948.265836ms | 172.17.0.1 | POST "/api/publish/test"
Now, add more packages, create a new snapshot snap3...
Re-Publish:
curl -X 'PUT' \
'http://localhost:3142/api/publish/test/bookworm' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"AcquireByHash": false,
"ForceOverwrite": false,
"MultiDist": false,
"Signing": {
"Keyring": "trustedkeys.gpg",
"PassphraseFile": "passphrase"
},
"SkipBz2": false,
"SkipCleanup": false,
"SkipContents": false,
"Snapshots": [
{
"Component": "main",
"Name": "snap3"
}
]
}'
Publish Update Logs:
Signing file 'Release' with gpg, please enter your passphrase when prompted:
Clearsigning file 'Release' with gpg, please enter your passphrase when prompted:
[GIN] 2024/11/03 - 15:02:39 | 200 | 1.567547221s | 172.17.0.1 | PUT "/api/publish/test/bookworm"
Show Snapshot
curl -X 'GET' \
'http://localhost:3142/api/publish' \
-H 'accept: application/json'
[
{
"AcquireByHash": false,
"Architectures": [
"amd64",
"armhf"
],
"ButAutomaticUpgrades": "",
"Codename": "",
"Distribution": "bookworm",
"Label": "",
"MultiDist": false,
"NotAutomatic": "",
"Origin": "",
"Path": "test/bookworm",
"Prefix": "test",
"SkipContents": false,
"SourceKind": "snapshot",
"Sources": [
{
"Component": "main",
"Name": "snap3"
}
],
"Storage": "",
"Suite": ""
}
]
-> new packages are published:
find .aptly/public -name *.deb
.aptly/public/test/pool/main/a/aptly/aptly-api_1.6.0~beta1+20241101201028.0b6514dc_all.deb
.aptly/public/test/pool/main/a/aptly/aptly-dbg_1.6.0~beta1+20241101201028.0b6514dc_amd64.deb
.aptly/public/test/pool/main/a/aptly/aptly_1.6.0~beta1+20241101201028.0b6514dc_amd64.deb
Could you retry with latest ci build ?
Looks like I have the same problem. I recently switched to the api over the cmd line and could not find why my packages were not uploaded (to s3). Funny thing is in my case it works if I upload to my dev repository (s3:myrepository:dev/distribution), but silently fails with (s3:myrepository:./distribution). Will try with latest ci build.
Edit: I confirm no more bug for me in 1.6.0~beta1+20241110143847.147955c6
thanks a lot for testing !