Add restart recovery logic.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2017-09-04 02:47:58 +00:00
parent 5dbba596e6
commit cc1b0b6709
14 changed files with 543 additions and 34 deletions

View File

@@ -88,11 +88,6 @@ func (c *Container) Delete() error {
return c.Status.Delete()
}
// LoadContainer loads the internal used container type.
func LoadContainer() (Container, error) {
return Container{}, nil
}
// Store stores all Containers.
type Store struct {
lock sync.RWMutex

View File

@@ -41,6 +41,7 @@ func TestContainerStore(t *testing.T) {
},
},
ImageRef: "TestImage-1",
LogPath: "/test/log/path/1",
},
"2": {
ID: "2",
@@ -53,6 +54,7 @@ func TestContainerStore(t *testing.T) {
},
},
ImageRef: "TestImage-2",
LogPath: "/test/log/path/2",
},
"3": {
ID: "3",
@@ -65,6 +67,7 @@ func TestContainerStore(t *testing.T) {
},
},
ImageRef: "TestImage-3",
LogPath: "/test/log/path/3",
},
}
statuses := map[string]Status{
@@ -153,6 +156,7 @@ func TestWithContainerIO(t *testing.T) {
},
},
ImageRef: "TestImage-1",
LogPath: "/test/log/path",
}
status := Status{
Pid: 1,

View File

@@ -54,6 +54,8 @@ type Metadata struct {
Config *runtime.ContainerConfig
// ImageRef is the reference of image used by the container.
ImageRef string
// LogPath is the container log path.
LogPath string
}
// MarshalJSON encodes Metadata into bytes in json format.

View File

@@ -36,6 +36,7 @@ func TestMetadataMarshalUnmarshal(t *testing.T) {
},
},
ImageRef: "test-image-ref",
LogPath: "/test/log/path",
}
assert := assertlib.New(t)

View File

@@ -58,8 +58,7 @@ type Status struct {
Message string
// Removing indicates that the container is in removing state.
// This field doesn't need to be checkpointed.
// TODO(random-liu): Reset this field to false during state recoverry.
Removing bool
Removing bool `json:"-"`
}
// State returns current state of the container based on the container status.

View File

@@ -81,6 +81,7 @@ func TestStatusEncodeDecode(t *testing.T) {
assert.NoError(err)
newS := &Status{}
assert.NoError(newS.decode(data))
s.Removing = false // Removing should not be encoded.
assert.Equal(s, newS)
unsupported, err := json.Marshal(&versionedStatus{