|
|
@ -376,13 +376,17 @@ func syncById(installId uint) error {
|
|
|
|
errorContainers []string
|
|
|
|
errorContainers []string
|
|
|
|
notFoundContainers []string
|
|
|
|
notFoundContainers []string
|
|
|
|
runningContainers []string
|
|
|
|
runningContainers []string
|
|
|
|
|
|
|
|
exitedContainers []string
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
for _, n := range containers {
|
|
|
|
for _, n := range containers {
|
|
|
|
if n.State != "running" {
|
|
|
|
switch n.State {
|
|
|
|
errorContainers = append(errorContainers, n.Names[0])
|
|
|
|
case "exited":
|
|
|
|
} else {
|
|
|
|
exitedContainers = append(exitedContainers, n.Names[0])
|
|
|
|
|
|
|
|
case "running":
|
|
|
|
runningContainers = append(runningContainers, n.Names[0])
|
|
|
|
runningContainers = append(runningContainers, n.Names[0])
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
errorContainers = append(errorContainers, n.Names[0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, old := range containerNames {
|
|
|
|
for _, old := range containerNames {
|
|
|
@ -401,6 +405,7 @@ func syncById(installId uint) error {
|
|
|
|
containerCount := len(containers)
|
|
|
|
containerCount := len(containers)
|
|
|
|
errCount := len(errorContainers)
|
|
|
|
errCount := len(errorContainers)
|
|
|
|
notFoundCount := len(notFoundContainers)
|
|
|
|
notFoundCount := len(notFoundContainers)
|
|
|
|
|
|
|
|
existedCount := len(exitedContainers)
|
|
|
|
normalCount := len(containerNames)
|
|
|
|
normalCount := len(containerNames)
|
|
|
|
runningCount := len(runningContainers)
|
|
|
|
runningCount := len(runningContainers)
|
|
|
|
|
|
|
|
|
|
|
@ -409,16 +414,17 @@ func syncById(installId uint) error {
|
|
|
|
appInstall.Message = "container is not found"
|
|
|
|
appInstall.Message = "container is not found"
|
|
|
|
return appInstallRepo.Save(&appInstall)
|
|
|
|
return appInstallRepo.Save(&appInstall)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if errCount == 0 && notFoundCount == 0 {
|
|
|
|
if errCount == 0 && existedCount == 0 {
|
|
|
|
appInstall.Status = constant.Running
|
|
|
|
appInstall.Status = constant.Running
|
|
|
|
return appInstallRepo.Save(&appInstall)
|
|
|
|
return appInstallRepo.Save(&appInstall)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if existedCount == normalCount {
|
|
|
|
|
|
|
|
appInstall.Status = constant.Stopped
|
|
|
|
|
|
|
|
return appInstallRepo.Save(&appInstall)
|
|
|
|
|
|
|
|
}
|
|
|
|
if errCount == normalCount {
|
|
|
|
if errCount == normalCount {
|
|
|
|
appInstall.Status = constant.Error
|
|
|
|
appInstall.Status = constant.Error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if notFoundCount == normalCount {
|
|
|
|
|
|
|
|
appInstall.Status = constant.Stopped
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if runningCount < normalCount {
|
|
|
|
if runningCount < normalCount {
|
|
|
|
appInstall.Status = constant.UnHealthy
|
|
|
|
appInstall.Status = constant.UnHealthy
|
|
|
|
}
|
|
|
|
}
|
|
|
|