Closed sf-nwaller closed 8 months ago
Hi !
Thanks a lot for the analysis and the patch ! I am not sure this completely solves the problem.
For example, then creating, deleting and creating the same s3 publish point again, no deb files are published.
Publish a snapshot to s3:
curl -X POST -H 'Content-Type: application/json' --data '{"SourceKind": "snapshot", "Sources": [{"Name": "my-snapshot"}], "Distribution": "stable", "Signing": { "Batch": true, "GpgKey": "key@aptly", "PassphraseFile": "secret" }, "AcquireByHash": true, "ForceOverwrite": true }' aptly:8080/api/publish/s3:bucket
Delete the s3 publish
curl -X DELETE aptly:8080/api/publish/s3:bucket
Recreate with same command above
Result: no files published
Expectation: same files published
The reason is, the pathCache is not recreated when just removing paths from it.
In your scenario, if you publish the same file again (without restarting aptly), does it show up in S3 ?
I added the following at the end of the RemoveDirs function:
+ // Invalidate path cache
+ storage.pathCache = nil
Maybe this is needed in every scenario, where aptly serve is not restarted compared to running aptly commands?
Awesome, thanks! 🚀
I re-ran my local test scenario using the latest build aptly=1.5.0+82+gd060ad72
and confirmed that I'm no longer able to reproduce the bug. I can confirm this fix. ✅
In specific circumstances, replacing a package with different content can result in this error message:
The specific circumstances are:
api serve
modes3
storageSteps To Reproduce
aptly api serve
Expected Behaviour
It should be possible to withdraw a package and re-publish it with different content without using
ForceOverwrite
.Actual Behaviour
If Aptly is running in
api serve
mode and is configured to publish to S3, the Steps To Reproduce cause this error:This fails because Aptly's pathCache still holds the MD5 sum of the original file, even though the file is no longer present in S3.
Works After Restart
If Aptly is restarted after removing the original package from S3, then publishing the changed package succeeds without error. This works because Aptly starts with an empty pathCache.
Works With
ForceOverwrite
If
"ForceOverwrite": true
is included with the final publish operation, Aptly succeeds at publishing to S3, as expected.Discussion
The Debian documentation on repository format says:
The Aptly documentation on duplicate packages has this to say:
However, this issue is describing a different scenario where the package has already been removed. In that case, the repository does not contain simultaneously conflicting packages, and there are no conflicting package files in the pool.
Context
It's not possible to add/publish any other packages when Aptly is in this state. As long as Aptly has an in-memory cache of the MD5sum of an object that is different from the local pool version, regardless of the fact the object doesn't actually exist in S3, it will refuse to proceed with any publish operations.
Possible Implementation
I've tested this patch and it resolves the problem for me.
Your Environment
1.5.0+49+g847fd90e
in our production environment1.5.0+58+gf155ed3b
in test/sandbox environment