Skip to content
Merged
Show file tree
Hide file tree
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
30 changes: 15 additions & 15 deletions compute/gcp_batch/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ package gcp_batch
import (
"context"
"fmt"
"path"
"strings"
"time"

batch "cloud.google.com/go/batch/apiv1"
"cloud.google.com/go/batch/apiv1/batchpb"
"cloud.google.com/go/logging"
logadmin "cloud.google.com/go/logging/apiv2"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/ohsu-comp-bio/funnel/config"
"github.com/ohsu-comp-bio/funnel/events"
"github.com/ohsu-comp-bio/funnel/logger"
"github.com/ohsu-comp-bio/funnel/storage"
"github.com/ohsu-comp-bio/funnel/tes"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
)

Expand Down Expand Up @@ -403,27 +404,22 @@ ReconcileLoop:
}
pageToken = lresp.NextPageToken

// Map TES Task → GCP Batch Job
// Map Funnel task ID → task. The GCP job name is always
// "projects/.../jobs/<task-id>" so we match on path.Base(j.Name).
tmap := make(map[string]*tes.Task)
var jobs []*string
for _, t := range lresp.Tasks {
jobid := b.getTaskID(t)
b.log.Debug("Checking task for GCP Batch job ID",
b.log.Debug("Queueing task for reconciliation",
"taskID", t.Id,
"gcpbatch_uid", jobid,
"state", t.State)
if jobid != "" {
tmap[jobid] = t
jobs = append(jobs, aws.String(jobid))
}
tmap[t.Id] = t
}

b.log.Debug("Tasks to reconcile",
"count", len(jobs),
"count", len(tmap),
"state", s)

// Last page of jobs from the Funnel Database
if len(jobs) == 0 {
// Nothing to reconcile on this page — advance or stop.
if len(tmap) == 0 {
if pageToken == "" {
break
}
Expand All @@ -441,12 +437,16 @@ ReconcileLoop:

for {
j, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
b.log.Error("ListJobs iterator error", err)
break
}

// If Job is in our list
task, ok := tmap[j.Uid]
// Match by job name suffix, which equals the Funnel task ID.
task, ok := tmap[path.Base(j.Name)]
if !ok {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func DefaultConfig() *Config {
c.GCPBatch.Project = "example-gcp-project"
c.GCPBatch.Location = "us-central1"
c.GCPBatch.ReconcileRate = reconcile
c.GCPBatch.DisableReconciler = true
c.GCPBatch.DisableReconciler = false

// Kubernetes Configs moved to Helm Charts:
// https://github.com/ohsu-comp-bio/helm-charts/tree/main/charts/funnel
Expand Down
Loading