Use step uuid instead of name in GRPC status calls (#3143)

close #3109

~~also fix start time of steps to be set correctly~~ edgecase do not hit
anymore as we have a clear sepperation between workflows and steps now
:)

---------

Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
6543
2024-01-09 15:39:09 +01:00
committed by GitHub
parent cd59a85230
commit aab2f0e675
8 changed files with 166 additions and 157 deletions

View File

@@ -106,25 +106,34 @@ func (s *RPC) Update(_ context.Context, id string, state rpc.State) error {
workflow, err := s.store.WorkflowLoad(workflowID)
if err != nil {
log.Error().Msgf("error: rpc.update: cannot find workflow with id %d: %s", workflowID, err)
log.Error().Err(err).Msgf("rpc.update: cannot find workflow with id %d", workflowID)
return err
}
currentPipeline, err := s.store.GetPipeline(workflow.PipelineID)
if err != nil {
log.Error().Msgf("error: cannot find pipeline with id %d: %s", workflow.PipelineID, err)
log.Error().Err(err).Msgf("cannot find pipeline with id %d", workflow.PipelineID)
return err
}
step, err := s.store.StepChild(currentPipeline, workflow.PID, state.Step)
step, err := s.store.StepByUUID(state.StepUUID)
if err != nil {
log.Error().Msgf("error: cannot find step with name %s: %s", state.Step, err)
log.Error().Err(err).Msgf("cannot find step with uuid %s", state.StepUUID)
return err
}
if step.PipelineID != currentPipeline.ID {
msg := fmt.Sprintf("agent returned status with step uuid '%s' which does not belong to current pipeline", state.StepUUID)
log.Error().
Int64("stepPipelineID", step.PipelineID).
Int64("currentPipelineID", currentPipeline.ID).
Msg(msg)
return fmt.Errorf(msg)
}
repo, err := s.store.GetRepo(currentPipeline.RepoID)
if err != nil {
log.Error().Msgf("error: cannot find repo with id %d: %s", currentPipeline.RepoID, err)
log.Error().Err(err).Msgf("cannot find repo with id %d", currentPipeline.RepoID)
return err
}

View File

@@ -95,7 +95,7 @@ func (s *WoodpeckerServer) Init(c context.Context, req *proto.InitRequest) (*pro
ExitCode: int(req.GetState().GetExitCode()),
Finished: req.GetState().GetFinished(),
Started: req.GetState().GetStarted(),
Step: req.GetState().GetName(),
StepUUID: req.GetState().GetStepUuid(),
Exited: req.GetState().GetExited(),
}
res := new(proto.Empty)
@@ -109,7 +109,7 @@ func (s *WoodpeckerServer) Update(c context.Context, req *proto.UpdateRequest) (
ExitCode: int(req.GetState().GetExitCode()),
Finished: req.GetState().GetFinished(),
Started: req.GetState().GetStarted(),
Step: req.GetState().GetName(),
StepUUID: req.GetState().GetStepUuid(),
Exited: req.GetState().GetExited(),
}
res := new(proto.Empty)
@@ -123,7 +123,7 @@ func (s *WoodpeckerServer) Done(c context.Context, req *proto.DoneRequest) (*pro
ExitCode: int(req.GetState().GetExitCode()),
Finished: req.GetState().GetFinished(),
Started: req.GetState().GetStarted(),
Step: req.GetState().GetName(),
StepUUID: req.GetState().GetStepUuid(),
Exited: req.GetState().GetExited(),
}
res := new(proto.Empty)