Commit Graph

71 Commits

Author SHA1 Message Date
André Roth
731e92c8e4 Merge pull request #1483 from JupiterRider/gofmt
format the Go code with gofmt
2025-08-30 18:04:29 +02:00
Agustin Henze
3608c137a0 Add mutex on LinkFromPool to fix #1449
This fixes the race condition that happens when you call publish
concurrently. It adds a valuable test that reproduces the error almost
deterministically, it's hard to say always but I have run this in loop
100 times and it reproduces the error consistently without the patch and
after the patch it works consistently.
2025-08-28 10:40:53 +02:00
JupiterRider
b49a631e0b ran "gofmt -s -w ." to format the code 2025-08-20 19:41:26 +02:00
André Roth
f7057a9517 go1.24: fix lint, unit and system tests
- development env: base on debian trixie with go1.24
- lint: run with default config
- fix lint errors
- fix unit tests
- fix system test
2025-04-26 13:29:50 +02:00
Mikel Olasagasti Uranga
7074fc8856 Switch to google/uuid module
Current used github.com/pborman/uuid hasn't seen any updates in years.

Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
2025-01-11 23:18:50 +01:00
André Roth
e92afd8f78 fix unit tests on arm
and fix etcd data dir
2024-12-11 10:40:44 +01:00
Ryan Gonzalez
f9325fbc91 Add support for Azure package pools
This adds support for storing packages directly on Azure, with no truly
"local" (on-disk) repo used. The existing Azure PublishedStorage
implementation was refactored to move the shared code to a separate
context struct, which can then be re-used by the new PackagePool. In
addition, the files package's mockChecksumStorage was made public so
that it could be used in the Azure PackagePool tests as well.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2024-06-17 11:51:18 +02:00
Ryan Gonzalez
19255debb9 Reduce required usage of LocalPackagePool
Several sections of the code *required* a LocalPackagePool, but they
could still perform their operations with a standard PackagePool.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2024-06-17 11:51:18 +02:00
Ryan Gonzalez
1ebd37f9ad Move Stat() into LocalPackagePool
The contents of `os.Stat` are rather fitted towards local package pools,
but the method is in the generic PackagePool interface. This moves it to
LocalPackagePool, and the use case of simply finding a file's size is
delegated to a new, more generic PackagePool.Size() method.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2024-06-17 11:51:18 +02:00
Ryan Gonzalez
8e37813129 Add support for custom package pool locations
Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2024-06-17 11:51:18 +02:00
Ryan Gonzalez
8ab8398c50 Use github.com/saracen/walker for file walk operations
In some local tests w/ a slowed down filesystem, this massively cut down
on the time to clean up a repository by ~3x, bringing a total 'publish
update' time from ~16s to ~13s.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2024-04-24 16:46:16 +02:00
André Roth
3a29e08ff2 fix typo 2024-04-11 19:40:25 +02:00
Ludovico Cavedon
fad660450c Cache bucket content by prefix
When a publishing uses a publish prefix, instead of listing the contents
of the whole bucket under the storage prefix, only list the contents of
the bucket under the storage prefix and publish prefix, and cache it by
publish prefix.
This speeds up publish operations under a prefix.
2024-02-06 20:49:35 +01:00
André Roth
01893a492f s3: call s3.ListFiles only on publish path in LinkFromPool
instead of caching the whole s3 bucket, cache only the pool path. this
requires an additional parameter, and since this is an interface, all
implementations need to follow. might help in other backends too.

closes #1181
2024-02-06 20:49:35 +01:00
Markus Muellner
352f4e8772 update golangci-lint and replace deprecated calls to io/ioutil 2022-12-12 10:21:39 +01:00
Lorenzo Bolla
6826efc723 Fix pure-go unittests
So they can run on e.g. LXC containers as root, or other conceivable setups.
2022-01-27 09:30:14 +01:00
Oliver Sauder
f09a273ad7 Add publish output progress counting remaining number of packages 2022-01-27 09:30:14 +01:00
Joshua Colson
1f56fb86e3 Add -json output flag to repo list|show
Signed-off-by: Joshua Colson <joshua.colson@gmail.com>
2021-09-24 10:29:33 +02:00
Nabil BENDAFI
586f879e80 [DOC] Note about legacy file structure 2019-09-03 00:23:25 +03:00
Nabil BENDAFI
e2112670bf [DOC] Uploaded package file structure 2019-09-03 00:23:25 +03:00
Oliver Sauder
2e52692ba6 Test LinkFromPool with nested filenames 2018-07-06 15:02:37 +02:00
Oliver Sauder
108b0ea226 Add support to mirror non package installer files 2018-07-06 15:02:37 +02:00
aviau
814ac6c28c dep: use official uuid package 2018-06-21 16:12:45 -04:00
Andrey Smirnov
b8c5303fdb Fix paths after repository transfer to aptly-dev 2018-04-18 21:19:43 +03:00
Harald Sitter
b893c0a7ca prevent removal of a PublishedStorage's root dir
presently there is no use case where we need this. on the other hand,
passing empty paths into any of the remove methods is indicative of a bug.
this is particularly dangerous as this can temporarily smash the publish
root but later restore it again when actually publishing. this makes
for super nasty and hard to track down problems.

