diff --git a/virtcontainers/container.go b/virtcontainers/container.go index 703f90f84a..2c7e8c0572 100644 --- a/virtcontainers/container.go +++ b/virtcontainers/container.go @@ -361,12 +361,6 @@ func (c *Container) SetPid(pid int) error { return c.storeProcess() } -func (c *Container) setStateBlockIndex(index int) error { - c.state.BlockIndex = index - - return c.storeState() -} - func (c *Container) setStateFstype(fstype string) error { c.state.Fstype = fstype diff --git a/virtcontainers/sandbox_test.go b/virtcontainers/sandbox_test.go index 4a2c960aaf..70ed5906b9 100644 --- a/virtcontainers/sandbox_test.go +++ b/virtcontainers/sandbox_test.go @@ -750,100 +750,6 @@ func TestSandboxGetContainer(t *testing.T) { } } -func TestContainerSetStateBlockIndex(t *testing.T) { - containers := []ContainerConfig{ - { - ID: "100", - Annotations: containerAnnotations, - }, - } - - hConfig := newHypervisorConfig(nil, nil) - sandbox, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NetworkConfig{}, containers, nil) - if err != nil { - t.Fatal(err) - } - defer cleanUp() - - sandboxStore, err := store.NewVCSandboxStore(sandbox.ctx, sandbox.id) - if err != nil { - t.Fatal(err) - } - sandbox.store = sandboxStore - - c := sandbox.GetContainer("100") - if c == nil { - t.Fatal() - } - cImpl, ok := c.(*Container) - assert.True(t, ok) - - containerStore, err := store.NewVCContainerStore(sandbox.ctx, sandbox.id, c.ID()) - if err != nil { - t.Fatal(err) - } - cImpl.store = containerStore - - path := store.ContainerRuntimeRootPath(testSandboxID, c.ID()) - stateFilePath := filepath.Join(path, store.StateFile) - - f, err := os.Create(stateFilePath) - if err != nil { - t.Fatal(err) - } - - state := types.ContainerState{ - State: "stopped", - Fstype: "vfs", - } - - cImpl.state = state - - stateData := `{ - "state":"stopped", - "fstype":"vfs" - }` - - n, err := f.WriteString(stateData) - if err != nil || n != len(stateData) { - f.Close() - t.Fatal() - } - f.Close() - - newIndex := 20 - if err := cImpl.setStateBlockIndex(newIndex); err != nil { - t.Fatal(err) - } - - if cImpl.state.BlockIndex != newIndex { - t.Fatal() - } - - fileData, err := ioutil.ReadFile(stateFilePath) - if err != nil { - t.Fatal() - } - - var res types.ContainerState - err = json.Unmarshal([]byte(string(fileData)), &res) - if err != nil { - t.Fatal(err) - } - - if res.BlockIndex != newIndex { - t.Fatal() - } - - if res.Fstype != state.Fstype { - t.Fatal() - } - - if res.State != state.State { - t.Fatal() - } -} - func TestContainerStateSetFstype(t *testing.T) { var err error @@ -889,9 +795,8 @@ func TestContainerStateSetFstype(t *testing.T) { } state := types.ContainerState{ - State: "ready", - Fstype: "vfs", - BlockIndex: 3, + State: "ready", + Fstype: "vfs", } cImpl.state = state @@ -899,7 +804,6 @@ func TestContainerStateSetFstype(t *testing.T) { stateData := `{ "state":"ready", "fstype":"vfs", - "blockIndex": 3 }` n, err := f.WriteString(stateData) @@ -933,10 +837,6 @@ func TestContainerStateSetFstype(t *testing.T) { t.Fatal() } - if res.BlockIndex != state.BlockIndex { - t.Fatal() - } - if res.State != state.State { t.Fatal() } diff --git a/virtcontainers/types/container.go b/virtcontainers/types/container.go index 7b3b5e2bc3..3436f8afdc 100644 --- a/virtcontainers/types/container.go +++ b/virtcontainers/types/container.go @@ -10,8 +10,6 @@ type ContainerState struct { State StateString `json:"state"` BlockDeviceID string - // Index of the block device passed to hypervisor. - BlockIndex int `json:"blockIndex"` // File system of the rootfs incase it is block device Fstype string `json:"fstype"`