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

docs: warehouse selection strategies #2963

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fykaa
Copy link
Contributor

@fykaa fykaa commented Nov 19, 2024

closes #2880

This addresses the aforementioned problem in its broadest sense.

However, we would prefer to have a separate "Working with Warehouses" guide in the long run, which can be completed within this PR.

@fykaa fykaa self-assigned this Nov 19, 2024
@fykaa fykaa requested review from a team as code owners November 19, 2024 14:17
Copy link

netlify bot commented Nov 19, 2024

Deploy Preview for docs-kargo-io ready!

Name Link
🔨 Latest commit 40dd06f
🔍 Latest deploy log https://app.netlify.com/sites/docs-kargo-io/deploys/673ca11ac0ddf60008dcbb10
😎 Deploy Preview https://deploy-preview-2963.docs.kargo.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 50.91%. Comparing base (34c6128) to head (40dd06f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2963      +/-   ##
==========================================
- Coverage   50.92%   50.91%   -0.01%     
==========================================
  Files         279      279              
  Lines       25180    25175       -5     
==========================================
- Hits        12823    12818       -5     
  Misses      11666    11666              
  Partials      691      691              

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


🚨 Try these New Features:

@fykaa
Copy link
Contributor Author

fykaa commented Nov 19, 2024

However, we would prefer to have a separate "Working with Warehouses" guide in the long run, which can be completed within this PR.

I addressed this under commit 40dd06f. If it's not necessary for this PR, I can revert the commit.

@krancour
Copy link
Member

@fykaa I can look at this, but the more immediate solution I was hoping for were comments added to relevant fields in warehouse_types.go and then codegen re-run. i.e. I want info currently not surfaced here and here to be surfaced.

For subscriptions to container image repositories, the `imageSelectionStrategy` field specifies the method for selecting
the desired image. The available strategies for subscribing to an image repository are:

- `Digest`: Selects the image with the specified digest.
Copy link
Member

Choose a reason for hiding this comment

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

This isn't quite what this one does. This is for people who for whatever reason are ignoring the well-established best practice of not using mutable tags like latest.

When you use this one, you must supply a value in the constaint field. That value is the name of a single "mutable" tag.

The strategy will retrieve the latest details for the image tagged that way, including new/updated digest.

the desired image. The available strategies for subscribing to an image repository are:

- `Digest`: Selects the image with the specified digest.
- `Lexical`: Selects the image with the lexicographically greatest tag.
Copy link
Member

Choose a reason for hiding this comment

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

It may be useful to describe the circumstances under which you might use this. It's useful for scenarios where tags incorporate a date/time stamp. With any date/time format that arranges units from most significant to least significant (for example, yyyymmdd), the lexicographically greatest tag will also be the newest. You'd typically pair this with a regex in the allowTags field to limit eligibility to just those tags that conform to the expected format. i.e. You don't want to ask the the lexicographically latest tag and end up with zzzz-my-custom-build instead of nightly-20241211.


- `Digest`: Selects the image with the specified digest.
- `Lexical`: Selects the image with the lexicographically greatest tag.
- `NewestBuild`: Selects the image with the most recent build time.
Copy link
Member

Choose a reason for hiding this comment

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

This is incredibly slow because it requires retrieval of metadata for every eligible tag. This makes it easy to blast through your registry's rate limit.

This should probably come with a warning. If it must be used, it is probably best to use allowTags to constrain the retrieval of metadata to as few images as possible.

- `Digest`: Selects the image with the specified digest.
- `Lexical`: Selects the image with the lexicographically greatest tag.
- `NewestBuild`: Selects the image with the most recent build time.
- `SemVer`: Selects the image that best matches a semantic versioning constraint.
Copy link
Member

Choose a reason for hiding this comment

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

Probably a good place to re-iterate this:

:::info
Kargo uses [semver](https://github.com/masterminds/semver#checking-version-constraints) to handle semantic versioning constraints.
:::

specifies the method for selecting the desired commit.
The available strategies for subscribing to a git repository are:

- `Lexical`: Selects the commit with the lexicographically greatest reference.
Copy link
Member

@krancour krancour Dec 11, 2024

Choose a reason for hiding this comment

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

Suggested change
- `Lexical`: Selects the commit with the lexicographically greatest reference.
- `Lexical`: Selects the commit referenced by the lexicographically greatest tag.

As with the Lexical strategy for image selection, it may we good to explain the circumstances under which this is useful. Also as with that image selection strategy, it's good to limit the acceptable format here so that you don't end up with something like zzz-custom over nightly-20241211.


- `Lexical`: Selects the commit with the lexicographically greatest reference.
- `NewestFromBranch`: Selects the most recent commit from a specified branch.
- `NewestTag`: Selects the most recent commit associated with a tag.
Copy link
Member

Choose a reason for hiding this comment

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

Not quite what it does.

Unlike branches, tags are supposed to be immutable, so there should only be one commit associated with each tag.

The purpose of this strategy is to select the commit associated with the newest (most recently created) tag.

Again, constraining the tags that are eligible is a good idea.

- `Lexical`: Selects the commit with the lexicographically greatest reference.
- `NewestFromBranch`: Selects the most recent commit from a specified branch.
- `NewestTag`: Selects the most recent commit associated with a tag.
- `SemVer`: Selects the commit that best matches a semantic versioning constraint.
Copy link
Member

Choose a reason for hiding this comment

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

This selects the commit referenced by a tag that best matches the constraint.

@krancour
Copy link
Member

This is great, overall.

An additional tip is that you can find more information about how different subscription fields like relate to the different strategies by reading field-level comments in warehouse_types.go.

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

Successfully merging this pull request may close these issues.

Document the possible values of Warehouse imageSelectionStrategy
2 participants