Add checkpoint timestamp based on mtime
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
7baee380ea
commit
3fdc48eb01
7 changed files with 18 additions and 14 deletions
|
@ -173,13 +173,15 @@ Response:
|
||||||
"name" : "test1",
|
"name" : "test1",
|
||||||
"unixSockets" : false,
|
"unixSockets" : false,
|
||||||
"tcp" : false,
|
"tcp" : false,
|
||||||
"shell" : false
|
"shell" : false,
|
||||||
|
"timestamp" : "2015-12-04T15:09:14.915868934-08:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name" : "test2",
|
"name" : "test2",
|
||||||
"tcp" : false,
|
"tcp" : false,
|
||||||
"unixSockets" : false,
|
"unixSockets" : false,
|
||||||
"shell" : false
|
"shell" : false,
|
||||||
|
"timestamp" : "2015-12-04T15:09:14.915868934-08:00"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
|
@ -314,6 +314,7 @@ func (s *server) listCheckpoints(w http.ResponseWriter, r *http.Request) {
|
||||||
Tcp: c.Tcp,
|
Tcp: c.Tcp,
|
||||||
Shell: c.Shell,
|
Shell: c.Shell,
|
||||||
UnixSockets: c.UnixSockets,
|
UnixSockets: c.UnixSockets,
|
||||||
|
Timestamp: c.Timestamp,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err := json.NewEncoder(w).Encode(out); err != nil {
|
if err := json.NewEncoder(w).Encode(out); err != nil {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package v1
|
package v1
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
type State struct {
|
type State struct {
|
||||||
Containers []Container `json:"containers"`
|
Containers []Container `json:"containers"`
|
||||||
Machine Machine `json:"machine"`
|
Machine Machine `json:"machine"`
|
||||||
|
@ -58,9 +60,10 @@ type Event struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Checkpoint struct {
|
type Checkpoint struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Exit bool `json:"exit,omitempty"`
|
Timestamp time.Time `json:"timestamp,omitempty"`
|
||||||
Tcp bool `json:"tcp"`
|
Exit bool `json:"exit,omitempty"`
|
||||||
UnixSockets bool `json:"unixSockets"`
|
Tcp bool `json:"tcp"`
|
||||||
Shell bool `json:"shell"`
|
UnixSockets bool `json:"unixSockets"`
|
||||||
|
Shell bool `json:"shell"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,9 @@ func (h *DeleteEvent) Handle(e *Event) error {
|
||||||
if container, ok := h.s.containers[e.ID]; ok {
|
if container, ok := h.s.containers[e.ID]; ok {
|
||||||
if err := h.deleteContainer(container); err != nil {
|
if err := h.deleteContainer(container); err != nil {
|
||||||
logrus.WithField("error", err).Error("containerd: deleting container")
|
logrus.WithField("error", err).Error("containerd: deleting container")
|
||||||
} else {
|
|
||||||
ContainersCounter.Dec(1)
|
|
||||||
h.s.containerGroup.Done()
|
|
||||||
}
|
}
|
||||||
|
ContainersCounter.Dec(1)
|
||||||
|
h.s.containerGroup.Done()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/docker/containerd/runtime"
|
"github.com/docker/containerd/runtime"
|
||||||
"github.com/opencontainers/runc/libcontainer"
|
"github.com/opencontainers/runc/libcontainer"
|
||||||
|
@ -202,7 +201,8 @@ func (c *libcontainerContainer) Checkpoints() ([]runtime.Checkpoint, error) {
|
||||||
}
|
}
|
||||||
for _, fi := range files {
|
for _, fi := range files {
|
||||||
out = append(out, runtime.Checkpoint{
|
out = append(out, runtime.Checkpoint{
|
||||||
Name: fi.Name(),
|
Name: fi.Name(),
|
||||||
|
Timestamp: fi.ModTime(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return out, nil
|
return out, nil
|
||||||
|
@ -238,7 +238,6 @@ func (c *libcontainerContainer) Checkpoint(cp runtime.Checkpoint) error {
|
||||||
if err := c.c.Checkpoint(opts); err != nil {
|
if err := c.c.Checkpoint(opts); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cp.Timestamp = time.Now()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
start.go
1
start.go
|
@ -9,6 +9,7 @@ func (h *StartEvent) Handle(e *Event) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
h.s.containerGroup.Add(1)
|
||||||
h.s.containers[e.ID] = container
|
h.s.containers[e.ID] = container
|
||||||
ContainersCounter.Inc(1)
|
ContainersCounter.Inc(1)
|
||||||
task := &StartTask{
|
task := &StartTask{
|
||||||
|
|
|
@ -50,7 +50,6 @@ func (w *worker) Start() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.s.containerGroup.Add(1)
|
|
||||||
ContainerStartTimer.UpdateSince(started)
|
ContainerStartTimer.UpdateSince(started)
|
||||||
t.Err <- nil
|
t.Err <- nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue