Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support archive priorities #59

Closed
wants to merge 6 commits into from

Conversation

woky
Copy link
Contributor

@woky woky commented May 15, 2023

If a package to be downloaded exists in archive A and archive B, and
archive A has higher priority than archive B, the package is downloaded
from archive A even if archive B has a newer version. If two or more
archives have the same priority, the most recent version of the package
from all of them is selected, if any. Otherwise, lower priority archives
are tried, if any.

This PR depends on #79

  • Have you signed the CLA?

@woky woky mentioned this pull request May 15, 2023
1 task
@woky woky force-pushed the pro-new/archive-priority branch 2 times, most recently from 1d48062 to 7e03f29 Compare May 16, 2023 08:18
@woky woky mentioned this pull request May 16, 2023
1 task
@woky woky force-pushed the pro-new/archive-priority branch 2 times, most recently from d7e8332 to 8dfc390 Compare May 16, 2023 12:06
@woky woky force-pushed the pro-new/archive-priority branch from 8dfc390 to 17caff0 Compare May 18, 2023 21:29
Copy link
Collaborator

@cjdcordeiro cjdcordeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this change. My original comments were in #53 (review) and I can see them addressed in here, so it LGTM.

@cjdcordeiro cjdcordeiro added the Priority Look at me first label May 22, 2023
Copy link
Member

@rebornplusplus rebornplusplus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks nice! I only have a few questions and suggestions.

internal/slicer/slicer.go Outdated Show resolved Hide resolved
internal/slicer/slicer.go Outdated Show resolved Hide resolved
internal/slicer/slicer.go Outdated Show resolved Hide resolved
internal/slicer/slicer.go Outdated Show resolved Hide resolved
@woky woky force-pushed the pro-new/archive-priority branch from 480c0b7 to 2ba6c40 Compare May 31, 2023 11:30
Copy link
Member

@rebornplusplus rebornplusplus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@woky woky force-pushed the pro-new/archive-priority branch 4 times, most recently from 6bebd78 to 8508be3 Compare June 8, 2023 13:05
@woky woky force-pushed the pro-new/archive-priority branch 2 times, most recently from 761f530 to 24c32be Compare June 21, 2023 17:53
@woky woky added Blocked Waiting for something external and removed Priority Look at me first labels Jun 21, 2023
@woky woky force-pushed the pro-new/archive-priority branch 2 times, most recently from 6794408 to a3c5dc6 Compare June 22, 2023 10:38
@woky woky force-pushed the pro-new/archive-priority branch 2 times, most recently from 9c5f389 to 762040c Compare August 30, 2023 12:04
@woky woky force-pushed the pro-new/archive-priority branch from 762040c to 3f7a32c Compare September 19, 2023 06:07
@woky woky force-pushed the pro-new/archive-priority branch 3 times, most recently from ff6bd88 to 438f23a Compare October 9, 2023 19:15
woky added 6 commits October 12, 2023 18:39
Currently we only test with the embedded base-files files package. This
quite limits what we can test. But since commit a3315e3
("testutil/pkgdata: Create deb programatically") we have the ability to
define our own custom package content.

Add support for testing with custom packages. These can be defined in
each test case per archive name. The content can be defined directly in
test case definition with the help of testutil.MustMakeDeb().

The package content is wrapped in the testPackage structure. This
introduces one level of nesting in each test case package definition. In
future, we will add package metadata to the package definition, namely
version. So wrapping the package content in the structure now and later
just adding a new field to it the structure later will make the future
diff much smaller.
At some point we will need to get information about (deb) packages from
(Go) packages other than archive, namely from the slicer package.
For instance:
- Package entries in Chisel DB will include version, digest and
  architecture.
- Multi-archive package selection will need to know versions of a
  package in all configured archives.

Add Info() method to the Archive interface that returns a new
PackageInfo interface that contains accessors for the underlying
control.Section of the package. Currently these accessors are Name(),
Version(), Arch() and SHA256() methods.

The reason to introduce PackageInfo interface instead of returing
control.Section directly is keep the archive abstraction and not leak
implementation details.
In the future, we'd like to support different kinds of archives which
have a non-empty intersection of packages. In other words, we'd like to
support archives that partly override the Ubuntu archive.

Currently, each sliced package is tied to an archive via the "archive"
property that defaults to the default archive. Drop this link from the
sliced packages to the archives and select the latest available version
of the package from all configured archives.

This commit, in effect, doesn't change the current behavior because we
don't allow archives to define their URLs. It's only preparation for
future commits that will add support for different types of archives.
If a package to be downloaded exists in archive A and archive B, and
archive A has higher priority than archive B, the package is downloaded
from archive A even if archive B has a newer version. If two or more
archives have the same priority, the most recent version of the package
from all of them is selected, if any. Otherwise, lower priority archives
are tried, if any.
When two or more archives with highest priority contain a package with
the same version, the choice is effectively random, because the
iteration order over options.Archives map is not defined.

Get rid of this nondeterminism by sorting archives by their priority and
then lexicographically by their labels (greater label wins) when the
priorities are equal. Since archive labels are used as keys in YAML map,
they should be unique and the order should be total.
Archive priority is currently defined as int. This can make chisel.yaml
with very high/low priorities non-portable, e.g. from amd64 to arm32.

Change archive priority definition to int32 data type.
@woky woky force-pushed the pro-new/archive-priority branch from 438f23a to b84d884 Compare October 12, 2023 16:40
@letFunny
Copy link
Collaborator

Per our offline discussion, I think our best way forward is to close this PR and discuss with @rebornplusplus to see if it is a priority right now, and how to amend the code here to make it compatible with the latest changes. We will take that discussion offline and we can always re-open the PRs or create new ones as we see fit.

@cjdcordeiro cjdcordeiro added the Decaying It's been a while, close or act on it label Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocked Waiting for something external Decaying It's been a while, close or act on it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants