Skip to content

Commit

Permalink
Merge pull request #18 from praveenkumar/fix_json_marshal
Browse files Browse the repository at this point in the history
Don't unmarshal empty status file.
  • Loading branch information
praveenkumar authored Jun 27, 2019
2 parents 448bfae + dc5f897 commit 7206f26
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions libvirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,14 @@ func (d *Driver) Start() error {
// They wont start immediately
time.Sleep(5 * time.Second)

for i := 0; i < 40; i++ {
for i := 0; i < 60; i++ {
ip, err := d.GetIP()
if err != nil {
return fmt.Errorf("%v: getting ip during machine start", err)
}

if ip == "" {
log.Debugf("Waiting for machine to come up %d/%d", i, 40)
log.Debugf("Waiting for machine to come up %d/%d", i, 60)
time.Sleep(3 * time.Second)
continue
}
Expand Down Expand Up @@ -521,6 +521,11 @@ func (d *Driver) getIPByMacFromSettings(mac string) (string, error) {
}
var s []Lease

// In case of status file is empty then don't try to unmarshal data
if len(data) == 0 {
return "", nil
}

err = json.Unmarshal(data, &s)
if err != nil {
log.Warnf("Failed to decode dnsmasq lease status: %s", err)
Expand Down

0 comments on commit 7206f26

Please sign in to comment.