Skip to content

Commit

Permalink
Add labels to published execution events
Browse files Browse the repository at this point in the history
Signed-off-by: Katrina Rogan <[email protected]>
  • Loading branch information
katrogan committed Dec 12, 2024
1 parent d770918 commit d34a1e1
Show file tree
Hide file tree
Showing 16 changed files with 535 additions and 130 deletions.
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 @@ func NewCloudEventsPublisher(ctx context.Context, db repositoryInterfaces.Reposi
}

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)
}

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 @@ func (p *Publisher) shouldPublishEvent(notificationType string) bool {
}

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 @@ func (c *CloudEventWrappedPublisher) TransformWorkflowExecutionEvent(ctx context
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 {
return &event.CloudEventWorkflowExecution{
RawEvent: rawEvent,
}, nil
Expand Down Expand Up @@ -193,6 +194,7 @@ func (c *CloudEventWrappedPublisher) TransformWorkflowExecutionEvent(ctx context
ReferenceExecution: spec.GetMetadata().GetReferenceExecution(),
Principal: spec.GetMetadata().GetPrincipal(),
LaunchPlanId: spec.GetLaunchPlan(),
Labels: spec.GetLabels().GetValues(),
}, nil
}

Expand Down Expand Up @@ -317,6 +319,7 @@ func (c *CloudEventWrappedPublisher) TransformNodeExecutionEvent(ctx context.Con
ArtifactIds: spec.GetMetadata().GetArtifactIds(),
Principal: spec.GetMetadata().GetPrincipal(),
LaunchPlanId: spec.GetLaunchPlan(),
Labels: spec.GetLabels().GetValues(),
}, nil
}

Expand All @@ -326,8 +329,24 @@ func (c *CloudEventWrappedPublisher) TransformTaskExecutionEvent(ctx context.Con
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
}

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

Expand Down Expand Up @@ -472,14 +491,15 @@ func NewCloudEventsPublisher(sender interfaces.Sender, scope promutils.Scope, ev
}

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 {

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,
}
}
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
27 changes: 27 additions & 0 deletions flyteidl/clients/go/admin/pkce/access_token_error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link href='https://fonts.googleapis.com/css?family=Mulish' rel='stylesheet'>
<meta charset="UTF-8">
<title>Union authentication</title>
<style>
body { font-family: 'Mulish'; }
p { font-weight: 400;font-size: 16px }
</style>
</head>
<body>
<div style="position: absolute;top:40%;left:50%;transform: translate(-50%, -50%);text-align:center;">
<!-- Union logo SVG -->
<svg width="223" height="48" viewBox="0 0 223 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24.0195 47.9353C10.9344 47.9353 0.277344 38.0732 0.277344 25.1171V2.55672H13.2979V33.1959C13.2979 34.614 14.1144 35.3875 15.511 35.3875H32.528C33.946 35.3875 34.741 34.571 34.741 33.1959V2.55672H47.7616V25.1171C47.7616 38.0732 37.083 47.9353 24.0195 47.9353Z" fill="#FCB51D"/>
<path d="M75.8652 0C88.9502 0 99.6288 9.86212 99.6288 22.8182V45.3571H86.6082V14.718C86.6082 13.3214 85.7917 12.5264 84.3952 12.5264H67.3782C65.9601 12.5264 65.1436 13.3429 65.1436 14.718V45.3571H52.123V22.8182C52.123 9.8836 62.8016 0 75.8652 0Z" fill="#FCB51D"/>
<path d="M198.98 0C212.065 0 222.723 9.86212 222.723 22.8182V45.3571H209.702V14.718C209.702 13.3214 208.885 12.5264 207.489 12.5264H190.472C189.054 12.5264 188.259 13.3429 188.259 14.718V45.3571H175.238V22.8182C175.238 9.8836 185.895 0 198.98 0Z" fill="#FCB51D"/>
<path d="M147.005 0.0860291C133.641 0.0860291 123.306 10.4853 123.306 23.9141C123.306 37.3429 133.641 48 147.005 48C160.37 48 170.876 37.4074 170.876 23.9141C170.876 10.4208 160.37 0.0860291 147.005 0.0860291ZM158.543 33.0457C158.543 34.4638 157.727 35.2588 156.309 35.2588H137.938C136.52 35.2588 135.704 34.4423 135.704 33.0457V14.8685C135.704 13.4504 136.52 12.6554 137.938 12.6554H156.309C157.727 12.6554 158.543 13.4719 158.543 14.8685V33.0457Z" fill="#FCB51D"/>
<path d="M118.107 2.55672H105.086V45.3785H118.107V2.55672Z" fill="#FCB51D"/>
</svg>

