1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-11 17:50:58 +00:00

support ErrContainerNotFound in health check timeout retrieval too

This commit is contained in:
Mathieu Fenniak 2025-08-05 21:32:50 -06:00
parent 7b75a647d4
commit a274893fe5
2 changed files with 7 additions and 2 deletions

View file

@ -221,7 +221,9 @@ func (cr *containerReference) GetHealth(ctx context.Context) (Health, error) {
func (cr *containerReference) GetHealthCheckTimeout(ctx context.Context) (*time.Duration, error) {
resp, err := cr.cli.ContainerInspect(ctx, cr.id)
if err != nil {
if cerrdefs.IsNotFound(err) {
return nil, ErrContainerNotFound
} else if err != nil {
return nil, err
}
if resp.Config == nil || resp.Config.Healthcheck == nil || len(resp.Config.Healthcheck.Test) == 1 && strings.EqualFold(resp.Config.Healthcheck.Test[0], "NONE") {

View file

@ -749,7 +749,10 @@ func (rc *RunContext) waitForServiceContainer(c container.ExecutionsEnvironment,
return func(ctx context.Context) error {
logger := common.Logger(ctx)
timeout, err := c.GetHealthCheckTimeout(ctx)
if err != nil {
if errors.Is(err, container.ErrContainerNotFound) {
// Terminated really early -- maintain same message as ErrContainerNotFound state in the loop.
return fmt.Errorf("service container %s: failed health check or terminated before becoming healthy", serviceID)
} else if err != nil {
return fmt.Errorf("service container %s: error retrieving health check details: %v", serviceID, err)
} else if timeout == nil {
logger.Debugf("service container %s: skipping health check wait", serviceID)