Browse code

daemon: Ignore nonexistent containers when listing containers

The name/ID relationships are maintained separately from the memdb and
can be out of sync from any particular memdb snapshot. If a container
does not exist in the memdb, we must accept this as normal and not fail
the listing. This is consistent with what the code used to do before
memdb was introduced.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Aaron Lehmann authored on 2017/06/30 07:25:17
Showing 1 changed files
... ...
@@ -162,11 +162,13 @@ func (daemon *Daemon) filterByNameIDMatches(view container.View, ctx *listContex
162 162
 	cntrs := make([]container.Snapshot, 0, len(matches))
163 163
 	for id := range matches {
164 164
 		c, err := view.Get(id)
165
-		if err != nil {
166
-			return nil, err
167
-		}
168
-		if c != nil {
165
+		switch err.(type) {
166
+		case nil:
169 167
 			cntrs = append(cntrs, *c)
168
+		case container.NoSuchContainerError:
169
+			// ignore error
170
+		default:
171
+			return nil, err
170 172
 		}
171 173
 	}
172 174