worker: rename backend to runtime

Rename the backend directory and package to runtime. This should make it easier for contributors to locate container runtime specific code.

concourse/5510

Signed-off-by: Muntasir Chowdhury <muntasir.mzc@gmail.com>
This commit is contained in:
Muntasir Chowdhury 2020-05-13 09:24:10 -04:00 committed by Muntasir Chowdhury
parent 38a3a92c10
commit 2bfcfb419d
50 changed files with 134 additions and 134 deletions

2
.gitignore vendored
View File

@ -18,4 +18,4 @@ ci/deployments/*/keys/id_rsa.pub
hack/vault/certs
hack/vault/init.json
worker/backend/integration/sample/sample
worker/runtime/integration/sample/sample

View File

@ -3,7 +3,7 @@
//
// See https://containerd.io/, and https://github.com/cloudfoundry/garden.
//
package backend
package runtime
import (
"context"
@ -11,8 +11,8 @@ import (
"time"
"code.cloudfoundry.org/garden"
"github.com/concourse/concourse/worker/backend/libcontainerd"
bespec "github.com/concourse/concourse/worker/backend/spec"
"github.com/concourse/concourse/worker/runtime/libcontainerd"
bespec "github.com/concourse/concourse/worker/runtime/spec"
"github.com/containerd/containerd"
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/errdefs"

View File

@ -1,4 +1,4 @@
package backend_test
package runtime_test
import (
"errors"
@ -7,9 +7,9 @@ import (
"code.cloudfoundry.org/garden"
"code.cloudfoundry.org/garden/gardenfakes"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/backend/backendfakes"
"github.com/concourse/concourse/worker/backend/libcontainerd/libcontainerdfakes"
"github.com/concourse/concourse/worker/runtime"
"github.com/concourse/concourse/worker/runtime/backendfakes"
"github.com/concourse/concourse/worker/runtime/libcontainerd/libcontainerdfakes"
"github.com/containerd/containerd"
"github.com/containerd/containerd/errdefs"
"github.com/stretchr/testify/require"
@ -20,7 +20,7 @@ type BackendSuite struct {
suite.Suite
*require.Assertions
backend backend.Backend
backend runtime.Backend
client *libcontainerdfakes.FakeClient
network *backendfakes.FakeNetwork
userns *backendfakes.FakeUserNamespace
@ -34,16 +34,16 @@ func (s *BackendSuite) SetupTest() {
s.userns = new(backendfakes.FakeUserNamespace)
var err error
s.backend, err = backend.New(s.client,
backend.WithKiller(s.killer),
backend.WithNetwork(s.network),
backend.WithUserNamespace(s.userns),
s.backend, err = runtime.New(s.client,
runtime.WithKiller(s.killer),
runtime.WithNetwork(s.network),
runtime.WithUserNamespace(s.userns),
)
s.NoError(err)
}
func (s *BackendSuite) TestNew() {
_, err := backend.New(nil)
_, err := runtime.New(nil)
s.EqualError(err, "nil client")
}
@ -316,7 +316,7 @@ func (s *BackendSuite) TestDestroyKillTaskFails() {
err := s.backend.Destroy("some handle")
s.True(errors.Is(err, expectedError))
_, _, behaviour := s.killer.KillArgsForCall(0)
s.Equal(backend.KillGracefully, behaviour)
s.Equal(runtime.KillGracefully, behaviour)
}
func (s *BackendSuite) TestDestroyRemoveNetworkFails() {

View File

@ -4,7 +4,7 @@ package backendfakes
import (
"sync"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/runtime"
)
type FakeFileStore struct {
@ -192,4 +192,4 @@ func (fake *FakeFileStore) recordInvocation(key string, args []interface{}) {
fake.invocations[key] = append(fake.invocations[key], args)
}
var _ backend.FileStore = new(FakeFileStore)
var _ runtime.FileStore = new(FakeFileStore)

View File

@ -5,17 +5,17 @@ import (
"context"
"sync"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/runtime"
"github.com/containerd/containerd"
)
type FakeKiller struct {
KillStub func(context.Context, containerd.Task, backend.KillBehaviour) error
KillStub func(context.Context, containerd.Task, runtime.KillBehaviour) error
killMutex sync.RWMutex
killArgsForCall []struct {
arg1 context.Context
arg2 containerd.Task
arg3 backend.KillBehaviour
arg3 runtime.KillBehaviour
}
killReturns struct {
result1 error
@ -27,13 +27,13 @@ type FakeKiller struct {
invocationsMutex sync.RWMutex
}
func (fake *FakeKiller) Kill(arg1 context.Context, arg2 containerd.Task, arg3 backend.KillBehaviour) error {
func (fake *FakeKiller) Kill(arg1 context.Context, arg2 containerd.Task, arg3 runtime.KillBehaviour) error {
fake.killMutex.Lock()
ret, specificReturn := fake.killReturnsOnCall[len(fake.killArgsForCall)]
fake.killArgsForCall = append(fake.killArgsForCall, struct {
arg1 context.Context
arg2 containerd.Task
arg3 backend.KillBehaviour
arg3 runtime.KillBehaviour
}{arg1, arg2, arg3})
fake.recordInvocation("Kill", []interface{}{arg1, arg2, arg3})
fake.killMutex.Unlock()
@ -53,13 +53,13 @@ func (fake *FakeKiller) KillCallCount() int {
return len(fake.killArgsForCall)
}
func (fake *FakeKiller) KillCalls(stub func(context.Context, containerd.Task, backend.KillBehaviour) error) {
func (fake *FakeKiller) KillCalls(stub func(context.Context, containerd.Task, runtime.KillBehaviour) error) {
fake.killMutex.Lock()
defer fake.killMutex.Unlock()
fake.KillStub = stub
}
func (fake *FakeKiller) KillArgsForCall(i int) (context.Context, containerd.Task, backend.KillBehaviour) {
func (fake *FakeKiller) KillArgsForCall(i int) (context.Context, containerd.Task, runtime.KillBehaviour) {
fake.killMutex.RLock()
defer fake.killMutex.RUnlock()
argsForCall := fake.killArgsForCall[i]
@ -113,4 +113,4 @@ func (fake *FakeKiller) recordInvocation(key string, args []interface{}) {
fake.invocations[key] = append(fake.invocations[key], args)
}
var _ backend.Killer = new(FakeKiller)
var _ runtime.Killer = new(FakeKiller)

View File

@ -5,7 +5,7 @@ import (
"context"
"sync"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/runtime"
"github.com/containerd/containerd"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
@ -265,4 +265,4 @@ func (fake *FakeNetwork) recordInvocation(key string, args []interface{}) {
fake.invocations[key] = append(fake.invocations[key], args)
}
var _ backend.Network = new(FakeNetwork)
var _ runtime.Network = new(FakeNetwork)

View File

@ -7,7 +7,7 @@ import (
"syscall"
"time"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/runtime"
"github.com/containerd/containerd"
)
@ -117,4 +117,4 @@ func (fake *FakeProcessKiller) recordInvocation(key string, args []interface{})
fake.invocations[key] = append(fake.invocations[key], args)
}
var _ backend.ProcessKiller = new(FakeProcessKiller)
var _ runtime.ProcessKiller = new(FakeProcessKiller)

View File

@ -4,7 +4,7 @@ package backendfakes
import (
"sync"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/runtime"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
@ -110,4 +110,4 @@ func (fake *FakeRootfsManager) recordInvocation(key string, args []interface{})
fake.invocations[key] = append(fake.invocations[key], args)
}
var _ backend.RootfsManager = new(FakeRootfsManager)
var _ runtime.RootfsManager = new(FakeRootfsManager)

View File

@ -4,7 +4,7 @@ package backendfakes
import (
"sync"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/runtime"
)
type FakeUserNamespace struct {
@ -108,4 +108,4 @@ func (fake *FakeUserNamespace) recordInvocation(key string, args []interface{})
fake.invocations[key] = append(fake.invocations[key], args)
}
var _ backend.UserNamespace = new(FakeUserNamespace)
var _ runtime.UserNamespace = new(FakeUserNamespace)

View File

@ -1,4 +1,4 @@
package backend
package runtime
import (
"context"

View File

@ -1,12 +1,12 @@
package backend_test
package runtime_test
import (
"context"
"errors"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/backend/backendfakes"
"github.com/concourse/concourse/worker/backend/libcontainerd/libcontainerdfakes"
"github.com/concourse/concourse/worker/runtime"
"github.com/concourse/concourse/worker/runtime/backendfakes"
"github.com/concourse/concourse/worker/runtime/libcontainerd/libcontainerdfakes"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
@ -16,7 +16,7 @@ type CNINetworkSuite struct {
suite.Suite
*require.Assertions
network backend.Network
network runtime.Network
cni *backendfakes.FakeCNI
store *backendfakes.FakeFileStore
}
@ -26,9 +26,9 @@ func (s *CNINetworkSuite) SetupTest() {
s.store = new(backendfakes.FakeFileStore)
s.cni = new(backendfakes.FakeCNI)
s.network, err = backend.NewCNINetwork(
backend.WithCNIFileStore(s.store),
backend.WithCNIClient(s.cni),
s.network, err = runtime.NewCNINetwork(
runtime.WithCNIFileStore(s.store),
runtime.WithCNIClient(s.cni),
)
s.NoError(err)
}
@ -37,8 +37,8 @@ func (s *CNINetworkSuite) TestNewCNINetworkWithInvalidConfigDoesntFail() {
// CNI defers the actual interpretation of the network configuration to
// the plugins.
//
_, err := backend.NewCNINetwork(
backend.WithCNINetworkConfig(backend.CNINetworkConfig{
_, err := runtime.NewCNINetwork(
runtime.WithCNINetworkConfig(runtime.CNINetworkConfig{
Subnet: "_____________",
}),
)
@ -99,8 +99,8 @@ func (s *CNINetworkSuite) TestSetupMountsReturnsMountpoints() {
}
func (s *CNINetworkSuite) TestSetupMountsCallsStoreWithNoNameServer() {
network, err := backend.NewCNINetwork(
backend.WithCNIFileStore(s.store),
network, err := runtime.NewCNINetwork(
runtime.WithCNIFileStore(s.store),
)
s.NoError(err)
@ -112,9 +112,9 @@ func (s *CNINetworkSuite) TestSetupMountsCallsStoreWithNoNameServer() {
}
func (s *CNINetworkSuite) TestSetupMountsCallsStoreWithOneNameServer() {
network, err := backend.NewCNINetwork(
backend.WithCNIFileStore(s.store),
backend.WithNameServers([]string{"6.6.7.7", "1.2.3.4"}),
network, err := runtime.NewCNINetwork(
runtime.WithCNIFileStore(s.store),
runtime.WithNameServers([]string{"6.6.7.7", "1.2.3.4"}),
)
s.NoError(err)

View File

@ -1,4 +1,4 @@
package backend
package runtime
import (
"context"

View File

@ -1,12 +1,12 @@
package backend_test
package runtime_test
import (
"errors"
"code.cloudfoundry.org/garden"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/backend/backendfakes"
"github.com/concourse/concourse/worker/backend/libcontainerd/libcontainerdfakes"
"github.com/concourse/concourse/worker/runtime"
"github.com/concourse/concourse/worker/runtime/backendfakes"
"github.com/concourse/concourse/worker/runtime/libcontainerd/libcontainerdfakes"
"github.com/containerd/containerd"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/stretchr/testify/require"
@ -17,7 +17,7 @@ type ContainerSuite struct {
suite.Suite
*require.Assertions
container *backend.Container
container *runtime.Container
containerdContainer *libcontainerdfakes.FakeContainer
containerdProcess *libcontainerdfakes.FakeProcess
containerdTask *libcontainerdfakes.FakeTask
@ -32,7 +32,7 @@ func (s *ContainerSuite) SetupTest() {
s.rootfsManager = new(backendfakes.FakeRootfsManager)
s.killer = new(backendfakes.FakeKiller)
s.container = backend.NewContainer(
s.container = runtime.NewContainer(
s.containerdContainer,
s.killer,
s.rootfsManager,
@ -213,7 +213,7 @@ func (s *ContainerSuite) TestPropertyGetLabelsFails() {
func (s *ContainerSuite) TestPropertyNotFound() {
s.containerdContainer.LabelsReturns(garden.Properties{}, nil)
_, err := s.container.Property("any")
s.Equal(backend.ErrNotFound("any"), err)
s.Equal(runtime.ErrNotFound("any"), err)
}
func (s *ContainerSuite) TestPropertyReturnsValue() {

View File

@ -1,4 +1,4 @@
package backend
package runtime
import "errors"

View File

@ -1,4 +1,4 @@
package backend
package runtime
import (
"fmt"

View File

@ -1,11 +1,11 @@
package backend_test
package runtime_test
import (
"io/ioutil"
"os"
"path/filepath"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/runtime"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
@ -15,7 +15,7 @@ type FileStoreSuite struct {
*require.Assertions
rootfs string
store backend.FileStore
store runtime.FileStore
}
func (s *FileStoreSuite) SetupTest() {
@ -24,7 +24,7 @@ func (s *FileStoreSuite) SetupTest() {
s.rootfs, err = ioutil.TempDir("", "bcknd-filestore")
s.NoError(err)
s.store = backend.NewFileStore(s.rootfs)
s.store = runtime.NewFileStore(s.rootfs)
}
func (s *FileStoreSuite) TearDownTest() {

View File

@ -11,8 +11,8 @@ import (
"time"
"code.cloudfoundry.org/garden"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/backend/libcontainerd"
"github.com/concourse/concourse/worker/runtime"
"github.com/concourse/concourse/worker/runtime/libcontainerd"
"github.com/concourse/concourse/worker/workercmd"
"github.com/containerd/containerd"
"github.com/stretchr/testify/require"
@ -24,7 +24,7 @@ type IntegrationSuite struct {
suite.Suite
*require.Assertions
backend backend.Backend
backend runtime.Backend
client *libcontainerd.Client
containerdProcess ifrit.Process
rootfs string
@ -90,7 +90,7 @@ func (s *IntegrationSuite) SetupTest() {
requestTimeout = 3 * time.Second
)
s.backend, err = backend.New(
s.backend, err = runtime.New(
libcontainerd.New(
s.containerdSocket(),
namespace,
@ -218,7 +218,7 @@ func (s *IntegrationSuite) TestRunPrivileged() {
// to execute the executable in there.
//
func (s *IntegrationSuite) TestRunUnprivileged() {
maxUid, maxGid, err := backend.NewUserNamespace().MaxValidIds()
maxUid, maxGid, err := runtime.NewUserNamespace().MaxValidIds()
s.NoError(err)
filepath.Walk(s.rootfs, func(path string, _ os.FileInfo, _ error) error {
@ -355,15 +355,15 @@ func (s *IntegrationSuite) TestCustomDNS() {
namespace := "test-custom-dns"
requestTimeout := 3 * time.Second
network, err := backend.NewCNINetwork(
backend.WithNameServers([]string{
network, err := runtime.NewCNINetwork(
runtime.WithNameServers([]string{
"1.1.1.1", "1.2.3.4",
}),
)
s.NoError(err)
networkOpt := backend.WithNetwork(network)
customBackend, err := backend.New(
networkOpt := runtime.WithNetwork(network)
customBackend, err := runtime.New(
libcontainerd.New(
s.containerdSocket(),
namespace,

View File

@ -1,4 +1,4 @@
package backend
package runtime
import (
"context"

View File

@ -1,13 +1,13 @@
package backend_test
package runtime_test
import (
"context"
"errors"
"testing"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/backend/backendfakes"
"github.com/concourse/concourse/worker/backend/libcontainerd/libcontainerdfakes"
"github.com/concourse/concourse/worker/runtime"
"github.com/concourse/concourse/worker/runtime/backendfakes"
"github.com/concourse/concourse/worker/runtime/libcontainerd/libcontainerdfakes"
"github.com/containerd/containerd"
"github.com/containerd/containerd/runtime/v2/runc/options"
"github.com/containerd/typeurl"
@ -21,26 +21,26 @@ type KillerSuite struct {
task *libcontainerdfakes.FakeTask
processKiller *backendfakes.FakeProcessKiller
killer backend.Killer
killer runtime.Killer
}
func (s *KillerSuite) SetupTest() {
s.task = new(libcontainerdfakes.FakeTask)
s.processKiller = new(backendfakes.FakeProcessKiller)
s.killer = backend.NewKiller(
backend.WithProcessKiller(s.processKiller),
s.killer = runtime.NewKiller(
runtime.WithProcessKiller(s.processKiller),
)
}
func (s *KillerSuite) TestKillTaskWithNoProcs() {
s.T().Run("graceful", func(_ *testing.T) {
err := s.killer.Kill(context.Background(), s.task, backend.KillGracefully)
err := s.killer.Kill(context.Background(), s.task, runtime.KillGracefully)
s.NoError(err)
})
s.T().Run("ungraceful", func(_ *testing.T) {
err := s.killer.Kill(context.Background(), s.task, backend.KillUngracefully)
err := s.killer.Kill(context.Background(), s.task, runtime.KillUngracefully)
s.NoError(err)
})
@ -53,12 +53,12 @@ func (s *KillerSuite) TestKillTaskPidsErr() {
s.task.PidsReturns(nil, expectedErr)
s.T().Run("graceful", func(_ *testing.T) {
err := s.killer.Kill(context.Background(), s.task, backend.KillGracefully)
err := s.killer.Kill(context.Background(), s.task, runtime.KillGracefully)
s.True(errors.Is(err, expectedErr))
})
s.T().Run("ungraceful", func(_ *testing.T) {
err := s.killer.Kill(context.Background(), s.task, backend.KillUngracefully)
err := s.killer.Kill(context.Background(), s.task, runtime.KillUngracefully)
s.True(errors.Is(err, expectedErr))
})
}
@ -69,12 +69,12 @@ func (s *KillerSuite) TestKillTaskWithOnlyInitProc() {
}, nil)
s.T().Run("graceful", func(_ *testing.T) {
err := s.killer.Kill(context.Background(), s.task, backend.KillUngracefully)
err := s.killer.Kill(context.Background(), s.task, runtime.KillUngracefully)
s.NoError(err)
})
s.T().Run("ungraceful", func(_ *testing.T) {
err := s.killer.Kill(context.Background(), s.task, backend.KillUngracefully)
err := s.killer.Kill(context.Background(), s.task, runtime.KillUngracefully)
s.NoError(err)
})
@ -97,12 +97,12 @@ func (s *KillerSuite) TestKillTaskLoadProcessError() {
s.task.LoadProcessReturns(nil, expectedErr)
s.T().Run("graceful", func(_ *testing.T) {
err = s.killer.Kill(context.Background(), s.task, backend.KillUngracefully)
err = s.killer.Kill(context.Background(), s.task, runtime.KillUngracefully)
s.True(errors.Is(err, expectedErr))
})
s.T().Run("ungraceful", func(_ *testing.T) {
err = s.killer.Kill(context.Background(), s.task, backend.KillUngracefully)
err = s.killer.Kill(context.Background(), s.task, runtime.KillUngracefully)
s.True(errors.Is(err, expectedErr))
})
}
@ -120,7 +120,7 @@ func (s *KillerSuite) TestUngracefulKillTaskProcKillError() {
expectedErr := errors.New("load-proc-err")
s.processKiller.KillReturns(expectedErr)
err = s.killer.Kill(context.Background(), s.task, backend.KillUngracefully)
err = s.killer.Kill(context.Background(), s.task, runtime.KillUngracefully)
s.True(errors.Is(err, expectedErr))
}
@ -134,10 +134,10 @@ func (s *KillerSuite) TestGracefulKillTaskProcKillGracePeriodTimeoutError() {
{Pid: 123, Info: procInfo},
}, nil)
expectedErr := backend.ErrGracePeriodTimeout
expectedErr := runtime.ErrGracePeriodTimeout
s.processKiller.KillReturnsOnCall(0, expectedErr)
err = s.killer.Kill(context.Background(), s.task, backend.KillGracefully)
err = s.killer.Kill(context.Background(), s.task, runtime.KillGracefully)
s.NoError(err)
s.Equal(2, s.processKiller.KillCallCount())
@ -156,7 +156,7 @@ func (s *KillerSuite) TestGracefulKillTaskProcKillUncaughtError() {
expectedErr := errors.New("kill-err")
s.processKiller.KillReturnsOnCall(0, expectedErr)
err = s.killer.Kill(context.Background(), s.task, backend.KillGracefully)
err = s.killer.Kill(context.Background(), s.task, runtime.KillGracefully)
s.True(errors.Is(err, expectedErr))
s.Equal(1, s.processKiller.KillCallCount())
@ -172,11 +172,11 @@ func (s *KillerSuite) TestGracefulKillTaskProcKillErrorOnUngracefulTry() {
{Pid: 123, Info: procInfo},
}, nil)
s.processKiller.KillReturnsOnCall(0, backend.ErrGracePeriodTimeout)
s.processKiller.KillReturnsOnCall(0, runtime.ErrGracePeriodTimeout)
expectedErr := errors.New("ungraceful-kill-err")
s.processKiller.KillReturnsOnCall(1, expectedErr)
err = s.killer.Kill(context.Background(), s.task, backend.KillGracefully)
err = s.killer.Kill(context.Background(), s.task, runtime.KillGracefully)
s.True(errors.Is(err, expectedErr))
s.Equal(2, s.processKiller.KillCallCount())

View File

@ -5,7 +5,7 @@ import (
"context"
"sync"
"github.com/concourse/concourse/worker/backend/libcontainerd"
"github.com/concourse/concourse/worker/runtime/libcontainerd"
"github.com/containerd/containerd"
specs "github.com/opencontainers/runtime-spec/specs-go"
)

View File

@ -1,4 +1,4 @@
package backend
package runtime
import (
"context"

View File

@ -1,4 +1,4 @@
package backend
package runtime
import (
"context"

View File

@ -1,4 +1,4 @@
package backend
package runtime
import (
"context"

View File

@ -1,4 +1,4 @@
package backend_test
package runtime_test
import (
"context"
@ -7,8 +7,8 @@ import (
"syscall"
"time"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/backend/libcontainerd/libcontainerdfakes"
"github.com/concourse/concourse/worker/runtime"
"github.com/concourse/concourse/worker/runtime/libcontainerd/libcontainerdfakes"
"github.com/containerd/containerd"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
@ -20,7 +20,7 @@ type ProcessKillerSuite struct {
signal syscall.Signal
proc *libcontainerdfakes.FakeProcess
killer backend.ProcessKiller
killer runtime.ProcessKiller
goodEnoughTimeout time.Duration
notEnoughTimeout time.Duration
@ -28,7 +28,7 @@ type ProcessKillerSuite struct {
func (s *ProcessKillerSuite) SetupTest() {
s.proc = new(libcontainerdfakes.FakeProcess)
s.killer = backend.NewProcessKiller()
s.killer = runtime.NewProcessKiller()
s.signal = 142
s.goodEnoughTimeout = math.MaxInt64
@ -67,7 +67,7 @@ func (s *ProcessKillerSuite) TestKillKillError() {
func (s *ProcessKillerSuite) TestKillWaitContextDeadlineReached() {
err := s.killer.Kill(context.Background(), s.proc, s.signal, s.notEnoughTimeout)
s.True(errors.Is(err, backend.ErrGracePeriodTimeout))
s.True(errors.Is(err, runtime.ErrGracePeriodTimeout))
}
func (s *ProcessKillerSuite) TestKillWaitContextCancelled() {

View File

@ -1,12 +1,12 @@
package backend_test
package runtime_test
import (
"errors"
"time"
"code.cloudfoundry.org/garden"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/backend/libcontainerd/libcontainerdfakes"
"github.com/concourse/concourse/worker/runtime"
"github.com/concourse/concourse/worker/runtime/libcontainerd/libcontainerdfakes"
"github.com/containerd/containerd"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
@ -19,7 +19,7 @@ type ProcessSuite struct {
io *libcontainerdfakes.FakeIO
containerdProcess *libcontainerdfakes.FakeProcess
ch chan containerd.ExitStatus
process *backend.Process
process *runtime.Process
}
func (s *ProcessSuite) SetupTest() {
@ -27,7 +27,7 @@ func (s *ProcessSuite) SetupTest() {
s.containerdProcess = new(libcontainerdfakes.FakeProcess)
s.ch = make(chan containerd.ExitStatus, 1)
s.process = backend.NewProcess(s.containerdProcess, s.ch)
s.process = runtime.NewProcess(s.containerdProcess, s.ch)
}
func (s *ProcessSuite) TestID() {

View File

@ -1,4 +1,4 @@
package backend
package runtime
import (
"fmt"

View File

@ -1,4 +1,4 @@
package backend
package runtime
import (
"fmt"

View File

@ -1,11 +1,11 @@
package backend_test
package runtime_test
import (
"io/ioutil"
"os"
"path/filepath"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/runtime"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
@ -40,8 +40,8 @@ func (s *RootfsManagerSuite) TearDownTest() {
func (s *RootfsManagerSuite) TestSetupCwdDirAlreadyExists() {
mkdirCalled := false
mgr := backend.NewRootfsManager(
backend.WithMkdirAll(func(p string, mode os.FileMode) error {
mgr := runtime.NewRootfsManager(
runtime.WithMkdirAll(func(p string, mode os.FileMode) error {
mkdirCalled = true
return nil
}),
@ -57,7 +57,7 @@ func (s *RootfsManagerSuite) TestSetupCwdDirAlreadyExists() {
}
func (s *RootfsManagerSuite) TestSetupCwdCreatePathsRecursivelyByDefault() {
mgr := backend.NewRootfsManager()
mgr := runtime.NewRootfsManager()
err := mgr.SetupCwd(s.baseSpec, "/this/that")
s.NoError(err)
@ -73,8 +73,8 @@ func (s *RootfsManagerSuite) TestSetupCwdWithoutIDMappings() {
mode, expectedMode os.FileMode = 0000, 0777
)
mgr := backend.NewRootfsManager(
backend.WithMkdirAll(func(p string, m os.FileMode) error {
mgr := runtime.NewRootfsManager(
runtime.WithMkdirAll(func(p string, m os.FileMode) error {
path = p
mode = m
return nil

View File

@ -4,7 +4,7 @@ import (
"testing"
"code.cloudfoundry.org/garden"
"github.com/concourse/concourse/worker/backend/spec"
"github.com/concourse/concourse/worker/runtime/spec"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

View File

@ -1,4 +1,4 @@
package backend_test
package runtime_test
import (
"testing"

View File

@ -1,4 +1,4 @@
package backend
package runtime
import (
"bufio"

View File

@ -1,10 +1,10 @@
package backend_test
package runtime_test
import (
"bytes"
"testing"
"github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/runtime"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
@ -57,7 +57,7 @@ func (s *UserNamespaceSuite) TestMaxValid() {
},
} {
s.T().Run(tc.desc, func(t *testing.T) {
res, err := backend.MaxValid(bytes.NewBufferString(tc.input))
res, err := runtime.MaxValid(bytes.NewBufferString(tc.input))
if tc.shouldErr {
s.Error(err)
return

View File

@ -15,8 +15,8 @@ import (
"code.cloudfoundry.org/lager"
"code.cloudfoundry.org/localip"
concourseCmd "github.com/concourse/concourse/cmd"
containerd "github.com/concourse/concourse/worker/backend"
"github.com/concourse/concourse/worker/backend/libcontainerd"
"github.com/concourse/concourse/worker/runtime"
"github.com/concourse/concourse/worker/runtime/libcontainerd"
"github.com/tedsuo/ifrit"
"github.com/tedsuo/ifrit/grouper"
"github.com/tedsuo/ifrit/restart"
@ -35,30 +35,30 @@ func containerdGardenServerRunner(
namespace = "concourse"
)
backendOpts := []containerd.BackendOpt{}
networkOpts := []containerd.CNINetworkOpt{}
backendOpts := []runtime.BackendOpt{}
networkOpts := []runtime.CNINetworkOpt{}
if len(dnsServers) > 0 {
networkOpts = append(networkOpts, containerd.WithNameServers(dnsServers))
networkOpts = append(networkOpts, runtime.WithNameServers(dnsServers))
}
if networkPool != "" {
networkOpts = append(networkOpts, containerd.WithCNINetworkConfig(
containerd.CNINetworkConfig{
networkOpts = append(networkOpts, runtime.WithCNINetworkConfig(
runtime.CNINetworkConfig{
BridgeName: "concourse0",
NetworkName: "concourse",
Subnet: networkPool,
}))
}
cniNetwork, err := containerd.NewCNINetwork(networkOpts...)
cniNetwork, err := runtime.NewCNINetwork(networkOpts...)
if err != nil {
return nil, fmt.Errorf("new cni network: %w", err)
}
backendOpts = append(backendOpts, containerd.WithNetwork(cniNetwork))
backendOpts = append(backendOpts, runtime.WithNetwork(cniNetwork))
backend, err := containerd.New(
backend, err := runtime.New(
libcontainerd.New(containerdAddr, namespace, requestTimeout),
backendOpts...,
)