Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
| ... | ... |
@@ -31,14 +31,6 @@ func (d *Daemon) registerExecCommand(container *container.Container, config *exe |
| 31 | 31 |
d.execCommands.Add(config.ID, config) |
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 |
-func (d *Daemon) registerExecPidUnlocked(container *container.Container, config *exec.Config) {
|
|
| 35 |
- logrus.Debugf("registering pid %v for exec %v", config.Pid, config.ID)
|
|
| 36 |
- // Storing execs in container in order to kill them gracefully whenever the container is stopped or removed. |
|
| 37 |
- container.ExecCommands.SetPidUnlocked(config.ID, config.Pid) |
|
| 38 |
- // Storing execs in daemon for easy access via Engine API. |
|
| 39 |
- d.execCommands.SetPidUnlocked(config.ID, config.Pid) |
|
| 40 |
-} |
|
| 41 |
- |
|
| 42 | 34 |
// ExecExists looks up the exec instance and returns a bool if it exists or not. |
| 43 | 35 |
// It will also return the error produced by `getConfig` |
| 44 | 36 |
func (d *Daemon) ExecExists(name string) (bool, error) {
|
| ... | ... |
@@ -253,7 +245,6 @@ func (d *Daemon) ContainerExecStart(ctx context.Context, name string, stdin io.R |
| 253 | 253 |
return translateContainerdStartErr(ec.Entrypoint, ec.SetExitCode, err) |
| 254 | 254 |
} |
| 255 | 255 |
ec.Pid = systemPid |
| 256 |
- d.registerExecPidUnlocked(c, ec) |
|
| 257 | 256 |
c.ExecCommands.Unlock() |
| 258 | 257 |
ec.Unlock() |
| 259 | 258 |
|
| ... | ... |
@@ -88,16 +88,14 @@ func (c *Config) SetExitCode(code int) {
|
| 88 | 88 |
|
| 89 | 89 |
// Store keeps track of the exec configurations. |
| 90 | 90 |
type Store struct {
|
| 91 |
- byID map[string]*Config |
|
| 92 |
- byPid map[int]*Config |
|
| 91 |
+ byID map[string]*Config |
|
| 93 | 92 |
sync.RWMutex |
| 94 | 93 |
} |
| 95 | 94 |
|
| 96 | 95 |
// NewStore initializes a new exec store. |
| 97 | 96 |
func NewStore() *Store {
|
| 98 | 97 |
return &Store{
|
| 99 |
- byID: make(map[string]*Config), |
|
| 100 |
- byPid: make(map[int]*Config), |
|
| 98 |
+ byID: make(map[string]*Config), |
|
| 101 | 99 |
} |
| 102 | 100 |
} |
| 103 | 101 |
|
| ... | ... |
@@ -119,14 +117,6 @@ func (e *Store) Add(id string, Config *Config) {
|
| 119 | 119 |
e.Unlock() |
| 120 | 120 |
} |
| 121 | 121 |
|
| 122 |
-// SetPidUnlocked adds an association between a Pid and a config, it does not |
|
| 123 |
-// synchronized with other operations. |
|
| 124 |
-func (e *Store) SetPidUnlocked(id string, pid int) {
|
|
| 125 |
- if config, ok := e.byID[id]; ok {
|
|
| 126 |
- e.byPid[pid] = config |
|
| 127 |
- } |
|
| 128 |
-} |
|
| 129 |
- |
|
| 130 | 122 |
// Get returns an exec configuration by its id. |
| 131 | 123 |
func (e *Store) Get(id string) *Config {
|
| 132 | 124 |
e.RLock() |
| ... | ... |
@@ -135,18 +125,9 @@ func (e *Store) Get(id string) *Config {
|
| 135 | 135 |
return res |
| 136 | 136 |
} |
| 137 | 137 |
|
| 138 |
-// ByPid returns an exec configuration by its pid. |
|
| 139 |
-func (e *Store) ByPid(pid int) *Config {
|
|
| 140 |
- e.RLock() |
|
| 141 |
- res := e.byPid[pid] |
|
| 142 |
- e.RUnlock() |
|
| 143 |
- return res |
|
| 144 |
-} |
|
| 145 |
- |
|
| 146 | 138 |
// Delete removes an exec configuration from the store. |
| 147 | 139 |
func (e *Store) Delete(id string, pid int) {
|
| 148 | 140 |
e.Lock() |
| 149 |
- delete(e.byPid, pid) |
|
| 150 | 141 |
delete(e.byID, id) |
| 151 | 142 |
e.Unlock() |
| 152 | 143 |
} |
| ... | ... |
@@ -108,7 +108,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerd.EventType, ei libc |
| 108 | 108 |
return daemon.postRunProcessing(c, ei) |
| 109 | 109 |
} |
| 110 | 110 |
|
| 111 |
- if execConfig := c.ExecCommands.ByPid(int(ei.Pid)); execConfig != nil {
|
|
| 111 |
+ if execConfig := c.ExecCommands.Get(ei.ProcessID); execConfig != nil {
|
|
| 112 | 112 |
ec := int(ei.ExitCode) |
| 113 | 113 |
execConfig.Lock() |
| 114 | 114 |
defer execConfig.Unlock() |
| ... | ... |
@@ -125,6 +125,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerd.EventType, ei libc |
| 125 | 125 |
} else {
|
| 126 | 126 |
logrus.WithFields(logrus.Fields{
|
| 127 | 127 |
"container": c.ID, |
| 128 |
+ "exec-id": ei.ProcessID, |
|
| 128 | 129 |
"exec-pid": ei.Pid, |
| 129 | 130 |
}).Warnf("Ignoring Exit Event, no such exec command found")
|
| 130 | 131 |
} |