Skip to content

Commit

Permalink
fix: panic handling for get workflow logs (#6168)
Browse files Browse the repository at this point in the history
* panic handling

* error panic

* cd logs panic handle
  • Loading branch information
Shivam-nagar23 authored Dec 13, 2024
1 parent b37bf8d commit c3f68db
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,11 @@ func (handler *PipelineConfigRestHandlerImpl) GetBuildLogs(w http.ResponseWriter
}(ctx.Done(), cn.CloseNotify())
}
defer cancel()
defer cleanUp()
defer func() {
if cleanUp != nil {
cleanUp()
}
}()
handler.streamOutput(w, logsReader, lastSeenMsgId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1808,7 +1808,11 @@ func (handler *PipelineConfigRestHandlerImpl) GetPrePostDeploymentLogs(w http.Re
}(ctx.Done(), cn.CloseNotify())
}
defer cancel()
defer cleanUp()
defer func() {
if cleanUp != nil {
cleanUp()
}
}()
handler.streamOutput(w, logsReader, lastSeenMsgId)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/pipeline/CiHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ func (impl *CiHandlerImpl) GetRunningWorkflowLogs(workflowId int) (*bufio.Reader

func (impl *CiHandlerImpl) getWorkflowLogs(ciWorkflow *pipelineConfig.CiWorkflow) (*bufio.Reader, func() error, error) {
if string(v1alpha1.NodePending) == ciWorkflow.PodStatus {
return bufio.NewReader(strings.NewReader("")), nil, nil
return bufio.NewReader(strings.NewReader("")), func() error { return nil }, nil
}
ciLogRequest := types.BuildLogRequest{
PodName: ciWorkflow.PodName,
Expand Down

0 comments on commit c3f68db

Please sign in to comment.