From 2af7cedcf8898416eaf343933fced022168f5d69 Mon Sep 17 00:00:00 2001 From: Vladimir Ermakov Date: Fri, 10 Nov 2023 18:17:07 +0100 Subject: [PATCH] wait for cloud-init finish, which likely accours earlier than the boot-time --- provider.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/provider.go b/provider.go index e0776f7..3be0858 100644 --- a/provider.go +++ b/provider.go @@ -137,9 +137,23 @@ 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) + } } } } @@ -147,7 +161,7 @@ func (g *InstanceGroup) Update(ctx context.Context, update func(instance string, update(node.ID, state) } - return nil + return reterr } func (g *InstanceGroup) Increase(ctx context.Context, delta int) (succeeded int, err error) {