Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions shared/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,26 +307,34 @@ func (c *Connection) ExecScript(script string) ([]byte, error) {
}

// Healthcheck runs healthcheck command inside the container.
func (c *Connection) Healthcheck() ([]byte, error) {
func (c *Connection) Healthcheck() error {
if c.podName == "" {
if _, err := c.GetPodName(); c.podName == "" {
return nil, utils.Errorf(err, L("Healthcheck not executed"))
return utils.Errorf(err, L("Healthcheck not executed"))
}
}

cmd, cmdErr := c.GetCommand()
if cmdErr != nil {
return nil, cmdErr
return cmdErr
}

if cmd == "host" {
// Healthcheck not supported on host, always return nil
return nil, nil
return nil
}

cmdArgs := []string{"healthcheck", "run", c.podName}
cmdArgs := []string{"inspect", "--format", "{{ .State.Health.Status }}", c.podName}

return runner(cmd, cmdArgs...).Log(zerolog.DebugLevel).Spinner("").Exec()
out, err := runner(cmd, cmdArgs...).Log(zerolog.DebugLevel).Spinner("").Exec()
if err != nil {
return err
}
outStr := strings.TrimSpace(string(out))
if outStr != "healthy" && outStr != "running" {
return errors.New(L("not healthy or running"))
}
return nil
}

// WaitForContainer waits up to 10 sec for the container to appear.
Expand Down Expand Up @@ -380,7 +388,7 @@ func (c *Connection) WaitForHealthcheck() error {
}
// once here, container started at least once, clear startupTimeout
startupTimeout = 0
_, err := c.Healthcheck()
err := c.Healthcheck()
if err != nil {
log.Debug().Err(err)
time.Sleep(1 * time.Second)
Expand Down
2 changes: 2 additions & 0 deletions uyuni-tools.changes.cbosdo.healthcheck-wait
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Do not call podman healthcheck run to wait for pods to be ready
(bsc#1266012)
Loading