diff --git a/pkg/executor/docker/executor.go b/pkg/executor/docker/executor.go index 352960a020..80d65ca05e 100644 --- a/pkg/executor/docker/executor.go +++ b/pkg/executor/docker/executor.go @@ -17,7 +17,7 @@ import ( "github.com/bacalhau-project/bacalhau/pkg/storage" "github.com/bacalhau-project/bacalhau/pkg/storage/util" "github.com/bacalhau-project/bacalhau/pkg/system" - "github.com/bacalhau-project/bacalhau/pkg/telemetry" + pkgUtil "github.com/bacalhau-project/bacalhau/pkg/util" dockertypes "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/mount" @@ -288,7 +288,7 @@ func (e *Executor) RunShard( } // Can't use the original context as it may have already been timed out - detachedContext, cancel := context.WithTimeout(telemetry.NewDetachedContext(ctx), 3*time.Second) + detachedContext, cancel := context.WithTimeout(pkgUtil.NewDetachedContext(ctx), 3*time.Second) defer cancel() stdoutPipe, stderrPipe, logsErr := e.client.FollowLogs(detachedContext, jobContainer.ID) log.Ctx(detachedContext).Debug().Err(logsErr).Msg("Captured stdout/stderr for container") @@ -304,7 +304,7 @@ func (e *Executor) RunShard( func (e *Executor) cleanupJob(ctx context.Context, shard model.JobShard) { // Use a detached context in case the current one has already been canceled - separateCtx, cancel := context.WithTimeout(telemetry.NewDetachedContext(ctx), 1*time.Minute) + separateCtx, cancel := context.WithTimeout(pkgUtil.NewDetachedContext(ctx), 1*time.Minute) defer cancel() if config.ShouldKeepStack() || !e.client.IsInstalled(separateCtx) { return @@ -318,7 +318,7 @@ func (e *Executor) cleanupJob(ctx context.Context, shard model.JobShard) { func (e *Executor) cleanupAll(ctx context.Context) error { // We have to use a detached context, rather than the one passed in to `NewExecutor`, as it may have already been // canceled and so would prevent us from performing any cleanup work. - safeCtx := telemetry.NewDetachedContext(ctx) + safeCtx := pkgUtil.NewDetachedContext(ctx) if config.ShouldKeepStack() || !e.client.IsInstalled(safeCtx) { return nil } diff --git a/pkg/system/cleanup.go b/pkg/system/cleanup.go index 812216f044..dd9aef13ef 100644 --- a/pkg/system/cleanup.go +++ b/pkg/system/cleanup.go @@ -6,7 +6,7 @@ import ( realsync "sync" "time" - "github.com/bacalhau-project/bacalhau/pkg/telemetry" + "github.com/bacalhau-project/bacalhau/pkg/util" sync "github.com/bacalhau-project/golang-mutex-tracer" "github.com/rs/zerolog/log" ) @@ -66,7 +66,7 @@ func (cm *CleanupManager) Cleanup(ctx context.Context) { var wg realsync.WaitGroup wg.Add(len(cm.fns)) - detachedContext := telemetry.NewDetachedContext(ctx) + detachedContext := util.NewDetachedContext(ctx) for i := 0; i < len(cm.fns); i++ { go func(fn any) { diff --git a/pkg/telemetry/context.go b/pkg/util/context.go similarity index 97% rename from pkg/telemetry/context.go rename to pkg/util/context.go index 858c1e3735..c2a360b10f 100644 --- a/pkg/telemetry/context.go +++ b/pkg/util/context.go @@ -1,4 +1,4 @@ -package telemetry +package util import ( "context" diff --git a/pkg/telemetry/context_test.go b/pkg/util/context_test.go similarity index 97% rename from pkg/telemetry/context_test.go rename to pkg/util/context_test.go index cfb45e35b5..3a785a6ff9 100644 --- a/pkg/telemetry/context_test.go +++ b/pkg/util/context_test.go @@ -1,9 +1,10 @@ -package telemetry +package util import ( "context" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestDetachedContext_Value_valuesPassedThrough(t *testing.T) {