| 372 | } |
| 373 | |
| 374 | func (a *Application) verifyHTTP(ctx context.Context) error { |
| 375 | url := a.URL() |
| 376 | if url == "" { |
| 377 | return nil |
| 378 | } |
| 379 | |
| 380 | client := &http.Client{Timeout: httpVerifyTimeout} |
| 381 | req, err := http.NewRequestWithContext(ctx, http.MethodGet, url+HealthCheckPath, nil) |
| 382 | if err != nil { |
| 383 | return fmt.Errorf("%w: %w", ErrVerificationFailed, err) |
| 384 | } |
| 385 | |
| 386 | resp, err := client.Do(req) |
| 387 | if err != nil { |
| 388 | return fmt.Errorf("%w: %w", ErrVerificationFailed, err) |
| 389 | } |
| 390 | defer resp.Body.Close() |
| 391 | |
| 392 | if resp.StatusCode < 200 || resp.StatusCode > 299 { |
| 393 | return fmt.Errorf("%w: unexpected status %d from %s", ErrVerificationFailed, resp.StatusCode, url) |
| 394 | } |
| 395 | |
| 396 | return nil |
| 397 | } |
| 398 | |
| 399 | func (a *Application) removeContainersExcept(ctx context.Context, keep string) error { |
| 400 | containers, err := a.namespace.client.ContainerList(ctx, container.ListOptions{All: true}) |