server/buildfile.go -> builder/builder.go; add maintainers file

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
Upstream-commit: 3a177ccd3afdfe481a7248fccb2efe0f2cbdfcca
Component: engine
This commit is contained in:
Erik Hollensbe
2014-07-29 11:35:02 -07:00
parent d0658f2e0a
commit 17543b1068
5 changed files with 46 additions and 42 deletions
+1 -1
View File
@@ -513,7 +513,7 @@ func (container *Container) monitor(callback execdriver.StartCallback) error {
if container.daemon != nil && container.daemon.srv != nil && container.daemon.srv.IsRunning() {
// FIXME: here is race condition between two RUN instructions in Dockerfile
// because they share same runconfig and change image. Must be fixed
// in server/buildfile.go
// in builder/builder.go
if err := container.toDisk(); err != nil {
utils.Errorf("Error dumping container %s state to disk: %s\n", container.ID, err)
}
+32
View File
@@ -1099,3 +1099,35 @@ func (daemon *Daemon) checkLocaldns() error {
}
return nil
}
func (daemon *Daemon) ImageGetCached(imgID string, config *runconfig.Config) (*image.Image, error) {
// Retrieve all images
images, err := daemon.Graph().Map()
if err != nil {
return nil, err
}
// Store the tree in a map of map (map[parentId][childId])
imageMap := make(map[string]map[string]struct{})
for _, img := range images {
if _, exists := imageMap[img.Parent]; !exists {
imageMap[img.Parent] = make(map[string]struct{})
}
imageMap[img.Parent][img.ID] = struct{}{}
}
// Loop on the children of the given image and check the config
var match *image.Image
for elem := range imageMap[imgID] {
img, err := daemon.Graph().Get(elem)
if err != nil {
return nil, err
}
if runconfig.Compare(&img.ContainerConfig, config) {
if match == nil || match.Created.Before(img.Created) {
match = img
}
}
}
return match, nil
}