Wait until logcollection containers are ready

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2024-06-10 09:12:48 +02:00
parent 85c4f9be2a
commit 35a2ec031c
No known key found for this signature in database
GPG Key ID: 7DD3015F3DDE4B9C

View File

@ -200,6 +200,10 @@ func startPod(ctx context.Context, logger *slog.Logger) error {
if err := runLogstashCmd.Start(); err != nil {
return fmt.Errorf("failed to start logstash: %w", err)
}
if out, err := exec.CommandContext(ctx, "podman", "wait", "logstash", "--condition=running", "--interval=15s").CombinedOutput(); err != nil {
logger.Error("Logstash container failed to reach healthy status", "err", err, "output", out)
return fmt.Errorf("waiting for logstash container to reach healthy status: %w; output: %s", err, out)
}
// start filebeat container
filebeatLog := newCmdLogger(logger.WithGroup("filebeat"))
@ -225,6 +229,10 @@ func startPod(ctx context.Context, logger *slog.Logger) error {
if err := runFilebeatCmd.Start(); err != nil {
return fmt.Errorf("failed to run filebeat: %w", err)
}
if out, err := exec.CommandContext(ctx, "podman", "wait", "filebeat", "--condition=running", "--interval=15s").CombinedOutput(); err != nil {
logger.Error("Filebeat container failed to reach healthy status", "err", err, "output", out)
return fmt.Errorf("waiting for filebeat container to reach healthy status: %w; output: %s", err, out)
}
return nil
}