From 00307a70eeae5a7cc8c21ff9cc502c38fdf75188 Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Fri, 31 Jan 2020 20:41:56 +0000 Subject: [PATCH] virtcontainers/sandbox: support new persist API Fix sandbox implementation and unit tests to support the new persist API Signed-off-by: Julio Montes --- virtcontainers/persist.go | 2 +- virtcontainers/persist_test.go | 2 +- virtcontainers/sandbox.go | 6 +++--- virtcontainers/sandbox_test.go | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/virtcontainers/persist.go b/virtcontainers/persist.go index ceff379600..bf4d4bd09a 100644 --- a/virtcontainers/persist.go +++ b/virtcontainers/persist.go @@ -451,7 +451,7 @@ func (c *Container) Restore() error { } func loadSandboxConfig(id string) (*SandboxConfig, error) { - store, err := persist.GetDriver("fs") + store, err := persist.GetDriver() if err != nil || store == nil { return nil, errors.New("failed to get fs persist driver") } diff --git a/virtcontainers/persist_test.go b/virtcontainers/persist_test.go index 03b6252f41..b7b0184bf8 100644 --- a/virtcontainers/persist_test.go +++ b/virtcontainers/persist_test.go @@ -37,7 +37,7 @@ func TestSandboxRestore(t *testing.T) { config: &sconfig, } - sandbox.newStore, err = persist.GetDriver("fs") + sandbox.newStore, err = persist.GetDriver() assert.NoError(err) assert.NotNil(sandbox.newStore) diff --git a/virtcontainers/sandbox.go b/virtcontainers/sandbox.go index 9f5f831b04..04259bc808 100644 --- a/virtcontainers/sandbox.go +++ b/virtcontainers/sandbox.go @@ -538,7 +538,7 @@ func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factor ctx: ctx, } - if s.newStore, err = persist.GetDriver("fs"); err != nil || s.newStore == nil { + if s.newStore, err = persist.GetDriver(); err != nil || s.newStore == nil { return nil, fmt.Errorf("failed to get fs persist driver: %v", err) } @@ -622,7 +622,7 @@ func (s *Sandbox) storeSandbox() error { } func rLockSandbox(sandboxID string) (func() error, error) { - store, err := persist.GetDriver("fs") + store, err := persist.GetDriver() if err != nil { return nil, fmt.Errorf("failed to get fs persist driver: %v", err) } @@ -631,7 +631,7 @@ func rLockSandbox(sandboxID string) (func() error, error) { } func rwLockSandbox(sandboxID string) (func() error, error) { - store, err := persist.GetDriver("fs") + store, err := persist.GetDriver() if err != nil { return nil, fmt.Errorf("failed to get fs persist driver: %v", err) } diff --git a/virtcontainers/sandbox_test.go b/virtcontainers/sandbox_test.go index f47ad857a0..58d8874cdc 100644 --- a/virtcontainers/sandbox_test.go +++ b/virtcontainers/sandbox_test.go @@ -990,7 +990,7 @@ func TestDeleteStoreWhenNewContainerFail(t *testing.T) { } _, err = newContainer(p, &contConfig) assert.NotNil(t, err, "New container with invalid device info should fail") - storePath := filepath.Join(fs.RunStoragePath(), testSandboxID, contID) + storePath := filepath.Join(p.newStore.RunStoragePath(), testSandboxID, contID) _, err = os.Stat(storePath) assert.NotNil(t, err, "Should delete configuration root after failed to create a container") } @@ -1160,7 +1160,7 @@ func TestAttachBlockDevice(t *testing.T) { } // create state file - path := filepath.Join(fs.RunStoragePath(), testSandboxID, container.ID()) + path := filepath.Join(fs.MockRunStoragePath(), testSandboxID, container.ID()) err := os.MkdirAll(path, DirMode) assert.NoError(t, err) @@ -1238,7 +1238,7 @@ func TestPreAddDevice(t *testing.T) { container.state.State = types.StateReady // create state file - path := filepath.Join(fs.RunStoragePath(), testSandboxID, container.ID()) + path := filepath.Join(fs.MockRunStoragePath(), testSandboxID, container.ID()) err := os.MkdirAll(path, DirMode) assert.NoError(t, err)