Skip to content

Make the set of Acquire-By-Hash algorithms configurable - #1626

Open
barnumbirr wants to merge 3 commits into
aptly-dev:masterfrom
barnumbirr:configurable-by-hash-algorithms
Open

Make the set of Acquire-By-Hash algorithms configurable#1626
barnumbirr wants to merge 3 commits into
aptly-dev:masterfrom
barnumbirr:configurable-by-hash-algorithms

Conversation

@barnumbirr

Copy link
Copy Markdown

Description of the Change

Acquire-By-Hash entries are written for MD5Sum, SHA1, SHA256 and SHA512,
hardcoded in two places in deb/index_files.go. Every algorithm is a full set of
index copies on each publish, and on S3-like storage each of those is a network
round trip rather than a link.

Measured on an R2-backed archive of 25 packages across three suites, one
aptly publish update per suite, counted at the storage backend:

S3 requests
Acquire-By-Hash off 38
Acquire-By-Hash on 222 — 88 HeadObject, 83 CopyObject, 35 DeleteObject, 13 PutObject

Modern apt verifies with SHA256; MD5Sum and SHA1 are deprecated and Debian has
been phasing them out of Release files for years. Publishers who do not need
them are paying three quarters of that for nothing, with no way to say so.

acquireByHashAlgorithms in aptly.conf now selects the set:

"acquireByHashAlgorithms": ["SHA256", "SHA512"],

Design notes

  • An empty or absent value keeps all four, so existing configurations are
    unaffected and the default behaviour is unchanged.
  • Order comes from the code, not the config. The directories are created in
    one loop and the entries written in another; taking the order from the config
    would let those two disagree.
  • An unrecognised name is an error, not something to skip. Skipping a typo
    would produce "no by-hash entries for that algorithm", which is
    indistinguishable from having configured it away.
  • Set per publish invocation from the config, the way SkipBz2 already is,
    rather than persisted on the publish point.

Independent of #1625

This touches no file that #1625
touches — that one is confined to s3/public.go. Both branch from master and
can merge in either order.

Checklist

  • allow Maintainers to edit PR (rebase, run coverage, help with tests, ...)
  • unit-test added (if change is algorithm) — deb/index_files_test.go
    covers the default, the configured set, the fixed ordering, and rejection
    of unknown names
  • functional test added/updated (if change is functional) — happy to add one
    if you point me at the right fixture
  • man page updated — both man/aptly.1.ronn.tmpl and the generated
    man/aptly.1

Test state

This tree has pre-existing failures unrelated to the change; they are unchanged
by it:

package master this branch
deb 173 passed, 11 failed 177 passed, 11 failed
utils 20 passed, 1 failed (TestCompress) 20 passed, 1 failed
s3 ok ok

Acquire-By-Hash entries are written for MD5Sum, SHA1, SHA256 and SHA512,
hardcoded in two places in deb/index_files.go. Every algorithm is a full
set of index copies on each publish, and on S3-like storage each of those
is a network round trip rather than a link.

Measured on an R2-backed archive of 25 packages across three suites, one
`aptly publish update` per suite:

  Acquire-By-Hash off   38 S3 requests
  Acquire-By-Hash on   222 S3 requests   (88 HeadObject, 83 CopyObject,
                                          35 DeleteObject, 13 PutObject)

Modern apt verifies with SHA256; MD5Sum and SHA1 are deprecated and
Debian has been phasing them out of Release files for years. Publishers
who do not need them are paying three quarters of that for nothing, with
no way to say so.

acquireByHashAlgorithms in aptly.conf now selects the set. An empty or
absent value keeps all four, so existing configurations are unaffected.
The order entries are written in comes from the code rather than the
config, so the directories created in one loop and the entries written in
another cannot disagree. An unrecognised name is an error rather than
something to skip: skipping a typo would produce "no by-hash entries for
that algorithm", which looks exactly like having configured it away.

Set per publish invocation from the config, the way SkipBz2 already is,
rather than persisted on the publish point.

Pre-existing test failures on this tree are unchanged by this commit:
deb goes 173->177 passed with the same 11 failures, utils keeps its one
(TestCompress), s3 stays green.
ConfigShowTest snapshots the output of `aptly config show`, which now
carries acquireByHashAlgorithms with its default. The other three system
files mentioning "architectures" are inputs rather than expected output,
which is why only this one test failed.
Same reason as the JSON one: ConfigShowYAMLTest snapshots `aptly config
show` in YAML form. Checked all three gold files under t02_config this
time rather than the one CI named. CreateConfigTest_gold is a commented
template rather than struct output, so it is unaffected, and it passes.
@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.09%. Comparing base (f59b0d2) to head (9187b90).

Files with missing lines Patch % Lines
deb/index_files.go 87.09% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1626      +/-   ##
==========================================
- Coverage   77.37%   77.09%   -0.29%     
==========================================
  Files         165      165              
  Lines       15747    15780      +33     
==========================================
- Hits        12185    12165      -20     
- Misses       2356     2411      +55     
+ Partials     1206     1204       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant