-
Notifications
You must be signed in to change notification settings - Fork 166
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
feat: factor optional "soak time" into freight availability #3100
Conversation
✅ Deploy Preview for docs-kargo-io ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3100 +/- ##
==========================================
+ Coverage 51.40% 51.55% +0.15%
==========================================
Files 288 288
Lines 26108 26188 +80
==========================================
+ Hits 13421 13502 +81
+ Misses 11961 11960 -1
Partials 726 726 ☔ View full report in Codecov by Sentry. |
7a1ebc7
to
6248d3f
Compare
This looks like it doesn't comprehensively address the question of a piece of Freight's overall availability to a given Stage. The required soak time isn't, for instance, being enforced in the case of a manual Promotion. I realize that based on wording of this PR's title and issue #2069, that the scope might have been narrowly about auto-promotion, in which case this PR checks that box perfectly, but imho, the soak time should also be enforced for manual promotions, and if someone absolutely needs to manually Promote a piece of Freight whose soak time hasn't elapsed, they should add a manual Approval to it first. (I don't think soak time should apply to manual approvals.) cc @jessesuen for his opinion on what the scope is supposed to be. @hiddeco since you're out for a bit, I will take up any remaining work on this pending @jessesuen's clarification. |
Thanks for catching this. I agree. We can consider this feature similar to a policy is enforced regardless of auto vs. manual promotion and it would be good to have the guard rail in place for both humans and machines. Manual approval seems like the appropriate way to go around it. |
Thanks @jessesuen. I think this is relatively easy to resolve. |
I have this well underway now. I should have something ready late tomorrow. |
The last four commits I added move Freight availability logic to one central place and it's applied consistently whether you're promoting, auto-promoting, or just querying for available Freight. I'm changing this to a draft, because there is still an outstanding issue here that I discovered and @jessesuen and I discussed offline. This will currently count a piece of Freight as available to a given Stage if its successful verification merely occurred long-enough ago, which turns out to be insufficient given the following scenario: Given a pipeline test --> uat, if Freight A were promoted to test and successfully verified and almost immediately afterward, Freight B were promoted to test, Freight A will still become available to uat after the specified time has elapsed, but Freight A didn't "soak" adequately in test. This is going to require additional bookkeeping to keep track of how long Freight verified in a given Stage actually spent in that Stage. My best thinking on how to achieve this, which needs to be sanity checked by @hiddeco:
A tangential benefit to this is that with every piece of Freight having a record of what Stages are currently using it, the UI, which I believe is currently crunching that information itself, will no longer have to. @hiddeco might be able to refine this idea or suggest an even better alternative. |
This is working e2e and now conforms to the requirements that were clarified by @jessesuen in our offline discussions. |
The merge conflicts are all with codegen. I'll resolve those once this is approved because a rebase on main is probably the best way and I don't want to force push while two maintainers are potentially working on this. |
|
||
// IsFreightAvailable answers whether the specified Freight is available to the | ||
// Stage. | ||
func (s *Stage) IsFreightAvailable(freight *Freight) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any specific reason for putting this method on the Stage instead of the Freight? E.g.
func (s *Stage) IsFreightAvailable(freight *Freight) bool { | |
func (f *Freight) IsEligibleForStage(stage *Stage) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Sorry. I misread this.
There wasn't any specific reason.
It's a function for which Stage and Freight are equally important arguments.
I think I could have gone either way on this and this is just where I landed.
If you think there's a compelling reason to do it the other way, I'm unopposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt it should be put on the Freight instead of the Stage because, assuming the Freight != nil
, it is always available. If it is available to something appears to be the responsibility of the Freight (see also .IsApprovedFor
and .IsVerifiedIn
), and not the entity having the desire.
@@ -26,10 +26,9 @@ func freightByCurrentStagesIndexer(obj client.Object) []string { | |||
return nil | |||
} | |||
currentStages := make([]string, len(freight.Status.CurrentlyIn)) | |||
var i int | |||
currentStages := make([]string, 0, len(freight.Status.CurrentlyIn)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something went wrong here when the suggestion was auto-applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix.
Signed-off-by: Hidde Beydals <[email protected]>
Signed-off-by: Hidde Beydals <[email protected]>
Signed-off-by: Kent Rancourt <[email protected]>
Signed-off-by: Kent Rancourt <[email protected]>
…y logic Signed-off-by: Kent Rancourt <[email protected]>
Signed-off-by: Kent Rancourt <[email protected]>
Signed-off-by: Kent Rancourt <[email protected]>
Signed-off-by: Kent Rancourt <[email protected]>
…ece of freight Signed-off-by: Kent Rancourt <[email protected]>
Signed-off-by: Kent Rancourt <[email protected]>
Signed-off-by: Kent Rancourt <[email protected]>
Signed-off-by: Kent Rancourt <[email protected]>
…e correct soak time Signed-off-by: Kent Rancourt <[email protected]>
Signed-off-by: Kent Rancourt <[email protected]>
Signed-off-by: Kent Rancourt <[email protected]>
Signed-off-by: Kent Rancourt <[email protected]> Co-authored-by: Hidde Beydals <[email protected]>
Signed-off-by: Kent Rancourt <[email protected]>
c03ec00
to
df8c497
Compare
I removed four codegen commits, rebased on main, re-ran codegen, and force pushed. |
) Signed-off-by: Hidde Beydals <[email protected]> Signed-off-by: Kent Rancourt <[email protected]> Co-authored-by: Kent Rancourt <[email protected]>
Fixes: #2069
With this addition, it is possible to configure a duration for which the Freight of an upstream Stage has to be verified, effectively allowing it to "soak" in this Stage.