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

Prevent manually created Freight from being auto-promoted #3225

Open
1 of 3 tasks
aayushsrivastava opened this issue Jan 8, 2025 · 4 comments
Open
1 of 3 tasks

Prevent manually created Freight from being auto-promoted #3225

aayushsrivastava opened this issue Jan 8, 2025 · 4 comments

Comments

@aayushsrivastava
Copy link

Checklist

  • I've searched the issue queue to verify this is not a duplicate feature request.
  • I've pasted the output of kargo version, if applicable.
  • I've pasted logs, if applicable.

Proposed Feature

When a user manually creates a Freight from "Freight Assembly", it should not be auto-promoted to the left-most Stage. Instead, the user should explicitly promote it to a Stage and then it can auto-promote downstream from there.

Disclaimer: Maybe I am using the features wrong and there are alternative ways of achieving this behavior, please point me in the right direction if that's the case.

Motivation

Consider this simple example where we are developing a pet store. The Warehouse has the following definition:

spec:
  freightCreationPolicy: Automatic
  interval: 5m0s
  subscriptions:
    - image:
        allowTags: v*
        discoveryLimit: 20
        imageSelectionStrategy: SemVer
        repoURL: registry.example.com/pet-store
        strictSemvers: true

The CI increments the minor version for any new change and Kargo auto-promotes it to the dev stage.

Screenshot 2025-01-08 at 12 35 02 PM

There is an issue in production for which the fix is available in version v0.2.1. Kargo doesn't automatically create a new Freight for this version, which is okay.
When the user manually creates a Freight for a hotfix, this Freight is auto-promoted to dev.

Screenshot 2025-01-08 at 12 38 18 PM

This is not ideal because the user would have to manually restore the dev to v0.3.0. Normally, the user would simply manually approve this Freight for staging, promote it there, and then promote it to prod.

Suggested Implementation

We can introduce a flag in the Freight called isAutoPromotable. Stages will ignore any Freight with this flag set to false for auto-promotions.

Freight created from manual freight assembly will initially have this flag set to false. When the user explicitly promotes the Freight to any Stage, we can flip the flag to true so that the Freight can automatically flow downstream after the first manual promotion.

@krancour
Copy link
Member

krancour commented Jan 8, 2025

Thanks @aayushsrivastava. I understand your issue and completely agree there's room for improvement here. I'm not sure about the proposed implementation:

we can flip the flag to true so that the Freight can automatically flow downstream after the first manual promotion

Freight that are eligible for autopromotion to any Stage are the newest ones "available" to it. Availability is based a variety of factors. If that logic were updated to additionally factor in a switch that indicates something is not auto-promotable, the problem is that once you flip that switch, that logic will no longer prevent it from flowing into the Stages that you didn't want to have it.

So I definitely would like to do something about the issue you've raised, but think we need to iterate a bit more on exactly how to achieve it. We're certainly open to any other ideas you may have.

Note some small bit of overlap with #3016

It might be possible to solve both problems in tandem. Or it may not. I'm linking to it just so that we don't lose sight of the potential for it.

@aayushsrivastava
Copy link
Author

aayushsrivastava commented Jan 10, 2025

the problem is that once you flip that switch, that logic will no longer prevent it from flowing into the Stages that you didn't want to have it.

Yeah, I realize now that flipping the switch upon manual promotion to staging can auto-promote it to the dev stage as well in the original example.

Freight that are eligible for autopromotion to any Stage are the newest ones "available" to it.

Maybe we treat the manually created Freight differently for the left-most stage (the one requesting it "directly" from a Warehouse).

Manually created Freight will not be "available" to any Stage to start with.

Manually created Freight is "available" to a later stage since it is manually approved (I am guessing manual approval and verification upstream are two of the factors that make a Freight "available").

PS: I haven't read the source code yet so my understanding of "availability" in this thread may be incomplete due to lossiness of English.

@krancour
Copy link
Member

Maybe we treat the manually created Freight differently for the left-most stage (the one requesting it "directly" from a Warehouse).

I think that's an idea worth exploring.

@gueux
Copy link

gueux commented Jan 14, 2025

Hi, all.
I've also faced the same issue with auto-promoted freight for prod hotfixes.

As a workaround I tried to use 2 warehouses - one with FreightCreationPolicy = 'Auto' that directly promoted to Dev stage and another with FreightCreationPolicy = 'Manual', that allow me to manually create Freight on demand. But in this case promotion steps doesn't work correctly because of ambiguous image detection between warehouses. I know there is argument warehouse() that might be passed to imageFrom(), but the 'freight' context is missed for PromotionTemplate steps. So its not possible to determine which of Warehouse current promotion belongs to.

Wouldn't it be an good option to have a FreightCreationPolicy per Warehouse subscription, and not for the whole Warehouse? It allows users to have multiply Freight streams for the same source, but for different purposes (for auto-promotion and for manual creation as example).

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

No branches or pull requests

3 participants