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

Upstream: Add labels to published execution events #6104

Merged
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
2 changes: 1 addition & 1 deletion flyteadmin/pkg/async/cloudevent/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
}

if cloudEventsConfig.CloudEventVersion == runtimeInterfaces.CloudEventVersionv2 {
return cloudEventImplementations.NewCloudEventsWrappedPublisher(db, sender, scope, storageClient, urlData, remoteDataConfig)
return cloudEventImplementations.NewCloudEventsWrappedPublisher(db, sender, scope, storageClient, urlData, remoteDataConfig, cloudEventsConfig.EventsPublisherConfig)

Check warning on line 104 in flyteadmin/pkg/async/cloudevent/factory.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/pkg/async/cloudevent/factory.go#L104

Added line #L104 was not covered by tests
}

return cloudEventImplementations.NewCloudEventsPublisher(sender, scope, cloudEventsConfig.EventsPublisherConfig.EventTypes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@
}

type CloudEventWrappedPublisher struct {
db repositoryInterfaces.Repository
sender interfaces.Sender
systemMetrics implementations.EventPublisherSystemMetrics
storageClient *storage.DataStore
urlData dataInterfaces.RemoteURLInterface
remoteDataConfig runtimeInterfaces.RemoteDataConfig
db repositoryInterfaces.Repository
sender interfaces.Sender
systemMetrics implementations.EventPublisherSystemMetrics
storageClient *storage.DataStore
urlData dataInterfaces.RemoteURLInterface
remoteDataConfig runtimeInterfaces.RemoteDataConfig
eventPublisherConfig runtimeInterfaces.EventsPublisherConfig
}

func (c *CloudEventWrappedPublisher) TransformWorkflowExecutionEvent(ctx context.Context, rawEvent *event.WorkflowExecutionEvent) (*event.CloudEventWorkflowExecution, error) {
Expand All @@ -133,8 +134,8 @@
return nil, fmt.Errorf("nil execution id in event [%+v]", rawEvent)
}

// For now, don't append any additional information unless succeeded
if rawEvent.GetPhase() != core.WorkflowExecution_SUCCEEDED {
// For now, don't append any additional information unless succeeded or otherwise configured
if rawEvent.GetPhase() != core.WorkflowExecution_SUCCEEDED && !c.eventPublisherConfig.EnrichAllWorkflowEventTypes {

Check warning on line 138 in flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go#L138

Added line #L138 was not covered by tests
return &event.CloudEventWorkflowExecution{
RawEvent: rawEvent,
}, nil
Expand Down Expand Up @@ -193,6 +194,7 @@
ReferenceExecution: spec.GetMetadata().GetReferenceExecution(),
Principal: spec.GetMetadata().GetPrincipal(),
LaunchPlanId: spec.GetLaunchPlan(),
Labels: spec.GetLabels().GetValues(),

Check warning on line 197 in flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go#L197

Added line #L197 was not covered by tests
}, nil
}

Expand Down Expand Up @@ -317,6 +319,7 @@
ArtifactIds: spec.GetMetadata().GetArtifactIds(),
Principal: spec.GetMetadata().GetPrincipal(),
LaunchPlanId: spec.GetLaunchPlan(),
Labels: spec.GetLabels().GetValues(),

Check warning on line 322 in flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go#L322

Added line #L322 was not covered by tests
}, nil
}

Expand All @@ -326,8 +329,24 @@
return nil, fmt.Errorf("nothing to publish, TaskExecution event is nil")
}

executionModel, err := c.db.ExecutionRepo().Get(ctx, repositoryInterfaces.Identifier{
Project: rawEvent.GetParentNodeExecutionId().GetExecutionId().GetProject(),
Domain: rawEvent.GetParentNodeExecutionId().GetExecutionId().GetDomain(),
Name: rawEvent.GetParentNodeExecutionId().GetExecutionId().GetName(),
})
if err != nil {
logger.Warningf(ctx, "couldn't find execution [%+v] for cloud event processing", rawEvent.GetParentNodeExecutionId().GetExecutionId())
return nil, err
}
ex, err := transformers.FromExecutionModel(ctx, executionModel, transformers.DefaultExecutionTransformerOptions)
if err != nil {
logger.Warningf(ctx, "couldn't transform execution [%+v] for cloud event processing", rawEvent.GetParentNodeExecutionId().GetExecutionId())
return nil, err
}

Check warning on line 345 in flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go#L332-L345

Added lines #L332 - L345 were not covered by tests

return &event.CloudEventTaskExecution{
RawEvent: rawEvent,
Labels: ex.GetSpec().GetLabels().GetValues(),

Check warning on line 349 in flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go#L349

Added line #L349 was not covered by tests
}, nil
}

Expand Down Expand Up @@ -472,14 +491,15 @@
}

func NewCloudEventsWrappedPublisher(
db repositoryInterfaces.Repository, sender interfaces.Sender, scope promutils.Scope, storageClient *storage.DataStore, urlData dataInterfaces.RemoteURLInterface, remoteDataConfig runtimeInterfaces.RemoteDataConfig) interfaces.Publisher {
db repositoryInterfaces.Repository, sender interfaces.Sender, scope promutils.Scope, storageClient *storage.DataStore, urlData dataInterfaces.RemoteURLInterface, remoteDataConfig runtimeInterfaces.RemoteDataConfig, eventPublisherConfig runtimeInterfaces.EventsPublisherConfig) interfaces.Publisher {

Check warning on line 494 in flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go#L494

Added line #L494 was not covered by tests

return &CloudEventWrappedPublisher{
db: db,
sender: sender,
systemMetrics: implementations.NewEventPublisherSystemMetrics(scope.NewSubScope("cloudevents_publisher")),
storageClient: storageClient,
urlData: urlData,
remoteDataConfig: remoteDataConfig,
db: db,
sender: sender,
systemMetrics: implementations.NewEventPublisherSystemMetrics(scope.NewSubScope("cloudevents_publisher")),
storageClient: storageClient,
urlData: urlData,
remoteDataConfig: remoteDataConfig,
eventPublisherConfig: eventPublisherConfig,

Check warning on line 503 in flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go#L497-L503

Added lines #L497 - L503 were not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,8 @@ type EventsPublisherConfig struct {
TopicName string `json:"topicName"`
// Event types: task, node, workflow executions
EventTypes []string `json:"eventTypes"`
// Whether to publish enriched events for all workflow execution events
EnrichAllWorkflowEventTypes bool `json:"enrichAllWorkflowEventTypes"`
}

type ExternalEventsConfig struct {
Expand Down
24 changes: 24 additions & 0 deletions flyteidl/gen/pb-es/flyteidl/event/cloudevents_pb.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading