Skip to content

Commit

Permalink
Fix incorrectly usage pipeline_specs.id instead of jobs.id (#10781)
Browse files Browse the repository at this point in the history
This was causing FK issues in mercury and is particularly insidious
because in test code these IDs are usually accidentally the same, so it
only shows up in diverse prod environments.
  • Loading branch information
samsondav authored Sep 25, 2023
1 parent 54223e7 commit 661dd01
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (d *Delegate) cleanupEVM(jb job.Job, q pg.Queryer, relayID relay.ID) error

rargs := types.RelayArgs{
ExternalJobID: jb.ExternalJobID,
JobID: spec.ID,
JobID: jb.ID,
ContractID: spec.ContractID,
New: false,
RelayConfig: spec.RelayConfig.Bytes(),
Expand Down Expand Up @@ -517,7 +517,7 @@ func (d *Delegate) newServicesMercury(
provider, err2 := relayer.NewPluginProvider(ctx,
types.RelayArgs{
ExternalJobID: jb.ExternalJobID,
JobID: spec.ID,
JobID: jb.ID,
ContractID: spec.ContractID,
New: d.isNewlyCreatedJob,
RelayConfig: spec.RelayConfig.Bytes(),
Expand Down Expand Up @@ -632,7 +632,7 @@ func (d *Delegate) newServicesDKG(
dkgProvider, err2 := ocr2vrfRelayer.NewDKGProvider(
types.RelayArgs{
ExternalJobID: jb.ExternalJobID,
JobID: spec.ID,
JobID: jb.ID,
ContractID: spec.ContractID,
New: d.isNewlyCreatedJob,
RelayConfig: spec.RelayConfig.Bytes(),
Expand Down Expand Up @@ -717,7 +717,7 @@ func (d *Delegate) newServicesOCR2VRF(
vrfProvider, err2 := ocr2vrfRelayer.NewOCR2VRFProvider(
types.RelayArgs{
ExternalJobID: jb.ExternalJobID,
JobID: spec.ID,
JobID: jb.ID,
ContractID: spec.ContractID,
New: d.isNewlyCreatedJob,
RelayConfig: spec.RelayConfig.Bytes(),
Expand All @@ -732,7 +732,7 @@ func (d *Delegate) newServicesOCR2VRF(
dkgProvider, err2 := ocr2vrfRelayer.NewDKGProvider(
types.RelayArgs{
ExternalJobID: jb.ExternalJobID,
JobID: spec.ID,
JobID: jb.ID,
ContractID: cfg.DKGContractAddress,
RelayConfig: spec.RelayConfig.Bytes(),
}, types.PluginArgs{
Expand Down Expand Up @@ -1175,7 +1175,7 @@ func (d *Delegate) newServicesOCR2Functions(
chain,
types.RelayArgs{
ExternalJobID: jb.ExternalJobID,
JobID: spec.ID,
JobID: jb.ID,
ContractID: spec.ContractID,
RelayConfig: spec.RelayConfig.Bytes(),
New: d.isNewlyCreatedJob,
Expand Down
2 changes: 1 addition & 1 deletion core/services/ocr2/plugins/median/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func NewMedianServices(ctx context.Context,

provider, err := relayer.NewPluginProvider(ctx, types.RelayArgs{
ExternalJobID: jb.ExternalJobID,
JobID: spec.ID,
JobID: jb.ID,
ContractID: spec.ContractID,
New: isNewlyCreatedJob,
RelayConfig: spec.RelayConfig.Bytes(),
Expand Down
20 changes: 10 additions & 10 deletions core/services/ocrbootstrap/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ func (d *Delegate) BeforeJobCreated(spec job.Job) {
}

// ServicesForSpec satisfies the job.Delegate interface.
func (d *Delegate) ServicesForSpec(jobSpec job.Job, qopts ...pg.QOpt) (services []job.ServiceCtx, err error) {
spec := jobSpec.BootstrapSpec
func (d *Delegate) ServicesForSpec(jb job.Job, qopts ...pg.QOpt) (services []job.ServiceCtx, err error) {
spec := jb.BootstrapSpec
if spec == nil {
return nil, errors.Errorf("Bootstrap.Delegate expects an *job.BootstrapSpec to be present, got %v", jobSpec)
return nil, errors.Errorf("Bootstrap.Delegate expects an *job.BootstrapSpec to be present, got %v", jb)
}
if d.peerWrapper == nil {
return nil, errors.New("cannot setup OCR2 job service, libp2p peer was missing")
Expand All @@ -101,8 +101,8 @@ func (d *Delegate) ServicesForSpec(jobSpec job.Job, qopts ...pg.QOpt) (services
}

ctxVals := loop.ContextValues{
JobID: jobSpec.ID,
JobName: jobSpec.Name.ValueOrZero(),
JobID: jb.ID,
JobName: jb.Name.ValueOrZero(),
ContractID: spec.ContractID,
FeedID: spec.FeedID,
}
Expand All @@ -121,8 +121,8 @@ func (d *Delegate) ServicesForSpec(jobSpec job.Job, qopts ...pg.QOpt) (services
configProvider, err = relayer.NewPluginProvider(
ctx,
types.RelayArgs{
ExternalJobID: jobSpec.ExternalJobID,
JobID: spec.ID,
ExternalJobID: jb.ExternalJobID,
JobID: jb.ID,
ContractID: spec.ContractID,
RelayConfig: spec.RelayConfig.Bytes(),
New: d.isNewlyCreatedJob,
Expand All @@ -134,8 +134,8 @@ func (d *Delegate) ServicesForSpec(jobSpec job.Job, qopts ...pg.QOpt) (services
)
} else {
configProvider, err = relayer.NewConfigProvider(ctx, types.RelayArgs{
ExternalJobID: jobSpec.ExternalJobID,
JobID: spec.ID,
ExternalJobID: jb.ExternalJobID,
JobID: jb.ID,
ContractID: spec.ContractID,
New: d.isNewlyCreatedJob,
RelayConfig: spec.RelayConfig.Bytes(),
Expand Down Expand Up @@ -166,7 +166,7 @@ func (d *Delegate) ServicesForSpec(jobSpec job.Job, qopts ...pg.QOpt) (services
Database: NewDB(d.db.DB, spec.ID, lggr),
LocalConfig: lc,
Logger: relaylogger.NewOCRWrapper(lggr.Named("OCRBootstrap"), d.ocr2Cfg.TraceLogging(), func(msg string) {
logger.Sugared(lggr).ErrorIf(d.jobORM.RecordError(jobSpec.ID, msg), "unable to record error")
logger.Sugared(lggr).ErrorIf(d.jobORM.RecordError(jb.ID, msg), "unable to record error")
}),
OffchainConfigDigester: configProvider.OffchainConfigDigester(),
}
Expand Down

0 comments on commit 661dd01

Please sign in to comment.