Skip to content

Commit

Permalink
fixes for app revision status (#4067)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feroze Mohideen authored Dec 8, 2023
1 parent 97505b7 commit 3e4cd90
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions api/server/handlers/porter_app/get_app_revision_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func NewGetAppRevisionStatusHandler(
config *config.Config,
decoderValidator shared.RequestDecoderValidator,
writer shared.ResultWriter,
) *GetAppRevisionHandler {
return &GetAppRevisionHandler{
) *GetAppRevisionStatusHandler {
return &GetAppRevisionStatusHandler{
PorterHandlerReadWriter: handlers.NewDefaultPorterHandler(config, decoderValidator, writer),
KubernetesAgentGetter: authz.NewOutOfClusterAgentGetter(config),
}
Expand All @@ -42,7 +42,7 @@ type GetAppRevisionStatusResponse struct {

// GetAppRevisionStatusHandler returns the status of an app revision
func (c *GetAppRevisionStatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ctx, span := telemetry.NewSpan(r.Context(), "serve-get-app-revision")
ctx, span := telemetry.NewSpan(r.Context(), "serve-get-app-revision-status")
defer span.End()

project, _ := r.Context().Value(types.ProjectScope).(*models.Project)
Expand Down
19 changes: 13 additions & 6 deletions cli/cmd/v2/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ func Update(ctx context.Context, inp UpdateInput) error {

now := time.Now().UTC()

var status *porter_app.GetAppRevisionStatusResponse

for {
if time.Since(now) > checkDeployTimeout {
return errors.New("timed out waiting for app to deploy")
Expand All @@ -218,6 +216,10 @@ func Update(ctx context.Context, inp UpdateInput) error {
return errors.New("unable to determine status of app revision")
}

if status.AppRevisionStatus.IsInTerminalStatus {
break
}

if status.AppRevisionStatus.PredeployStarted {
color.New(color.FgGreen).Printf("Waiting for predeploy to complete...\n") // nolint:errcheck,gosec
}
Expand All @@ -226,10 +228,6 @@ func Update(ctx context.Context, inp UpdateInput) error {
color.New(color.FgGreen).Printf("Waiting for deploy to complete...\n") // nolint:errcheck,gosec
}

if status.AppRevisionStatus.IsInTerminalStatus {
break
}

time.Sleep(checkDeployFrequency)
}

Expand All @@ -242,6 +240,15 @@ func Update(ctx context.Context, inp UpdateInput) error {
CommitSHA: commitSHA,
})

status, err := client.GetRevisionStatus(ctx, cliConf.Project, cliConf.Cluster, appName, updateResp.AppRevisionId)
if err != nil {
return fmt.Errorf("error getting app revision status: %w", err)
}

if status == nil {
return errors.New("unable to determine status of app revision")
}

if status.AppRevisionStatus.InstallFailed {
return errors.New("app failed to deploy")
}
Expand Down

0 comments on commit 3e4cd90

Please sign in to comment.