<p>Couldn't get access token due to error: fail</p>

</div>
</body>
</html>
30 changes: 30 additions & 0 deletions flyteidl/clients/go/admin/pkce/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link href='https://fonts.googleapis.com/css?family=Mulish' rel='stylesheet'>
<meta charset="UTF-8">
<title>Union authentication</title>
<style>
body { font-family: 'Mulish'; }
p { font-weight: 400;font-size: 16px }
</style>
</head>
<body>
<div style="position: absolute;top:40%;left:50%;transform: translate(-50%, -50%);text-align:center;">
<!-- Union logo SVG -->
<svg width="223" height="48" viewBox="0 0 223 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24.0195 47.9353C10.9344 47.9353 0.277344 38.0732 0.277344 25.1171V2.55672H13.2979V33.1959C13.2979 34.614 14.1144 35.3875 15.511 35.3875H32.528C33.946 35.3875 34.741 34.571 34.741 33.1959V2.55672H47.7616V25.1171C47.7616 38.0732 37.083 47.9353 24.0195 47.9353Z" fill="#FCB51D"/>
<path d="M75.8652 0C88.9502 0 99.6288 9.86212 99.6288 22.8182V45.3571H86.6082V14.718C86.6082 13.3214 85.7917 12.5264 84.3952 12.5264H67.3782C65.9601 12.5264 65.1436 13.3429 65.1436 14.718V45.3571H52.123V22.8182C52.123 9.8836 62.8016 0 75.8652 0Z" fill="#FCB51D"/>
<path d="M198.98 0C212.065 0 222.723 9.86212 222.723 22.8182V45.3571H209.702V14.718C209.702 13.3214 208.885 12.5264 207.489 12.5264H190.472C189.054 12.5264 188.259 13.3429 188.259 14.718V45.3571H175.238V22.8182C175.238 9.8836 185.895 0 198.98 0Z" fill="#FCB51D"/>
<path d="M147.005 0.0860291C133.641 0.0860291 123.306 10.4853 123.306 23.9141C123.306 37.3429 133.641 48 147.005 48C160.37 48 170.876 37.4074 170.876 23.9141C170.876 10.4208 160.37 0.0860291 147.005 0.0860291ZM158.543 33.0457C158.543 34.4638 157.727 35.2588 156.309 35.2588H137.938C136.52 35.2588 135.704 34.4423 135.704 33.0457V14.8685C135.704 13.4504 136.52 12.6554 137.938 12.6554H156.309C157.727 12.6554 158.543 13.4719 158.543 14.8685V33.0457Z" fill="#FCB51D"/>
<path d="M118.107 2.55672H105.086V45.3785H118.107V2.55672Z" fill="#FCB51D"/>
</svg>

<h1>Error!</h1>
Error: fail<br>
Error Hint: hint<br>
Description: desc<br>

