Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update process execution only once #433

Merged
merged 1 commit into from
Sep 10, 2018
Merged
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
35 changes: 21 additions & 14 deletions dkron/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"net"
"time"

"github.com/sirupsen/logrus"
"github.com/abronan/valkeyrie/store"
metrics "github.com/armon/go-metrics"
"github.com/sirupsen/logrus"
"github.com/victorcoder/dkron/proto"
"golang.org/x/net/context"
"google.golang.org/grpc"
Expand Down Expand Up @@ -88,6 +88,9 @@ func (grpcs *GRPCServer) ExecutionDone(ctx context.Context, execDoneReq *proto.E
"job": execDoneReq.JobName,
}).Debug("grpc: Received execution done")

var execution Execution
processed := false

retry:
// Load the job from the store
job, jkv, err := grpcs.agent.Store.GetJobWithKVPair(execDoneReq.JobName, &JobOptions{
Expand All @@ -102,21 +105,25 @@ retry:
return nil, err
}

// Get the defined output types for the job, and call them
origExec := *NewExecutionFromProto(execDoneReq)
execution := origExec
for k, v := range job.Processors {
log.WithField("plugin", k).Debug("grpc: Processing execution with plugin")
if processor, ok := grpcs.agent.ProcessorPlugins[k]; ok {
v["reporting_node"] = grpcs.agent.config.NodeName
e := processor.Process(&ExecutionProcessorArgs{Execution: origExec, Config: v})
execution = e
if !processed {
// Get the defined output types for the job, and call them
origExec := *NewExecutionFromProto(execDoneReq)
execution = origExec
for k, v := range job.Processors {
log.WithField("plugin", k).Debug("grpc: Processing execution with plugin")
if processor, ok := grpcs.agent.ProcessorPlugins[k]; ok {
v["reporting_node"] = grpcs.agent.config.NodeName
e := processor.Process(&ExecutionProcessorArgs{Execution: origExec, Config: v})
execution = e
}
}

// Save the execution to store
if _, err := grpcs.agent.Store.SetExecution(&execution); err != nil {
return nil, err
}
}

// Save the execution to store
if _, err := grpcs.agent.Store.SetExecution(&execution); err != nil {
return nil, err
processed = true
}

if execution.Success {
Expand Down