90f827ca10
* Sync process.State() with the matching events Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com> * Allow requesting events for a specific container Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com> * Sync container state retrieval with other events Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com> * Let containerd take care of calling runtime delete on exit Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com> * Take care of possible race in TestBusyboxTopExecTopKillInit Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
47 lines
945 B
Go
47 lines
945 B
Go
package supervisor
|
|
|
|
import "github.com/docker/containerd/runtime"
|
|
|
|
// GetContainersTask holds needed parameters to retrieve a list of
|
|
// containers
|
|
type GetContainersTask struct {
|
|
baseTask
|
|
ID string
|
|
GetState func(c runtime.Container) (interface{}, error)
|
|
|
|
Containers []runtime.Container
|
|
States []interface{}
|
|
}
|
|
|
|
func (s *Supervisor) getContainers(t *GetContainersTask) error {
|
|
|
|
if t.ID != "" {
|
|
ci, ok := s.containers[t.ID]
|
|
if !ok {
|
|
return ErrContainerNotFound
|
|
}
|
|
t.Containers = append(t.Containers, ci.container)
|
|
if t.GetState != nil {
|
|
st, err := t.GetState(ci.container)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
t.States = append(t.States, st)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
for _, ci := range s.containers {
|
|
t.Containers = append(t.Containers, ci.container)
|
|
if t.GetState != nil {
|
|
st, err := t.GetState(ci.container)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
t.States = append(t.States, st)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|