From 661dd01e2f3a9eb1490218101135e1eb297408ad Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 25 Sep 2023 14:50:31 -0400 Subject: [PATCH] Fix incorrectly usage pipeline_specs.id instead of jobs.id (#10781) 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. --- core/services/ocr2/delegate.go | 12 +++++------ core/services/ocr2/plugins/median/services.go | 2 +- core/services/ocrbootstrap/delegate.go | 20 +++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/core/services/ocr2/delegate.go b/core/services/ocr2/delegate.go index 4168ed6c61b..2086eaa6a80 100644 --- a/core/services/ocr2/delegate.go +++ b/core/services/ocr2/delegate.go @@ -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(), @@ -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(), @@ -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(), @@ -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(), @@ -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{ @@ -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, diff --git a/core/services/ocr2/plugins/median/services.go b/core/services/ocr2/plugins/median/services.go index 562c0fa34f1..8d121083f3f 100644 --- a/core/services/ocr2/plugins/median/services.go +++ b/core/services/ocr2/plugins/median/services.go @@ -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(), diff --git a/core/services/ocrbootstrap/delegate.go b/core/services/ocrbootstrap/delegate.go index d530797367f..9f9efca68e2 100644 --- a/core/services/ocrbootstrap/delegate.go +++ b/core/services/ocrbootstrap/delegate.go @@ -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") @@ -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, } @@ -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, @@ -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(), @@ -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(), }