-
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: add Freight to PromotionStatus #1721
Conversation
✅ Deploy Preview for docs-kargo-akuity-io ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@krancour can you kindly take a look :) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1721 +/- ##
==========================================
- Coverage 47.00% 46.99% -0.02%
==========================================
Files 219 219
Lines 14332 14337 +5
==========================================
Hits 6737 6737
- Misses 7295 7300 +5
Partials 300 300 ☔ View full report in Codecov by Sentry. |
@jacobnguyenn as this pull request would be a very welcome addition for some other things I want to factor out of the Promotion reconciler, I was wondering if are still interested in incorporating the feedback from #1721 (review). I would otherwise also be happy to do the last bits for you, but wanted to give you a chance to address things yourself. (This doesn't have to be tomorrow, I can wait a little longer! 🍒) |
thanks @hiddeco , i have been busy the last few days. I will get back to this today :) |
868d68f
to
30525ce
Compare
48f6333
to
b3381ff
Compare
api/v1alpha1/promotion_types.go
Outdated
@@ -96,6 +96,8 @@ type PromotionStatus struct { | |||
// Metadata holds arbitrary metadata set by promotion mechanisms | |||
// (e.g. for display purposes, or internal bookkeeping) | |||
Metadata map[string]string `json:"metadata,omitempty" protobuf:"bytes,3,rep,name=metadata" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` | |||
// PromotedFreight is the detail of the piece of freight that was referenced by this promotion. | |||
PromotedFreight *FreightReference `json:"promotedFreight,omitempty" protobuf:"bytes,4,opt,name=promotedFreight"` |
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.
On the fence about the naming of this field, as it is also set when the promotion has not completed and/or failed. While the current name may make you think it's the result of a successful promotion.
Given this, I wonder if it maybe should just be named Freight
?
cc: @krancour
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.
Agreed. FreightRef maybe?
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.
It would be fine to just call it Freight
. I don't think there would be any ambiguity in doing so.
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.
Agreed.
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
newStatus, nextFreight, err := r.promoMechanisms.Promote(ctx, stage, &promo, targetFreightRef) |
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.
If I recall correctly, Promote
may actually modify the FreightRef
with more accurate information based on the outcome of the promotion mechanisms. Given this, I think only patching the Status before promoting doesn't suffice.
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.
Can you please kindly help to point out where it was mentioned?
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.
An example of where this happens is during Git promotion, where a HealthCheckCommit
gets added to the FreightRef
:
kargo/internal/controller/promotion/git.go
Lines 209 to 211 in 38ae6e6
if commitIndex > -1 && newStatus.Phase == kargoapi.PromotionPhaseSucceeded { | |
newFreight.Commits[commitIndex].HealthCheckCommit = commitID | |
} |
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.
Spot on. The health check commit is the main thing that may change in the course of promotion.
To be perfectly honest, it's not going to matter to any health check logic if we don't update it the PromotionStatus
, but it may cause confusion among human users if they notice the discrepancy between the FreightReference held by the Stage's CurrentFreight and History fields and this one.
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.e. So we should make sure it gets set here.
18f19ef
to
63beae7
Compare
internal/controller/promotion/git.go
Outdated
@@ -119,7 +119,7 @@ func (g *gitMechanism) Promote( | |||
); err != nil { | |||
return nil, newFreight, err | |||
} | |||
newStatus = aggregateGitPromoStatus(newStatus, *otherStatus) | |||
newStatus = aggregateGitPromoStatus(newStatus, *otherStatus).WithFreight(&newFreight) |
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 am not sure setting this here is the best thing we can do. As this would mean that for every promotion mechanism which does something with the Freight, we would have to remember to include it in the status.
What I would do instead, is persist the FreightReference
to the PromotionStatus
within internal/controller/promotions/promotions.go
after r.promoMechanisms.Promote
has been called. As nextFreight
will contain the updated Freight data.
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.
What I would do instead, is persist the
FreightReference
to thePromotionStatus
withininternal/controller/promotions/promotions.go
afterr.promoMechanisms.Promote
has been called. AsnextFreight
will contain the updated Freight data.
I see, but is it more convenient to reflect freight reference changes right beside the place we update its details? Also, it is pretty unclear which promotion mechanism caused freight reference update even if we update PromotionStatus
in nternal/controller/promotions/promotions.go
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 see, but is it more convenient to reflect freight reference changes right beside the place we update its details?
Can you eleborate more on this question, I am not sure I am following the details of it.
Also, it is pretty unclear which promotion mechanism caused freight reference update even if we update
PromotionStatus
ininternal/controller/promotions/promotions.go
Who and/or why would we have the desire to know what promotion mechanism changed something? Or how is the current approach solving this better?
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 see, but is it more convenient to reflect freight reference changes right beside the place we update its details?
Can you eleborate more on this question, I am not sure I am following the details of it.
I'm just wondering if it is more clear to add the new detail of FreightReference to the Promotion Status. In that way, after calling r.promoMechanisms.Promote, the caller will have the latest FreightReference data.
Also, it is pretty unclear which promotion mechanism caused freight reference update even if we update
PromotionStatus
ininternal/controller/promotions/promotions.go
Who and/or why would we have the desire to know what promotion mechanism changed something? Or how is the current approach solving this better?
For the second part, since we're doing an aggregation of promote mechanisms, will it be useful (or not) to know that which promote mechanism changed the FreightReference detail.
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 believe the easiest place to assign the FreightReference to the PromotionStatus would be right here:
kargo/internal/controller/promotions/promotions.go
Lines 455 to 458 in 5287d0e
newStatus, nextFreight, err := r.promoMechanisms.Promote(ctx, stage, &promo, targetFreightRef) | |
if err != nil { | |
return nil, err | |
} |
A superior, but more involved option might be to modify the signature of the Mechanism
interface's Promote
function so that promotion mechanisms do not return PromotionStatus and modified FreightReference separately, but just return the PromotionStatus with the FreightReference already set.
I think I would suggest taking the easier approach and either @hiddeco or myself will do the rest of the housekeeping in a follow-up.
f3439a0
to
2fa75cd
Compare
e42ce65
to
4cfa596
Compare
b5c8e05
to
4feb10d
Compare
@jacobnguyenn don't worry about conflicts. I'll run codegen tomorrow to resolve them then look at this with fresh eyes. I think this might be all set. |
Thanks for your patience 🎉 |
Just needs codegen rerun and then this is 🚀 I will square that away on Monday. |
4feb10d
to
7a4d28a
Compare
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.
Resolved the conflicts, this LGTM. Thanks @jacobnguyenn 🙇
Signed-off-by: Nguyen Duy Phuong <knowledge.phuongnguyen@gmail.com>
…m, add conventional method to add freight to promotion status Signed-off-by: Nguyen Duy Phuong <knowledge.phuongnguyen@gmail.com>
Co-authored-by: Kent Rancourt <kent.rancourt@gmail.com> Signed-off-by: Nguyen Duy Phuong <knowledge.phuongnguyen@gmail.com>
Signed-off-by: Phuong D. Nguyen <knowledge.phuongnguyen@gmail.com>
Co-authored-by: Kent Rancourt <kent.rancourt@gmail.com> Signed-off-by: Phuong D. Nguyen <knowledge.phuongnguyen@gmail.com>
7a4d28a
to
ba3004d
Compare
@@ -458,6 +457,7 @@ func (r *reconciler) promote( | |||
if err != nil { | |||
return nil, err | |||
} | |||
newStatus = newStatus.WithFreight(&nextFreight) |
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.
Nit: Personally, I'm not sure I would delegate such a trivial assignment as newStatus.Freight = nextFreight
to this new WithFreight()
function.
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 thought the same but figured we could sort it with the other suggestions we would tackle ourselves.
Fixes #1628