-
Notifications
You must be signed in to change notification settings - Fork 87
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
Introduce the Event v1beta1 API schema #390
Conversation
8b20ce5
to
e675d89
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.
By exposing the annotation keys in combination with more generic methods, I think the API would become more versatile and resistant to implementation changes within the domains of the producer and/or consumer.
) | ||
|
||
// EventTypeTrace represents a trace event. | ||
const EventTypeTrace string = "Trace" |
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's the difference between a "trace" event type and a "trace" severity?
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 used here for mapping https://github.com/fluxcd/pkg/blob/main/runtime/events/recorder.go#L229
apis/event/v1beta1/event.go
Outdated
// and trims the API group from the metadata keys. | ||
func (in *Event) StripMetadata() { | ||
group := in.InvolvedObject.GetObjectKind().GroupVersionKind().Group | ||
excludeList := []string{fmt.Sprintf("%s/checksum", group)} |
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.
Would expect [%s/]checksum
to be exposed as part of the contract. In addition, with RFC-0005 landing soon, we would probably need a %s/digest
(and %s/revision
) as well.
In extend to this, I am wondering if we can settle on all relevant annotations being prefixed with the GVK domain. As this would be more inline with Kubernetes annotations in general.
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.
The prefix borks the alerts, as the keys end up as Stack/Discord/etc labels, that's why we need this strip function.
apis/event/v1beta1/event.go
Outdated
} | ||
} | ||
|
||
in.Metadata = meta |
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 would be the intend of the caller / why are we directly mutating the Event?
apis/event/v1beta1/event.go
Outdated
|
||
// IsCommitStatusUpdate returns true if the event is meant for commit status updates. | ||
func (in *Event) IsCommitStatusUpdate() bool { | ||
if val, ok := in.Metadata["commit_status"]; ok && val == "update" { |
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.
Instead of creating a dedicated method for this, and pulling in implementation specific details. I would rather expose the commit_status
and offer a generic key/value checker.
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.
In addition to this, I would rename commit_status
to commitStatus
(leaving backwards compatibility details as an exercise), which is much more inline with both Kubernetes standards and JSON camelCase which the world has settled on.
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'm not for introducing any breaking changes in v1beta1. This PR is intended to be first step towards Event consolidation while keeping things as they are
apis/event/v1beta1/event.go
Outdated
} | ||
|
||
// GetCommitID extracts the Git commit value from the revision string. | ||
func (in *Event) GetCommitID() (string, error) { |
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.
Like with IsCommitStatusUpdate
, I would make a generic method to retrieve a value from the map and leave the parsing as an exercise for something else. Current logic also conflicts with RFC-0005.
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.
This PR doesn't try to address the RFC. This PR is intended to be first step towards Event consolidation while keeping things as they are. After RFC-0005 is merged, we could work on v1beta2 and introduce there all these changes.
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.
Following my suggestion would make this much easier?
e675d89
to
6f258b1
Compare
Talked more about this with @stefanprodan. The goal of this PR for now is to at least better document some of the indirect contracts that have been established in the notification-controller around e.g. expected "revision" and "checksum" annotation keys, in combination with generic API utilities to retrieve the values of said annotations. Not within the scope, but discussed to be followed up at a later time are at least the following things:
|
32a6987
to
59a8f3f
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.
Happy with the scoped outcome of this, thanks @stefanprodan 🙇
Signed-off-by: Stefan Prodan <[email protected]>
Signed-off-by: Stefan Prodan <[email protected]>
59a8f3f
to
25b2594
Compare
The
fluxcd/pkg/apis/event
package is for formalising how eventing works in Flux. Once this package is released, thefluxcd/pkg/runtime/events
and all controllers should switch to it. The Event API comes with helper functions to be used in notification-controller for filtering metadata.To be used in: fluxcd/notification-controller#435