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
Add events on app CRs #121
Conversation
Tested in ginger
|
resetted is wrong, right? |
return microerror.Maskf(parsingFailedError, "unable to parse app: %#v", err) | ||
} | ||
|
||
compareFunc := map[string]func(v1alpha1.App) string{ |
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 think having a list of compare functions like below is much tidy.
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.
Yes makes sense but also could be useful in other places.
What about moving to the key package in the app library? Since it's using lots of key funcs anyway.
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.
Also offtopic but the logging with namespace/name
is nice.
I think @fiunchinho did that in apptest as well. We should improve the logging in app- and chart-operator too.
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.
@rossf7 Do you mean moving compareFunc
into the app library? But here I would like to show users about events that relevant to the user interface when we hide other changes (e.g. annotation, kubeconfig changes).
Both app-operator and chart-operator are using cmp.diff
from the desired chart CRs, so there are not many places we could use this list other than app-admission-controller. So I'm inclined to stay this function here only, WDYT?
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.
OK sure if we're not going to reuse it then it's more readable to have it here IMO. 👍
But the ordering is weird here. Can we have this in alpha order?
pkg/app/validate_app.go
Outdated
newValue := f(app) | ||
if newValue != f(oldApp) { | ||
if newValue == "/" { | ||
v.event.Emit(ctx, &app, "AppUpdated", "%s has been resetted", name) |
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.
Need a little help here from 🇬🇧
I think it looks good! nice job |
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.
@tomahawk28 This is cool thanks! 🚀
There was a discussion between @fiunchinho on this, https://gigantic.slack.com/archives/C01P7P3BS2C/p1619601080015300
and I think it would be okay with app-admission-controller to emit events since,
it would be the single endpoint to validate app CRs.
It will emit events when it spots the differences between the specs.
Emitting events from the admission controller makes sense but I would expect it's only serving webhooks. Can you update the README to cover that? For describing the webhooks what about linking to the docs?
My main concern is could we have duplicate events? Also what happens when we have a failure condition, like when chart-operator / helm is blocked by a webhook?
Could this generate a lot of events and impact the management cluster?
Can we have a metric for how many events are emitted?
return microerror.Maskf(parsingFailedError, "unable to parse app: %#v", err) | ||
} | ||
|
||
compareFunc := map[string]func(v1alpha1.App) string{ |
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.
Yes makes sense but also could be useful in other places.
What about moving to the key package in the app library? Since it's using lots of key funcs anyway.
return microerror.Maskf(parsingFailedError, "unable to parse app: %#v", err) | ||
} | ||
|
||
compareFunc := map[string]func(v1alpha1.App) string{ |
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.
Also offtopic but the logging with namespace/name
is nice.
I think @fiunchinho did that in apptest as well. We should improve the logging in app- and chart-operator too.
@rossf7 I checked the kube-state-metrics and it doesn't gather metrics about So we either need to enable it from kube-state-metrics app or gather metrics ourselves. But I doubt we need to do it actually given the fact that the Moreover, app-admission-controller emits events right just before it would admit app CRs' changes and only if it sees the actual difference between old and new spec. (e.g. change from the .spec.version) If you still want to have a metric on these events, do you perhaps know any metrics for |
@tomahawk28 That's a shame kube-state-metrics doesn't gather this. But the admission controller emits its own metrics so I think we could add our own.
Yes, that's a good point. Let's see how it goes. We can add a custom metric later if we need 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.
@tomahawk28 Thanks for the changes. Just some final 🇬🇧 nits then this looks good.
return microerror.Maskf(parsingFailedError, "unable to parse app: %#v", err) | ||
} | ||
|
||
compareFunc := map[string]func(v1alpha1.App) string{ |
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.
OK sure if we're not going to reuse it then it's more readable to have it here IMO. 👍
But the ordering is weird here. Can we have this in alpha order?
} | ||
|
||
if newValue == "/" { | ||
v.event.Emit(ctx, &app, "AppUpdated", "%s has been reset", name) |
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's already fixed here. 😄
Co-authored-by: Ross Fairbanks <rossf7@users.noreply.github.com>
|
||
See [docs/tests.md](https://github.com/giantswarm/app-admission-controller/blob/master/docs/tests.md) |
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.
Just a note; I'm deleting this tests.md, since we don't have this document.
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.
LGTM once typos in the doc are fixed
docs/events.md
Outdated
At the end of each successful validation of an app CR, app-admission-controller checks the changes for the following fields and emits an event. | ||
|
||
- `.spec.version` | ||
- `.sepc.catalog` |
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.
These ones still have the typo.
Toward https://github.com/giantswarm/giantswarm/issues/16981
There was a discussion between @fiunchinho on this, https://gigantic.slack.com/archives/C01P7P3BS2C/p1619601080015300
and I think it would be okay with
app-admission-controller
to emit events since,WDYT?
Checklist