Skip to content

Commit c3f68db

Browse files
fix: panic handling for get workflow logs (#6168)
* panic handling * error panic * cd logs panic handle
1 parent b37bf8d commit c3f68db

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,11 @@ func (handler *PipelineConfigRestHandlerImpl) GetBuildLogs(w http.ResponseWriter
11911191
}(ctx.Done(), cn.CloseNotify())
11921192
}
11931193
defer cancel()
1194-
defer cleanUp()
1194+
defer func() {
1195+
if cleanUp != nil {
1196+
cleanUp()
1197+
}
1198+
}()
11951199
handler.streamOutput(w, logsReader, lastSeenMsgId)
11961200
}
11971201

api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,11 @@ func (handler *PipelineConfigRestHandlerImpl) GetPrePostDeploymentLogs(w http.Re
18081808
}(ctx.Done(), cn.CloseNotify())
18091809
}
18101810
defer cancel()
1811-
defer cleanUp()
1811+
defer func() {
1812+
if cleanUp != nil {
1813+
cleanUp()
1814+
}
1815+
}()
18121816
handler.streamOutput(w, logsReader, lastSeenMsgId)
18131817
}
18141818

pkg/pipeline/CiHandler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ func (impl *CiHandlerImpl) GetRunningWorkflowLogs(workflowId int) (*bufio.Reader
825825

826826
func (impl *CiHandlerImpl) getWorkflowLogs(ciWorkflow *pipelineConfig.CiWorkflow) (*bufio.Reader, func() error, error) {
827827
if string(v1alpha1.NodePending) == ciWorkflow.PodStatus {
828-
return bufio.NewReader(strings.NewReader("")), nil, nil
828+
return bufio.NewReader(strings.NewReader("")), func() error { return nil }, nil
829829
}
830830
ciLogRequest := types.BuildLogRequest{
831831
PodName: ciWorkflow.PodName,

0 commit comments

Comments
 (0)