[Fixes atc/worker - refactor cloneRemoteVolumes
@@ -8,7 +8,6 @@ import (
"context"
"errors"
"fmt"
- "github.com/concourse/concourse/tracing"
"path/filepath"
"sort"
"strings"
@@ -23,6 +22,7 @@ import (
"github.com/concourse/concourse/atc/resource"
"github.com/concourse/concourse/atc/runtime"
"github.com/concourse/concourse/atc/worker/gclient"
+ "github.com/concourse/concourse/tracing"
"github.com/cppforlife/go-semi-semantic/version"
"golang.org/x/sync/errgroup"
)
@@ -505,9 +505,7 @@ func (worker *gardenWorker) createVolumes(
return nil, err
}
- streamedMounts := []VolumeMount{}
- if len(nonlocalInputs) > 0 {
- streamedMounts, err = worker.cloneRemoteVolumes(
+ streamedMounts, err := worker.cloneRemoteVolumes(
ctx,
logger,
spec.TeamID,
@@ -518,7 +516,6 @@ func (worker *gardenWorker) createVolumes(
if err != nil {
return nil, err
}
- }
ioVolumeMounts = append(ioVolumeMounts, cowMounts...)
ioVolumeMounts = append(ioVolumeMounts, streamedMounts...)
@@ -600,10 +597,14 @@ func (worker *gardenWorker) cloneRemoteVolumes(
nonLocals []mountableRemoteInput,
) ([]VolumeMount, error) {
+ mounts := make([]VolumeMount, len(nonLocals))
+ if len(nonLocals) <= 0 {
+ return mounts, nil
+ }
+
ctx, span := tracing.StartSpan(ctx, "worker.cloneRemoteVolumes", tracing.Attrs{"container_id": container.Handle()})
defer span.End()
- mounts := make([]VolumeMount, len(nonLocals))
g, groupCtx := errgroup.WithContext(ctx)
for i, nonLocalInput := range nonLocals {
@@ -647,9 +648,7 @@ func (worker *gardenWorker) cloneRemoteVolumes(
return nil, err
}
- if len(nonLocals) > 0 {
logger.Debug("streamed-non-local-volumes", lager.Data{"volumes-streamed": len(nonLocals)})
- }
return mounts, nil
}
