Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkg/eventProcessor/in/WorkflowEventProcessorService.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ func (impl *WorkflowEventProcessorImpl) SubscribeCDStageCompleteEvent() error {
impl.logger.Errorw("could not get wf runner", "err", err)
return
}

if wfr.Status != string(v1alpha1.NodeSucceeded) {
impl.logger.Debugw("event received from ci runner, updating workflow runner status as succeeded", "savedWorkflowRunnerId", wfr.Id, "oldStatus", wfr.Status, "podStatus", wfr.PodStatus)
err = impl.cdWorkflowRunnerService.UpdateWfrStatus(wfr, string(v1alpha1.NodeSucceeded), 1)
if err != nil {
impl.logger.Errorw("update cd-wf-runner failed for id ", "cdWfrId", wfr.Id, "err", err)
return
}
}

triggerContext := bean5.TriggerContext{
ReferenceId: pointer.String(msg.MsgId),
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/workflow/cd/CdWorkflowRunnerService.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ import (
"github.com/devtron-labs/devtron/pkg/workflow/cd/bean"
"github.com/go-pg/pg"
"go.uber.org/zap"
"time"
)

type CdWorkflowRunnerService interface {
FindWorkflowRunnerById(wfrId int) (*bean.CdWorkflowRunnerDto, error)
CheckIfWfrLatest(wfrId, pipelineId int) (isLatest bool, err error)
UpdateWfrStatus(dto *bean.CdWorkflowRunnerDto, status string, updatedBy int) error
}

type CdWorkflowRunnerServiceImpl struct {
Expand Down Expand Up @@ -60,3 +62,16 @@ func (impl *CdWorkflowRunnerServiceImpl) CheckIfWfrLatest(wfrId, pipelineId int)
}
return isLatest, nil
}

func (impl *CdWorkflowRunnerServiceImpl) UpdateWfrStatus(dto *bean.CdWorkflowRunnerDto, status string, updatedBy int) error {
runnerDbObj := adapter.ConvertCdWorkflowRunnerDtoToDbObj(dto)
runnerDbObj.Status = status
runnerDbObj.UpdatedBy = int32(updatedBy)
runnerDbObj.UpdatedOn = time.Now()
err := impl.cdWorkflowRepository.UpdateWorkFlowRunner(runnerDbObj)
if err != nil {
impl.logger.Errorw("error in updating runner status in db", "runnerId", runnerDbObj.Id, "err", err)
return err
}
return nil
}
23 changes: 23 additions & 0 deletions pkg/workflow/cd/adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,26 @@ func ConvertCdWorkflowDtoToDbObj(dto *bean.CdWorkflowDto) *pipelineConfig.CdWork
},
}
}

func ConvertCdWorkflowRunnerDtoToDbObj(dto *bean.CdWorkflowRunnerDto) *pipelineConfig.CdWorkflowRunner {
return &pipelineConfig.CdWorkflowRunner{
Id: dto.Id,
Name: dto.Name,
WorkflowType: dto.WorkflowType,
ExecutorType: dto.ExecutorType,
Status: dto.Status,
PodStatus: dto.PodStatus,
Message: dto.Message,
StartedOn: dto.StartedOn,
FinishedOn: dto.FinishedOn,
Namespace: dto.Namespace,
LogLocation: dto.LogLocation,
TriggeredBy: dto.TriggeredBy,
CdWorkflowId: dto.CdWorkflowId,
PodName: dto.PodName,
BlobStorageEnabled: dto.BlobStorageEnabled,
RefCdWorkflowRunnerId: dto.RefCdWorkflowRunnerId,
ImagePathReservationIds: dto.ImagePathReservationIds,
ReferenceId: dto.ReferenceId,
}
}