Commit 1834d60e authored by vicotor's avatar vicotor

fix bug

parent 61d3804f
...@@ -78,10 +78,10 @@ func (w *imageWorker) IsRunning(modelId int) bool { ...@@ -78,10 +78,10 @@ func (w *imageWorker) IsRunning(modelId int) bool {
} }
// CanInstall check if the worker can install the model. // CanInstall check if the worker can install the model.
func (w *imageWorker) CanInstall(model ModelDetailInfo) bool { func (w *imageWorker) CanInstall(pendingDiskToUsed int64, model ModelDetailInfo) bool {
info := w.getInfo() info := w.getInfo()
diskFree := info.Hardware.DISK.Free diskFree := info.Hardware.DISK.Free
pending := int64(0) pending := pendingDiskToUsed
for _, v := range info.Models.WaitToInstallModels { for _, v := range info.Models.WaitToInstallModels {
id, _ := strconv.Atoi(v.ModelId) id, _ := strconv.Atoi(v.ModelId)
minfo := w.modelLibrary.FindModel(id) minfo := w.modelLibrary.FindModel(id)
...@@ -219,6 +219,14 @@ func (w *imageWorker) distributeMatch(mode DistributeMode, model ModelDetailInfo ...@@ -219,6 +219,14 @@ func (w *imageWorker) distributeMatch(mode DistributeMode, model ModelDetailInfo
} }
func (w *imageWorker) distributeToUnstall(models SortedModelDetailInfos, info omanager.NodeInfoResponse, ops []*omanager.ModelOperate) { func (w *imageWorker) distributeToUnstall(models SortedModelDetailInfos, info omanager.NodeInfoResponse, ops []*omanager.ModelOperate) {
lib := w.modelLibrary
for _, model := range info.Models.InstalledModels {
id, _ := strconv.Atoi(model.ModelId)
// if the model is not in the model library or the worker can't install the model, then uninstall it.
if find := lib.FindModel(id); find.TaskID == 0 || !w.CanForceRun(find) {
ops = append(ops, w.getOp(find, omanager.ModelOperateType_DELETE))
}
}
} }
...@@ -231,9 +239,11 @@ func (w *imageWorker) distributeToInstall(models SortedModelDetailInfos, info om ...@@ -231,9 +239,11 @@ func (w *imageWorker) distributeToInstall(models SortedModelDetailInfos, info om
if totalWorker > 10 { if totalWorker > 10 {
mode = HashingMode // 散列模式 mode = HashingMode // 散列模式
} }
pendingDiskToUsed := int64(0)
for _, model := range models { for _, model := range models {
if w.CanInstall(model) && w.distributeMatch(mode, model, hash[:]) { if w.CanInstall(pendingDiskToUsed, model) && w.distributeMatch(mode, model, hash[:]) {
pendingDiskToUsed += model.HardwareRequire.IntDiskSize()
ops = append(ops, w.getOp(model, omanager.ModelOperateType_INSTALL)) ops = append(ops, w.getOp(model, omanager.ModelOperateType_INSTALL))
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment