Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainers/sandbox: support new persist API
Browse files Browse the repository at this point in the history
Fix sandbox implementation and unit tests to support the new persist API

Signed-off-by: Julio Montes <[email protected]>
  • Loading branch information
Julio Montes committed Feb 12, 2020
1 parent 4b9ab55 commit 00307a7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion virtcontainers/persist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/persist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions virtcontainers/sandbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 00307a7

Please sign in to comment.