Skip to content

Commit

Permalink
Merge pull request #146 from mleone87/master
Browse files Browse the repository at this point in the history
Fixes for LXC containers HA management
  • Loading branch information
ggongaware authored Nov 22, 2021
2 parents 8bbe30e + ab36ccd commit af0b2da
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
7 changes: 3 additions & 4 deletions proxmox/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io"
"io/ioutil"
"log"
"mime/multipart"
"net"
"net/http"
Expand Down Expand Up @@ -130,10 +131,8 @@ func (c *Client) GetJsonRetryable(url string, data *map[string]interface{}, trie
if statErr == nil {
return nil
}
// if statErr != io.ErrUnexpectedEOF { // don't give up on ErrUnexpectedEOF
// return statErr
// }
time.Sleep(5 * time.Second)
log.Printf("[DEBUG][GetJsonRetryable] Sleeping for %d seconds before asking url %s", ii+1, url)
time.Sleep(time.Duration(ii+1) * time.Second)
}
return statErr
}
Expand Down
17 changes: 10 additions & 7 deletions proxmox/config_lxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"strconv"
"strings"
)
Expand Down Expand Up @@ -89,11 +90,6 @@ func NewConfigLxcFromApi(vmr *VmRef, client *Client) (config *ConfigLxc, err err
return nil, err
}

err = client.ReadVMHA(vmr)
if err != nil {
return nil, err
}

// prepare a new lxc config to store and return\
// the information from api
newConfig := NewConfigLxc()
Expand Down Expand Up @@ -302,8 +298,6 @@ func NewConfigLxcFromApi(vmr *VmRef, client *Client) (config *ConfigLxc, err err
config.CPUUnits = cpuunits
config.Description = description
config.OnBoot = onboot
config.HaState = vmr.HaState()
config.HaGroup = vmr.HaGroup()
config.Hookscript = hookscript
config.Hostname = hostname
config.Lock = lock
Expand All @@ -322,6 +316,15 @@ func NewConfigLxcFromApi(vmr *VmRef, client *Client) (config *ConfigLxc, err err
config.Unused = unused
config.Tags = tags

err = client.ReadVMHA(vmr)
if err == nil {
config.HaState = vmr.HaState()
config.HaGroup = vmr.HaGroup()
} else {
log.Printf("[DEBUG] Container %d(%s) has no HA config", vmr.vmId, lxcConfig["hostname"])
return config, nil
}

return
}

Expand Down
4 changes: 2 additions & 2 deletions proxmox/config_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,8 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e
unusedDiskNames = append(unusedDiskNames, unusedDiskName[0])
}
}
if unusedDiskNames != nil {
log.Printf("unusedDiskNames: %v", unusedDiskNames)
if len(unusedDiskNames) > 0 {
log.Printf("[DEBUG] unusedDiskNames: %v", unusedDiskNames)
}

for _, unusedDiskName := range unusedDiskNames {
Expand Down

0 comments on commit af0b2da

Please sign in to comment.