Renamed procs/jobs to steps in code (#1331)

Renamed `procs` to `steps` in code for the issue #1288

Co-authored-by: Harikesh Prajapati <harikesh.prajapati@druva.com>
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
Harikesh00
2022-10-28 21:08:53 +05:30
committed by GitHub
parent b44e895017
commit 36e42914fa
109 changed files with 1474 additions and 1364 deletions

View File

@@ -67,7 +67,7 @@ func (r *Runner) Run(ctx context.Context) error {
meta, _ := metadata.FromOutgoingContext(ctx)
ctxmeta := metadata.NewOutgoingContext(context.Background(), meta)
// get the next job from the queue
// get the next workflow from the queue
work, err := r.client.Next(ctx, r.filter)
if err != nil {
return err
@@ -150,10 +150,10 @@ func (r *Runner) Run(ctx context.Context) error {
}
var uploads sync.WaitGroup
defaultLogger := pipeline.LogFunc(func(proc *backend.Step, rc multipart.Reader) error {
defaultLogger := pipeline.LogFunc(func(step *backend.Step, rc multipart.Reader) error {
loglogger := logger.With().
Str("image", proc.Image).
Str("stage", proc.Alias).
Str("image", step.Image).
Str("stage", step.Alias).
Logger()
part, rerr := rc.NextPart()
@@ -172,7 +172,7 @@ func (r *Runner) Run(ctx context.Context) error {
loglogger.Debug().Msg("log stream opened")
limitedPart := io.LimitReader(part, maxLogsUpload)
logStream := rpc.NewLineWriter(r.client, work.ID, proc.Alias, secrets...)
logStream := rpc.NewLineWriter(r.client, work.ID, step.Alias, secrets...)
if _, err := io.Copy(logStream, limitedPart); err != nil {
log.Error().Err(err).Msg("copy limited logStream part")
}
@@ -186,7 +186,7 @@ func (r *Runner) Run(ctx context.Context) error {
file := &rpc.File{
Mime: "application/json+logs",
Proc: proc.Alias,
Step: step.Alias,
Name: "logs.json",
Data: data,
Size: len(data),
@@ -218,7 +218,7 @@ func (r *Runner) Run(ctx context.Context) error {
file = &rpc.File{
Mime: part.Header().Get("Content-Type"),
Proc: proc.Alias,
Step: step.Alias,
Name: part.FileName(),
Data: data,
Size: len(data),
@@ -250,7 +250,7 @@ func (r *Runner) Run(ctx context.Context) error {
})
defaultTracer := pipeline.TraceFunc(func(state *pipeline.State) error {
proclogger := logger.With().
steplogger := logger.With().
Str("image", state.Pipeline.Step.Image).
Str("stage", state.Pipeline.Step.Alias).
Err(state.Process.Error).
@@ -258,27 +258,27 @@ func (r *Runner) Run(ctx context.Context) error {
Bool("exited", state.Process.Exited).
Logger()
procState := rpc.State{
Proc: state.Pipeline.Step.Alias,
stepState := rpc.State{
Step: state.Pipeline.Step.Alias,
Exited: state.Process.Exited,
ExitCode: state.Process.ExitCode,
Started: time.Now().Unix(), // TODO do not do this
Finished: time.Now().Unix(),
}
if state.Process.Error != nil {
procState.Error = state.Process.Error.Error()
stepState.Error = state.Process.Error.Error()
}
defer func() {
proclogger.Debug().Msg("update step status")
steplogger.Debug().Msg("update step status")
if uerr := r.client.Update(ctxmeta, work.ID, procState); uerr != nil {
proclogger.Debug().
if uerr := r.client.Update(ctxmeta, work.ID, stepState); uerr != nil {
steplogger.Debug().
Err(uerr).
Msg("update step status error")
}
proclogger.Debug().Msg("update step status complete")
steplogger.Debug().Msg("update step status complete")
}()
if state.Process.Exited {
return nil
@@ -289,22 +289,29 @@ func (r *Runner) Run(ctx context.Context) error {
// TODO: find better way to update this state and move it to pipeline to have the same env in cli-exec
state.Pipeline.Step.Environment["CI_MACHINE"] = r.hostname
state.Pipeline.Step.Environment["CI_PIPELINE_STATUS"] = "success"
state.Pipeline.Step.Environment["CI_PIPELINE_STARTED"] = strconv.FormatInt(state.Pipeline.Time, 10)
state.Pipeline.Step.Environment["CI_PIPELINE_FINISHED"] = strconv.FormatInt(time.Now().Unix(), 10)
state.Pipeline.Step.Environment["CI_STEP_STATUS"] = "success"
state.Pipeline.Step.Environment["CI_STEP_STARTED"] = strconv.FormatInt(state.Pipeline.Time, 10)
state.Pipeline.Step.Environment["CI_STEP_FINISHED"] = strconv.FormatInt(time.Now().Unix(), 10)
state.Pipeline.Step.Environment["CI_SYSTEM_ARCH"] = runtime.GOOS + "/" + runtime.GOARCH
// DEPRECATED
state.Pipeline.Step.Environment["CI_BUILD_STATUS"] = "success"
state.Pipeline.Step.Environment["CI_BUILD_STARTED"] = strconv.FormatInt(state.Pipeline.Time, 10)
state.Pipeline.Step.Environment["CI_BUILD_FINISHED"] = strconv.FormatInt(time.Now().Unix(), 10)
state.Pipeline.Step.Environment["CI_JOB_STATUS"] = "success"
state.Pipeline.Step.Environment["CI_JOB_STARTED"] = strconv.FormatInt(state.Pipeline.Time, 10)
state.Pipeline.Step.Environment["CI_JOB_FINISHED"] = strconv.FormatInt(time.Now().Unix(), 10)
state.Pipeline.Step.Environment["CI_SYSTEM_ARCH"] = runtime.GOOS + "/" + runtime.GOARCH
if state.Pipeline.Error != nil {
state.Pipeline.Step.Environment["CI_PIPELINE_STATUS"] = "failure"
state.Pipeline.Step.Environment["CI_STEP_STATUS"] = "failure"
// DEPRECATED
state.Pipeline.Step.Environment["CI_BUILD_STATUS"] = "failure"
state.Pipeline.Step.Environment["CI_JOB_STATUS"] = "failure"