зеркало из https://github.com/microsoft/docker.git
Merge pull request #33882 from aaronlehmann/memdb-no-container
container: Handle failed memdb lookups
This commit is contained in:
Коммит
18d874a20f
|
@ -73,6 +73,17 @@ type memDB struct {
|
|||
store *memdb.MemDB
|
||||
}
|
||||
|
||||
// NoSuchContainerError indicates that the container wasn't found in the
|
||||
// database.
|
||||
type NoSuchContainerError struct {
|
||||
id string
|
||||
}
|
||||
|
||||
// Error satisfies the error interface.
|
||||
func (e NoSuchContainerError) Error() string {
|
||||
return "no such container " + e.id
|
||||
}
|
||||
|
||||
// NewViewDB provides the default implementation, with the default schema
|
||||
func NewViewDB() (ViewDB, error) {
|
||||
store, err := memdb.NewMemDB(schema)
|
||||
|
@ -134,6 +145,9 @@ func (v *memdbView) Get(id string) (*Snapshot, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if s == nil {
|
||||
return nil, NoSuchContainerError{id: id}
|
||||
}
|
||||
return v.transform(s.(*Container)), nil
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче