-
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 argocd application info to promotion event #2789
Conversation
✅ Deploy Preview for docs-kargo-io ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
internal/api/event.go
Outdated
@@ -0,0 +1,101 @@ | |||
package api |
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.
any specific reason to move this code from the v1alpha1/event?
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.
There are two main reasons:
- The function is only used in internal packages.
- If I keep it in the original directory, importing
ArgoCDUpdateConfig
from the internal package will causeimport cycle not allowed
, as thev1alpha1/
package is also imported in the internal package.
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 understand the import cycle you're trying to avoid, but I don't think this package is a good home for this. (idk if its old home was any better, tbh.)
"API" is overloaded. I wish this package had been named apiserver
instead, as this package is all API server endpoints, interceptors, etc. and this functionality you're moving to here is used much more broadly -- by the controller, by the webhooks, etc.
Is it possible this might be better off living in the existing event
package (e.g. Live alongside things like func NewRecorder()
)?
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.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2789 +/- ##
==========================================
+ Coverage 48.83% 50.16% +1.33%
==========================================
Files 270 275 +5
Lines 23932 24410 +478
==========================================
+ Hits 11687 12246 +559
+ Misses 11616 11504 -112
- Partials 629 660 +31 ☔ View full report in Codecov by Sentry. |
Signed-off-by: xiaopeng <hanxiaop8@outlook.com>
4a24af7
to
77f0264
Compare
internal/api/event.go
Outdated
if step.Uses != "argocd-update" || step.Config == nil { | ||
continue | ||
} | ||
var cfg directives.ArgoCDUpdateConfig |
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.
We're trying really hard to make built-in directives "not special." Ideally, the rest of Kargo would have as little awareness of their internals as it will eventually have of the internals of third-party directives.
That being said, I understand this might seem like the only practical way to get the information you're trying to include in the events. This, unfortunately, wouldn't be the first spot where we compromised on this ideal because it seemed like the only way to get something done.
Ultimately, I think this ties into a much broader question of how coupled do we want to be or not want to be to Argo CD. Implementation details aside, just including this information in the Promotion event to begin with says something about Kargo's relationship to Argo CD being special in some way. I think this may be a question for @jessesuen.
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.
We're trying really hard to make built-in directives "not special." Ideally, the rest of Kargo would have as little awareness of their internals as it will eventually have of the internals of third-party directives.
The intention of maintaining flexibility and avoiding any special logics for built-in and third-party directives makes sense to me. However I'm still a bit unclear about the design here. From my perspective, this little awareness is from code level instead of user level. Users still see the results the directives processed, but developers are limited to access the output of runners they have written.
Ultimately, I think this ties into a much broader question of how coupled do we want to be or not want to be to Argo CD. Implementation details aside, just including this information in the Promotion event to begin with says something about Kargo's relationship to Argo CD being special in some way.
I would also like to know the idea behind #2545. As a Kargo newbie, when I saw the argocd-update
step inPromotion
resource, I would expect there are some ArgoCD integrations with Kargo. Otherwise it seems we might not need this directive from the lower-level implementations. Seems like this can also be related to how we can integrate with projects that manage workloads?
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.
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.
@hiddeco I tried to move the entire api/v1alpha1/event.go
file and kubernetes events related files to internal/event
in #2808. However as you can see, this would require moving multiple files since some helpers rely on functions within that file. Moving just one function to internal/event doesn’t seem to make much sense. I’d also like to wait for consensus on the best location for this function.
26d214f
to
8f07efc
Compare
5d63097
to
1cd2c64
Compare
Signed-off-by: xiaopeng <hanxiaop8@outlook.com>
1cd2c64
to
4f7a0bc
Compare
internal/kubernetes/event/event.go
Outdated
|
||
// NewPromotionEventAnnotations returns annotations for a Promotion related event. | ||
// It may skip some fields when error occurred during serialization, to record event with best-effort. | ||
func NewPromotionEventAnnotations( |
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.
Please move this to internal/event/promotion.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.
Plus maybe rename it to NewPromotionAnnotations
, as event
already should be enough to indicate it's about events.
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.
Additional candidate to be moved from the public API package is FormatEventUserActor
(-> FormatUserActor
).
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.
@hiddeco Thank you for the suggestion! I've moved this function to internal/event/promotion.go
.
Additional candidate to be moved from the public API package is FormatEventUserActor (-> FormatUserActor).
I've tried this but it still caused the import cycle issue like:
0.602 imports github.com/akuity/kargo/api/v1alpha1
0.602 imports github.com/akuity/kargo/internal/event
0.602 imports github.com/akuity/kargo/api/v1alpha1: import cycle not allowed
I think we could only move NewPromotionAnnotations
here for minimal changes. We can discuss further improvements if necessary and I'd be very happy to contribute more.
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.
That's fair.
Signed-off-by: xiaopeng <hanxiaop8@outlook.com>
8f2bb7a
to
a9e29fb
Compare
This PR adds the applications updated during promotion to the event, so we can get the related application info. Also, I’ve moved
NewPromotionEventAnnotations
from the api directory to internal/api since it’s only used in internal packages, to avoid cyclic imports.The sample results will be something like: