Skip to content

Commit a6d703b

Browse files
authored
Merge pull request #604 from mbussolotto/wait
during upgrade, wait server is up and running (bsc#1244023)
2 parents 0734dbd + e1d103e commit a6d703b

3 files changed

Lines changed: 14 additions & 41 deletions

File tree

mgradm/shared/podman/podman.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,16 @@ func Upgrade(
416416
if err := updateServerSystemdService(); err != nil {
417417
return err
418418
}
419+
419420
log.Info().Msg(L("Waiting for the server to start…"))
421+
cnx := shared.NewConnection("podman", podman.ServerContainerName, "")
422+
if err := systemd.StartService(podman.ServerService); err != nil {
423+
return utils.Error(err, L("cannot start service"))
424+
}
425+
426+
if err := cnx.WaitForHealthcheck(); err != nil {
427+
log.Warn().Err(err)
428+
}
420429

421430
inspectedDB := adm_utils.DBFlags{
422431
Name: inspectedValues.DBName,
@@ -466,7 +475,7 @@ func WaitForSystemStart(
466475
return utils.Error(err, L("cannot enable service"))
467476
}
468477

469-
return cnx.WaitForServer()
478+
return cnx.WaitForHealthcheck()
470479
}
471480

472481
// Migrate will migrate a server to the image given as attribute.

shared/connection.go

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -281,47 +281,10 @@ func (c *Connection) WaitForContainer() error {
281281
return errors.New(L("container didn't start within 10s."))
282282
}
283283

284-
// WaitForServer waits at most 120s for multi-user systemd target to be reached.
285-
func (c *Connection) WaitForServer() error {
286-
// Wait for the system to be up
287-
for i := 0; i < 120; i++ {
288-
podName, err := c.GetPodName()
289-
if err != nil {
290-
log.Debug().Err(err)
291-
time.Sleep(1 * time.Second)
292-
continue
293-
}
294-
295-
namespace, err := c.GetNamespace("")
296-
if err != nil {
297-
return err
298-
}
299-
300-
args := []string{"exec", podName}
301-
command, err := c.GetCommand()
302-
if err != nil {
303-
return err
304-
}
305-
306-
if command == "kubectl" {
307-
args = append(args, "-n", namespace, "--")
308-
}
309-
args = append(args, "systemctl", "is-active", "-q", "multi-user.target")
310-
output := utils.RunCmd(command, args...)
311-
isActive := output == nil
312-
313-
if isActive {
314-
return nil
315-
}
316-
time.Sleep(1 * time.Second)
317-
}
318-
return errors.New(L("server didn't start within 120s. Check for the service status"))
319-
}
320-
321-
// WaitForHealthcheck waits at most 60s for healtcheck to succeed.
284+
// WaitForHealthcheck waits at most 120s for healtcheck to succeed.
322285
func (c *Connection) WaitForHealthcheck() error {
323286
// Wait for the system to be up
324-
for i := 0; i < 60; i++ {
287+
for i := 0; i < 120; i++ {
325288
_, err := c.Healthcheck()
326289
if err != nil {
327290
log.Debug().Err(err)
@@ -330,7 +293,7 @@ func (c *Connection) WaitForHealthcheck() error {
330293
}
331294
return nil
332295
}
333-
return errors.New(L("container didn't start within 60s. Check for the service status"))
296+
return errors.New(L("container didn't start within 120s. Check for the service status"))
334297
}
335298

336299
// Copy transfers a file to or from the container.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- During upgrade, wait server is up and running (bsc#1244023)

0 commit comments

Comments
 (0)