Skip to content

Commit 9409d9a

Browse files
authored
Merge pull request #577 from textileio/jsign/fx
fil: avoid tracker and retrieval modules if archiving is disabled
2 parents b253325 + 6e82c24 commit 9409d9a

2 files changed

Lines changed: 39 additions & 33 deletions

File tree

buckets/archive/tracker/tracker.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ func (t *Tracker) checkPendingTrackings() {
162162

163163
// processTrackedJob checks the status of the Job in Powergate, which
164164
// corresponds to bucket Archive action.
165-
// - If Job was successful: change its status as to not be tracked anymore,
166-
// and call corresponding logic depending if was created for an Archive or Retrieval.
167-
// - If Job failed: change its status to not being tracked anymore.
168-
// - If encountered a transient error: It will reschedule the tracked job to
169-
// be evaluated in a further iteration.
165+
// - If Job was successful: change its status as to not be tracked anymore,
166+
// and call corresponding logic depending if was created for an Archive or Retrieval.
167+
// - If Job failed: change its status to not being tracked anymore.
168+
// - If encountered a transient error: It will reschedule the tracked job to
169+
// be evaluated in a further iteration.
170170
func (t *Tracker) processTrackedJob(a *mdb.TrackedJob) error {
171171
ctx, cancel := context.WithTimeout(t.ctx, time.Second*10)
172172
defer cancel()

core/core.go

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -351,27 +351,29 @@ func NewTextile(ctx context.Context, conf Config, opts ...Option) (*Textile, err
351351
}
352352

353353
jobFinalizedEvents := make(chan archive.JobEvent)
354-
t.archiveTracker, err = tracker.New(
355-
t.collections,
356-
t.bucks,
357-
t.pc,
358-
t.internalHubSession,
359-
conf.ArchiveJobPollIntervalSlow,
360-
conf.ArchiveJobPollIntervalFast,
361-
jobFinalizedEvents,
362-
)
363-
if err != nil {
364-
return nil, err
365-
}
366354

367-
filRetrievalDS := kt.WrapTxnDatastore(t.ts, ktipfs.PrefixTransform{
368-
Prefix: datastore.NewKey("buckets/filretrieval"),
369-
})
370-
t.filRetrieval, err = retrieval.NewFilRetrieval(filRetrievalDS, t.pc, t.archiveTracker, jobFinalizedEvents, t.internalHubSession)
371-
if err != nil {
372-
return nil, err
373-
}
355+
if t.pc != nil {
356+
t.archiveTracker, err = tracker.New(
357+
t.collections,
358+
t.bucks,
359+
t.pc,
360+
t.internalHubSession,
361+
conf.ArchiveJobPollIntervalSlow,
362+
conf.ArchiveJobPollIntervalFast,
363+
jobFinalizedEvents,
364+
)
365+
if err != nil {
366+
return nil, err
367+
}
374368

369+
filRetrievalDS := kt.WrapTxnDatastore(t.ts, ktipfs.PrefixTransform{
370+
Prefix: datastore.NewKey("buckets/filretrieval"),
371+
})
372+
t.filRetrieval, err = retrieval.NewFilRetrieval(filRetrievalDS, t.pc, t.archiveTracker, jobFinalizedEvents, t.internalHubSession)
373+
if err != nil {
374+
return nil, err
375+
}
376+
}
375377
var hs *hubd.Service
376378
var us *usersd.Service
377379
if conf.Hub {
@@ -429,10 +431,12 @@ func NewTextile(ctx context.Context, conf Config, opts ...Option) (*Textile, err
429431
FilRetrieval: t.filRetrieval,
430432
}
431433

432-
// We can avoid the chicken-egg-problem of below line in the future.
433-
// For more info, see "TODO(**)" in buckd/service.go
434-
t.filRetrieval.SetBucketCreator(bs)
435-
t.filRetrieval.RunDaemon()
434+
if t.filRetrieval != nil {
435+
// We can avoid the chicken-egg-problem of below line in the future.
436+
// For more info, see "TODO(**)" in buckd/service.go
437+
t.filRetrieval.SetBucketCreator(bs)
438+
t.filRetrieval.RunDaemon()
439+
}
436440

437441
// Start serving
438442
ptarget, err := tutil.TCPAddrFromMultiAddr(conf.AddrAPIProxy)
@@ -607,11 +611,13 @@ func (t *Textile) Close() error {
607611
}
608612
log.Info("gRPC was shutdown")
609613

610-
log.Info("closing fil-retrieval module")
611-
if err := t.filRetrieval.Close(); err != nil {
612-
log.Errorf("closing fil-retrieval module: %s", err)
613-
} else {
614-
log.Info("fil-retrieval was shutdown")
614+
if t.filRetrieval != nil {
615+
log.Info("closing fil-retrieval module")
616+
if err := t.filRetrieval.Close(); err != nil {
617+
log.Errorf("closing fil-retrieval module: %s", err)
618+
} else {
619+
log.Info("fil-retrieval was shutdown")
620+
}
615621
}
616622

617623
if err := t.th.Close(); err != nil {

0 commit comments

Comments
 (0)