</div>
</body>
</html>
27 changes: 27 additions & 0 deletions flyteidl/clients/go/admin/pkce/no_code.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link href='https://fonts.googleapis.com/css?family=Mulish' rel='stylesheet'>
<meta charset="UTF-8">
<title>Union authentication</title>
<style>
body { font-family: 'Mulish'; }
p { font-weight: 400;font-size: 16px }
</style>
</head>
<body>
<div style="position: absolute;top:40%;left:50%;transform: translate(-50%, -50%);text-align:center;">
<!-- Union logo SVG -->
<svg width="223" height="48" viewBox="0 0 223 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24.0195 47.9353C10.9344 47.9353 0.277344 38.0732 0.277344 25.1171V2.55672H13.2979V33.1959C13.2979 34.614 14.1144 35.3875 15.511 35.3875H32.528C33.946 35.3875 34.741 34.571 34.741 33.1959V2.55672H47.7616V25.1171C47.7616 38.0732 37.083 47.9353 24.0195 47.9353Z" fill="#FCB51D"/>
<path d="M75.8652 0C88.9502 0 99.6288 9.86212 99.6288 22.8182V45.3571H86.6082V14.718C86.6082 13.3214 85.7917 12.5264 84.3952 12.5264H67.3782C65.9601 12.5264 65.1436 13.3429 65.1436 14.718V45.3571H52.123V22.8182C52.123 9.8836 62.8016 0 75.8652 0Z" fill="#FCB51D"/>
<path d="M198.98 0C212.065 0 222.723 9.86212 222.723 22.8182V45.3571H209.702V14.718C209.702 13.3214 208.885 12.5264 207.489 12.5264H190.472C189.054 12.5264 188.259 13.3429 188.259 14.718V45.3571H175.238V22.8182C175.238 9.8836 185.895 0 198.98 0Z" fill="#FCB51D"/>
<path d="M147.005 0.0860291C133.641 0.0860291 123.306 10.4853 123.306 23.9141C123.306 37.3429 133.641 48 147.005 48C160.37 48 170.876 37.4074 170.876 23.9141C170.876 10.4208 160.37 0.0860291 147.005 0.0860291ZM158.543 33.0457C158.543 34.4638 157.727 35.2588 156.309 35.2588H137.938C136.52 35.2588 135.704 34.4423 135.704 33.0457V14.8685C135.704 13.4504 136.52 12.6554 137.938 12.6554H156.309C157.727 12.6554 158.543 13.4719 158.543 14.8685V33.0457Z" fill="#FCB51D"/>
<path d="M118.107 2.55672H105.086V45.3785H118.107V2.55672Z" fill="#FCB51D"/>
</svg>

<p>Could not find the authorize code.</p>

</div>
</body>
</html>
28 changes: 28 additions & 0 deletions flyteidl/clients/go/admin/pkce/success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link href='https://fonts.googleapis.com/css?family=Mulish' rel='stylesheet'>
<meta charset="UTF-8">
<title>Union authentication</title>
<style>
body { font-family: 'Mulish'; }
p { font-weight: 400;font-size: 16px }
</style>
</head>
<body>
<div style="position: absolute;top:40%;left:50%;transform: translate(-50%, -50%);text-align:center;">
<!-- Union logo SVG -->
<svg width="223" height="48" viewBox="0 0 223 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24.0195 47.9353C10.9344 47.9353 0.277344 38.0732 0.277344 25.1171V2.55672H13.2979V33.1959C13.2979 34.614 14.1144 35.3875 15.511 35.3875H32.528C33.946 35.3875 34.741 34.571 34.741 33.1959V2.55672H47.7616V25.1171C47.7616 38.0732 37.083 47.9353 24.0195 47.9353Z" fill="#FCB51D"/>
<path d="M75.8652 0C88.9502 0 99.6288 9.86212 99.6288 22.8182V45.3571H86.6082V14.718C86.6082 13.3214 85.7917 12.5264 84.3952 12.5264H67.3782C65.9601 12.5264 65.1436 13.3429 65.1436 14.718V45.3571H52.123V22.8182C52.123 9.8836 62.8016 0 75.8652 0Z" fill="#FCB51D"/>
<path d="M198.98 0C212.065 0 222.723 9.86212 222.723 22.8182V45.3571H209.702V14.718C209.702 13.3214 208.885 12.5264 207.489 12.5264H190.472C189.054 12.5264 188.259 13.3429 188.259 14.718V45.3571H175.238V22.8182C175.238 9.8836 185.895 0 198.98 0Z" fill="#FCB51D"/>
<path d="M147.005 0.0860291C133.641 0.0860291 123.306 10.4853 123.306 23.9141C123.306 37.3429 133.641 48 147.005 48C160.37 48 170.876 37.4074 170.876 23.9141C170.876 10.4208 160.37 0.0860291 147.005 0.0860291ZM158.543 33.0457C158.543 34.4638 157.727 35.2588 156.309 35.2588H137.938C136.52 35.2588 135.704 34.4423 135.704 33.0457V14.8685C135.704 13.4504 136.52 12.6554 137.938 12.6554H156.309C157.727 12.6554 158.543 13.4719 158.543 14.8685V33.0457Z" fill="#FCB51D"/>
<path d="M118.107 2.55672H105.086V45.3785H118.107V2.55672Z" fill="#FCB51D"/>
</svg>

