Skip to content
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

Ensure events are serialized #6064

Merged
merged 1 commit into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions pkg/skaffold/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,17 +567,15 @@ func LogMetaEvent() {
}

func (ev *eventHandler) handle(event *proto.Event) {
go func(t *timestamp.Timestamp) {
ev.eventChan <- firedEvent{
event: event,
ts: t,
}
if _, ok := event.GetEventType().(*proto.Event_TerminationEvent); ok {
// close the event channel indicating there are no more events to all the
// receivers
close(ev.eventChan)
}
}(ptypes.TimestampNow())
ev.eventChan <- firedEvent{
event: event,
ts: ptypes.TimestampNow(),
}
if _, ok := event.GetEventType().(*proto.Event_TerminationEvent); ok {
// close the event channel indicating there are no more events to all the
// receivers
close(ev.eventChan)
}
}

func (ev *eventHandler) handleExec(f firedEvent) {
Expand Down
17 changes: 7 additions & 10 deletions pkg/skaffold/event/v2/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
//nolint:golint,staticcheck
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/timestamp"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants"
sErrors "github.com/GoogleContainerTools/skaffold/pkg/skaffold/errors"
Expand Down Expand Up @@ -377,15 +376,13 @@ func (ev *eventHandler) setState(state proto.State) {
}

func (ev *eventHandler) handle(event *proto.Event) {
go func(t *timestamp.Timestamp) {
event.Timestamp = t
ev.eventChan <- event
if _, ok := event.GetEventType().(*proto.Event_TerminationEvent); ok {
// close the event channel indicating there are no more events to all the
// receivers
close(ev.eventChan)
}
}(ptypes.TimestampNow())
event.Timestamp = ptypes.TimestampNow()
ev.eventChan <- event
if _, ok := event.GetEventType().(*proto.Event_TerminationEvent); ok {
// close the event channel indicating there are no more events to all the
// receivers
close(ev.eventChan)
}
}

func (ev *eventHandler) handleTaskEvent(e *proto.TaskEvent) {
Expand Down