From 3722ae2ac82fdebf16f028a25a1babd64cafc7e7 Mon Sep 17 00:00:00 2001 From: Feroze Mohideen Date: Thu, 28 Sep 2023 11:06:44 -0400 Subject: [PATCH 1/2] fix passing validate apply v2 flag to segment --- api/server/handlers/porter_app/analytics.go | 7 ++++--- api/server/handlers/porter_app/create_and_update_events.go | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/api/server/handlers/porter_app/analytics.go b/api/server/handlers/porter_app/analytics.go index 5ef993af3b..171aeefa6b 100644 --- a/api/server/handlers/porter_app/analytics.go +++ b/api/server/handlers/porter_app/analytics.go @@ -110,6 +110,7 @@ func TrackStackBuildStatus( stackName string, errorMessage string, status types.PorterAppEventStatus, + validateApplyV2 bool, ) error { _, span := telemetry.NewSpan(ctx, "track-build-status") defer span.End() @@ -126,7 +127,7 @@ func TrackStackBuildStatus( FirstName: user.FirstName, LastName: user.LastName, CompanyName: user.CompanyName, - ValidateApplyV2: project.ValidateApplyV2, + ValidateApplyV2: validateApplyV2, })) } @@ -138,7 +139,7 @@ func TrackStackBuildStatus( FirstName: user.FirstName, LastName: user.LastName, CompanyName: user.CompanyName, - ValidateApplyV2: project.ValidateApplyV2, + ValidateApplyV2: validateApplyV2, })) } @@ -151,7 +152,7 @@ func TrackStackBuildStatus( FirstName: user.FirstName, LastName: user.LastName, CompanyName: user.CompanyName, - ValidateApplyV2: project.ValidateApplyV2, + ValidateApplyV2: validateApplyV2, })) } diff --git a/api/server/handlers/porter_app/create_and_update_events.go b/api/server/handlers/porter_app/create_and_update_events.go index 89f2b0313b..03637eeb68 100644 --- a/api/server/handlers/porter_app/create_and_update_events.go +++ b/api/server/handlers/porter_app/create_and_update_events.go @@ -65,7 +65,8 @@ func (p *CreateUpdatePorterAppEventHandler) ServeHTTP(w http.ResponseWriter, r * ) if request.Type == types.PorterAppEventType_Build { - reportBuildStatus(ctx, request, p.Config(), user, project, appName) + validateApplyV2 := project.GetFeatureFlag(models.ValidateApplyV2, p.Config().LaunchDarklyClient) + reportBuildStatus(ctx, request, p.Config(), user, project, appName, validateApplyV2) } if request.ID == "" { @@ -88,7 +89,7 @@ func (p *CreateUpdatePorterAppEventHandler) ServeHTTP(w http.ResponseWriter, r * p.WriteResult(w, r, event) } -func reportBuildStatus(ctx context.Context, request *types.CreateOrUpdatePorterAppEventRequest, config *config.Config, user *models.User, project *models.Project, stackName string) { +func reportBuildStatus(ctx context.Context, request *types.CreateOrUpdatePorterAppEventRequest, config *config.Config, user *models.User, project *models.Project, stackName string, validateApplyV2 bool) { ctx, span := telemetry.NewSpan(ctx, "report-build-status") defer span.End() @@ -113,7 +114,7 @@ func reportBuildStatus(ctx context.Context, request *types.CreateOrUpdatePorterA } } - _ = TrackStackBuildStatus(ctx, config, user, project, stackName, errStr, request.Status) + _ = TrackStackBuildStatus(ctx, config, user, project, stackName, errStr, request.Status, validateApplyV2) } // createNewAppEvent will create a new app event for the given porter app name. If the app event is an agent event, then it will be created only if there is no existing event which has the agent ID. In the case that an existing event is found, that will be returned instead From 505ebbe69983ed3ef1673d07f5da7539b33b9ef1 Mon Sep 17 00:00:00 2001 From: Feroze Mohideen Date: Thu, 28 Sep 2023 11:14:57 -0400 Subject: [PATCH 2/2] fix --- api/server/handlers/porter_app/list_events.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api/server/handlers/porter_app/list_events.go b/api/server/handlers/porter_app/list_events.go index 1ca30a2e96..6f23280479 100644 --- a/api/server/handlers/porter_app/list_events.go +++ b/api/server/handlers/porter_app/list_events.go @@ -132,7 +132,8 @@ func (p *PorterAppEventListHandler) updateExistingAppEvent( // TODO: get rid of this block and related methods if still here after 08-04-2023 if appEvent.Type == string(types.PorterAppEventType_Build) && appEvent.TypeExternalSource == "GITHUB" { - err = p.updateBuildEvent_Github(ctx, &event, user, project, stackName) + validateApplyV2 := project.GetFeatureFlag(models.ValidateApplyV2, p.Config().LaunchDarklyClient) + err = p.updateBuildEvent_Github(ctx, &event, user, project, stackName, validateApplyV2) if err != nil { return appEvent, telemetry.Error(ctx, span, err, "error updating porter app event for github build") } @@ -158,6 +159,7 @@ func (p *PorterAppEventListHandler) updateBuildEvent_Github( user *models.User, project *models.Project, stackName string, + validateApplyV2 bool, ) error { ctx, span := telemetry.NewSpan(ctx, "update-porter-app-build-event") defer span.End() @@ -220,10 +222,10 @@ func (p *PorterAppEventListHandler) updateBuildEvent_Github( if *actionRun.Status == "completed" { if *actionRun.Conclusion == "success" { event.Status = string(types.PorterAppEventStatus_Success) - _ = TrackStackBuildStatus(ctx, p.Config(), user, project, stackName, "", types.PorterAppEventStatus_Success) + _ = TrackStackBuildStatus(ctx, p.Config(), user, project, stackName, "", types.PorterAppEventStatus_Success, validateApplyV2) } else { event.Status = string(types.PorterAppEventStatus_Failed) - _ = TrackStackBuildStatus(ctx, p.Config(), user, project, stackName, "", types.PorterAppEventStatus_Failed) + _ = TrackStackBuildStatus(ctx, p.Config(), user, project, stackName, "", types.PorterAppEventStatus_Failed, validateApplyV2) } event.Metadata["end_time"] = actionRun.GetUpdatedAt().Time }