|
|
@ -13,24 +13,27 @@ import ( |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func buildRuntime(runtime *model.Runtime, service *docker.ComposeService, imageID string) { |
|
|
|
func buildRuntime(runtime *model.Runtime, service *docker.ComposeService, oldImageID string) { |
|
|
|
err := service.ComposeBuild() |
|
|
|
err := service.ComposeBuild() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
runtime.Status = constant.RuntimeError |
|
|
|
runtime.Status = constant.RuntimeError |
|
|
|
runtime.Message = buserr.New(constant.ErrImageBuildErr).Error() + ":" + err.Error() |
|
|
|
runtime.Message = buserr.New(constant.ErrImageBuildErr).Error() + ":" + err.Error() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
runtime.Status = constant.RuntimeNormal |
|
|
|
runtime.Status = constant.RuntimeNormal |
|
|
|
if imageID != "" { |
|
|
|
if oldImageID != "" { |
|
|
|
client, err := docker.NewClient() |
|
|
|
client, err := docker.NewClient() |
|
|
|
global.LOG.Infof("delete imageID [%s] ", imageID) |
|
|
|
|
|
|
|
if err == nil { |
|
|
|
if err == nil { |
|
|
|
if err := client.DeleteImage(imageID); err != nil { |
|
|
|
newImageID, err := client.GetImageIDByName(runtime.Image) |
|
|
|
global.LOG.Errorf("delete imageID [%s] error %v", imageID, err) |
|
|
|
if err == nil && newImageID != oldImageID { |
|
|
|
} else { |
|
|
|
global.LOG.Infof("delete imageID [%s] ", oldImageID) |
|
|
|
global.LOG.Infof("delete old image success") |
|
|
|
if err := client.DeleteImage(oldImageID); err != nil { |
|
|
|
|
|
|
|
global.LOG.Errorf("delete imageID [%s] error %v", oldImageID, err) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
global.LOG.Infof("delete old image success") |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
global.LOG.Errorf("delete imageID [%s] error %v", imageID, err) |
|
|
|
global.LOG.Errorf("delete imageID [%s] error %v", oldImageID, err) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|