Skip to content

Commit

Permalink
wait for cloud-init finish, which likely accours earlier than the boo…
Browse files Browse the repository at this point in the history
…t-time
  • Loading branch information
vooon committed Nov 10, 2023
1 parent 1e8f8fa commit 2af7ced
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,31 @@ func (g *InstanceGroup) Update(ctx context.Context, update func(instance string,
case "ACTIVE", "OPERATING":
if srv != nil {
if srv.Created.Add(g.BootTime).Before(time.Now()) {
// treat all nodes running long enough as Running
state = provider.StateRunning
} else {
g.log.Debug("Instance boot time not passed yet", "server_id", srv.ID, "created", srv.Created, "boot_time", g.BootTime)
log, err := servers.ShowConsoleOutput(g.computeClient, srv.ID, servers.ShowConsoleOutputOpts{
Length: 100,
}).Extract()
if err != nil {
reterr = errors.Join(reterr, err)
continue
}

if IsCloudInitFinished(log) {
g.log.Debug("Instance cloud-init finished", "server_id", srv.ID, "created", srv.Created)
state = provider.StateRunning
} else {
g.log.Debug("Instance boot time not passed and cloud-init not finished", "server_id", srv.ID, "created", srv.Created, "boot_time", g.BootTime)
}
}
}
}

update(node.ID, state)
}

return nil
return reterr
}

func (g *InstanceGroup) Increase(ctx context.Context, delta int) (succeeded int, err error) {
Expand Down

0 comments on commit 2af7ced

Please sign in to comment.