<p style="font-weight: 700;font-size: 22px;">You’ve successfully authenticated<p>
<p>Return to your terminal for next steps<p>

</div>
</body>
</html>
27 changes: 27 additions & 0 deletions flyteidl/clients/go/admin/pkce/wrong_state.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link href='https://fonts.googleapis.com/css?family=Mulish' rel='stylesheet'>
<meta charset="UTF-8">
<title>Union authentication</title>
<style>
body { font-family: 'Mulish'; }
p { font-weight: 400;font-size: 16px }
</style>
</head>
<body>
<div style="position: absolute;top:40%;left:50%;transform: translate(-50%, -50%);text-align:center;">
<!-- Union logo SVG -->
<svg width="223" height="48" viewBox="0 0 223 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24.0195 47.9353C10.9344 47.9353 0.277344 38.0732 0.277344 25.1171V2.55672H13.2979V33.1959C13.2979 34.614 14.1144 35.3875 15.511 35.3875H32.528C33.946 35.3875 34.741 34.571 34.741 33.1959V2.55672H47.7616V25.1171C47.7616 38.0732 37.083 47.9353 24.0195 47.9353Z" fill="#FCB51D"/>
<path d="M75.8652 0C88.9502 0 99.6288 9.86212 99.6288 22.8182V45.3571H86.6082V14.718C86.6082 13.3214 85.7917 12.5264 84.3952 12.5264H67.3782C65.9601 12.5264 65.1436 13.3429 65.1436 14.718V45.3571H52.123V22.8182C52.123 9.8836 62.8016 0 75.8652 0Z" fill="#FCB51D"/>
<path d="M198.98 0C212.065 0 222.723 9.86212 222.723 22.8182V45.3571H209.702V14.718C209.702 13.3214 208.885 12.5264 207.489 12.5264H190.472C189.054 12.5264 188.259 13.3429 188.259 14.718V45.3571H175.238V22.8182C175.238 9.8836 185.895 0 198.98 0Z" fill="#FCB51D"/>
<path d="M147.005 0.0860291C133.641 0.0860291 123.306 10.4853 123.306 23.9141C123.306 37.3429 133.641 48 147.005 48C160.37 48 170.876 37.4074 170.876 23.9141C170.876 10.4208 160.37 0.0860291 147.005 0.0860291ZM158.543 33.0457C158.543 34.4638 157.727 35.2588 156.309 35.2588H137.938C136.52 35.2588 135.704 34.4423 135.704 33.0457V14.8685C135.704 13.4504 136.52 12.6554 137.938 12.6554H156.309C157.727 12.6554 158.543 13.4719 158.543 14.8685V33.0457Z" fill="#FCB51D"/>
<path d="M118.107 2.55672H105.086V45.3785H118.107V2.55672Z" fill="#FCB51D"/>
</svg>

<p>Sorry, we can't serve your request.</p>

</div>
</body>
</html>
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

0 comments on commit d34a1e1

Please sign in to comment.