to guard against this simply disallow root dir removal using empty
strings. should we find a use case for this in the future we can always
revisit this (FTR: I think very explicitly API should be used so everyone
knows what is going on and you can't accidentally run it)
2018-02-26 11:09:03 +01:00
Harald Sitter
3ea803e3bb fix PublishedStorage's ReadLink to return a relative path
previously it'd return an absolute path which makes the path absolutely
useless as all other functions of PublishedStorage need relative input
and will prepend them with the rootPath, so getting an absolute ReadLink
and then trying to remove that'd would ultimately try to remove the
absolute path `$root/AbsoluteRoot/LinkTarget` instead of `$root/LinkTarget`

add a unit test to actually verify readlink
2018-02-19 17:13:41 +01:00
Oliver Sauder
b2bf4f7884 Adjust FileExists to differentiate between error and actual file existence 2017-11-30 09:46:02 +01:00
Oliver Sauder
3efa1052fa Implement FileExists in files storage as simple stat to improve performance 2017-11-30 09:46:02 +01:00
André Roth
e07912770e Extend PublishedStorage interface for Acquire-By-Hash
Signed-off-by: André Roth <neolynx@gmail.com>
2017-11-30 09:46:02 +01:00
Andrey Smirnov
a584b2e058 Fix bug with PoolPath field being overwritten on mirror update
While updating mirror, if package file is already in pool path,
field `PoolPath` was left as empty which results in package file
being unavailable later on while publishing.
2017-08-11 20:05:55 +03:00
Andrey Smirnov
5ce6bf8718 Enable vetshadow linter 2017-05-04 23:00:13 +03:00
Andrey Smirnov
186bb2dff0 Add flag to disable/enable support for legacy pool paths
Legacy pool paths are enabled by default, but for new aptly installations
(when aptly config is first generated), it would be disabled explicitly.
2017-04-26 23:37:31 +03:00
Andrey Smirnov
3ce8227122 Add baseName to LinkFromPool as explicit argument 2017-04-26 23:17:04 +03:00
Andrey Smirnov
0bc3f71d27 Use SHA256 as main checksum in the pool 2017-04-26 23:17:04 +03:00
Andrey Smirnov
8078f3b588 We should remove file only when checksums are calculated 2017-04-26 23:17:04 +03:00
Andrey Smirnov
cc34a021ce Fix misspellings 2017-04-26 23:17:04 +03:00
Andrey Smirnov
10c096fbb6 Update all other pieces for the CheckumStorage and Verify 2017-04-26 23:17:04 +03:00
Andrey Smirnov
a85d8b6f90 Mock for ChecksumStorage 2017-04-26 23:17:04 +03:00
Andrey Smirnov
5566111a7b New ChecksumStorage and new PackagePool interfaces 2017-04-26 23:17:04 +03:00
Andrey Smirnov
1f3cb2db5d When downloading/importing packages, enforce all checksums 2017-04-26 23:17:04 +03:00
Andrey Smirnov
bc7903f86e Rework mirror update (download packages) implementation
`PackageDownloadTask` is just a reference to file now. Whole process
was rewritten to follow pattern: download to temp location inside the pool,
verify/update checksums, import into pool as final step.

This removes a lot of edge cases when aptly internal state might be broken
if updating from rogue mirror.

Also this changes whole memory model: package list/files are kept in memory
now during the duration of `mirror update` command and saved to disk
only in the end.
2017-04-26 23:17:03 +03:00
Andrey Smirnov
72d233b587 Final round of updates, everything except mirror download should be ready 2017-04-26 23:17:03 +03:00
Andrey Smirnov
f4ff8d957f Fix S3 published storage to use new PackagePool interface
Change PackagePool to return Seeker interface from Open call.
2017-04-26 23:17:03 +03:00
Andrey Smirnov
7bad358408 Local package pool and local publishing rewritten with new constraints
Local package pool now implements more generic package pool API.
The base idea is to never expose full paths to files, so that other
kinds of package pools (e.g. package pool in S3) could be used to implement
the same interface.

Files get into the pool only using `Import` method. `Import` method is
now more smart, it supports moving files into the pool, it can detect if
files reside on the same filesystem and use hardlinking instead of copying.
This will make direct mirror downloads still as fast as they were with previous
version which was performing download directly to package pool.

New package pool doesn't have two things implemented yet:

1. New file placement according to SHA256 or other configured hash

2. Calculate at least SHA256/MD5 for each imported files.
MD5 would be required for S3/Swift publishing
2017-04-26 23:17:03 +03:00
Clemens Rabe
25f9c29f00 Implemented filesystem endpoint with support for hardlinks, symlinks and copy. 2017-04-13 20:25:40 +02:00
Andrey Smirnov
50cf2b49bd Refactoring: use checksums instead of MD5 for pool/published
This is related to #506

As a first step, don't pass MD5 explicitly, pass checksum info object,
so that as a next step we can choose which hash to use.

There should be no functional changes so far.

Next step: stop returning explicit paths from public package pool.
2017-04-01 00:12:31 +03:00
Andrey Smirnov
516dd7b044 Switch to gometalinter
Only small amount of required checks is enabled,
plan is to enable more linters as issues are fixed in the code.
2017-03-23 01:51:08 +03:00
Benoit Foucher
7f5a7323a6 Fixed mkdir mode from 755 to 777 2016-03-18 09:37:18 +00:00
Andrey Smirnov
8fcfedf708 Lock down package pool to make sure that we have no concurrent access. #116 2015-02-28 22:10:21 +03:00
Andrey Smirnov
903d4cefba gofmt -s 2015-02-22 14:29:09 +03:00