Do not exit on autoballoon errors, keep adjust memory for other VMs

This commit is contained in:
Mikhail Klementev 2020-01-05 09:08:43 +00:00
parent 806448df17
commit dad147eb91
No known key found for this signature in database
GPG key ID: BE44DA8C062D87DC

View file

@ -318,17 +318,20 @@ func autoBalloon(l *libvirt.Libvirt, memoryMin, adjustPercent uint64) {
memoryUsedRaw, err := ioutil.ReadFile(os.Getenv("HOME") + "/appvm/" + name + "/.memory_used") memoryUsedRaw, err := ioutil.ReadFile(os.Getenv("HOME") + "/appvm/" + name + "/.memory_used")
if err != nil { if err != nil {
log.Fatal(err) log.Println(err)
continue
} }
memoryUsedMiB, err := strconv.Atoi(string(memoryUsedRaw[0 : len(memoryUsedRaw)-1])) memoryUsedMiB, err := strconv.Atoi(string(memoryUsedRaw[0 : len(memoryUsedRaw)-1]))
if err != nil { if err != nil {
log.Fatal(err) log.Println(err)
continue
} }
memoryUsed := memoryUsedMiB * 1024 memoryUsed := memoryUsedMiB * 1024
_, memoryMax, memoryCurrent, _, _, err := l.DomainGetInfo(d) _, memoryMax, memoryCurrent, _, _, err := l.DomainGetInfo(d)
if err != nil { if err != nil {
log.Fatal(err) log.Println(err)
continue
} }
memoryNew := uint64(float64(memoryUsed) * (1 + float64(adjustPercent)/100)) memoryNew := uint64(float64(memoryUsed) * (1 + float64(adjustPercent)/100))
@ -343,7 +346,8 @@ func autoBalloon(l *libvirt.Libvirt, memoryMin, adjustPercent uint64) {
err = l.DomainSetMemory(d, memoryNew) err = l.DomainSetMemory(d, memoryNew)
if err != nil { if err != nil {
log.Fatal(err) log.Println(err)
continue
} }
table.Append([]string{name, table.Append([]string{name,