mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-25 23:49:37 -05:00
debugd: use runc as podman runtime (#3205)
This commit is contained in:
parent
ca8d11861d
commit
3b64e654d1
@ -130,7 +130,7 @@ func getTemplate(ctx context.Context, logger *slog.Logger, image, templateDir, d
|
|||||||
"--name=template",
|
"--name=template",
|
||||||
image,
|
image,
|
||||||
}
|
}
|
||||||
createContainerCmd := exec.CommandContext(ctx, "podman", createContainerArgs...)
|
createContainerCmd := podman(ctx, createContainerArgs...)
|
||||||
logger.Info("Creating template container")
|
logger.Info("Creating template container")
|
||||||
if out, err := createContainerCmd.CombinedOutput(); err != nil {
|
if out, err := createContainerCmd.CombinedOutput(); err != nil {
|
||||||
return nil, fmt.Errorf("creating template container: %w\n%s", err, out)
|
return nil, fmt.Errorf("creating template container: %w\n%s", err, out)
|
||||||
@ -145,7 +145,7 @@ func getTemplate(ctx context.Context, logger *slog.Logger, image, templateDir, d
|
|||||||
"template:/usr/share/constellogs/templates/",
|
"template:/usr/share/constellogs/templates/",
|
||||||
destDir,
|
destDir,
|
||||||
}
|
}
|
||||||
copyFromCmd := exec.CommandContext(ctx, "podman", copyFromArgs...)
|
copyFromCmd := podman(ctx, copyFromArgs...)
|
||||||
logger.Info("Copying templates")
|
logger.Info("Copying templates")
|
||||||
if out, err := copyFromCmd.CombinedOutput(); err != nil {
|
if out, err := copyFromCmd.CombinedOutput(); err != nil {
|
||||||
return nil, fmt.Errorf("copying templates: %w\n%s", err, out)
|
return nil, fmt.Errorf("copying templates: %w\n%s", err, out)
|
||||||
@ -155,7 +155,7 @@ func getTemplate(ctx context.Context, logger *slog.Logger, image, templateDir, d
|
|||||||
"rm",
|
"rm",
|
||||||
"template",
|
"template",
|
||||||
}
|
}
|
||||||
removeContainerCmd := exec.CommandContext(ctx, "podman", removeContainerArgs...)
|
removeContainerCmd := podman(ctx, removeContainerArgs...)
|
||||||
logger.Info("Removing template container")
|
logger.Info("Removing template container")
|
||||||
if out, err := removeContainerCmd.CombinedOutput(); err != nil {
|
if out, err := removeContainerCmd.CombinedOutput(); err != nil {
|
||||||
return nil, fmt.Errorf("removing template container: %w\n%s", err, out)
|
return nil, fmt.Errorf("removing template container: %w\n%s", err, out)
|
||||||
@ -176,7 +176,7 @@ func startPod(ctx context.Context, logger *slog.Logger) error {
|
|||||||
"create",
|
"create",
|
||||||
"logcollection",
|
"logcollection",
|
||||||
}
|
}
|
||||||
createPodCmd := exec.CommandContext(ctx, "podman", createPodArgs...)
|
createPodCmd := podman(ctx, createPodArgs...)
|
||||||
logger.Info(fmt.Sprintf("Create pod command: %v", createPodCmd.String()))
|
logger.Info(fmt.Sprintf("Create pod command: %v", createPodCmd.String()))
|
||||||
if out, err := createPodCmd.CombinedOutput(); err != nil {
|
if out, err := createPodCmd.CombinedOutput(); err != nil {
|
||||||
return fmt.Errorf("failed to create pod: %w; output: %s", err, out)
|
return fmt.Errorf("failed to create pod: %w; output: %s", err, out)
|
||||||
@ -189,18 +189,18 @@ func startPod(ctx context.Context, logger *slog.Logger) error {
|
|||||||
"--rm",
|
"--rm",
|
||||||
"--name=logstash",
|
"--name=logstash",
|
||||||
"--pod=logcollection",
|
"--pod=logcollection",
|
||||||
"--log-driver=none",
|
"--log-driver=journald",
|
||||||
"--volume=/run/logstash/pipeline:/usr/share/logstash/pipeline/:ro",
|
"--volume=/run/logstash/pipeline:/usr/share/logstash/pipeline/:ro",
|
||||||
versions.LogstashImage,
|
versions.LogstashImage,
|
||||||
}
|
}
|
||||||
runLogstashCmd := exec.CommandContext(ctx, "podman", runLogstashArgs...)
|
runLogstashCmd := podman(ctx, runLogstashArgs...)
|
||||||
logger.Info(fmt.Sprintf("Run logstash command: %v", runLogstashCmd.String()))
|
logger.Info(fmt.Sprintf("Run logstash command: %v", runLogstashCmd.String()))
|
||||||
runLogstashCmd.Stdout = logstashLog
|
runLogstashCmd.Stdout = logstashLog
|
||||||
runLogstashCmd.Stderr = logstashLog
|
runLogstashCmd.Stderr = logstashLog
|
||||||
if err := runLogstashCmd.Start(); err != nil {
|
if err := runLogstashCmd.Start(); err != nil {
|
||||||
return fmt.Errorf("failed to start logstash: %w", err)
|
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 {
|
if out, err := podman(ctx, "wait", "logstash", "--condition=running", "--interval=15s").CombinedOutput(); err != nil {
|
||||||
logger.Error("Logstash container failed to reach healthy status", "err", err, "output", out)
|
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)
|
return fmt.Errorf("waiting for logstash container to reach healthy status: %w; output: %s", err, out)
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ func startPod(ctx context.Context, logger *slog.Logger) error {
|
|||||||
"--name=filebeat",
|
"--name=filebeat",
|
||||||
"--pod=logcollection",
|
"--pod=logcollection",
|
||||||
"--privileged",
|
"--privileged",
|
||||||
"--log-driver=none",
|
"--log-driver=journald",
|
||||||
"--volume=/run/log/journal:/run/log/journal:ro",
|
"--volume=/run/log/journal:/run/log/journal:ro",
|
||||||
"--volume=/etc/machine-id:/etc/machine-id:ro",
|
"--volume=/etc/machine-id:/etc/machine-id:ro",
|
||||||
"--volume=/run/systemd:/run/systemd:ro",
|
"--volume=/run/systemd:/run/systemd:ro",
|
||||||
@ -222,14 +222,14 @@ func startPod(ctx context.Context, logger *slog.Logger) error {
|
|||||||
"--volume=/run/filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro",
|
"--volume=/run/filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro",
|
||||||
versions.FilebeatImage,
|
versions.FilebeatImage,
|
||||||
}
|
}
|
||||||
runFilebeatCmd := exec.CommandContext(ctx, "podman", runFilebeatArgs...)
|
runFilebeatCmd := podman(ctx, runFilebeatArgs...)
|
||||||
logger.Info(fmt.Sprintf("Run filebeat command: %v", runFilebeatCmd.String()))
|
logger.Info(fmt.Sprintf("Run filebeat command: %v", runFilebeatCmd.String()))
|
||||||
runFilebeatCmd.Stdout = filebeatLog
|
runFilebeatCmd.Stdout = filebeatLog
|
||||||
runFilebeatCmd.Stderr = filebeatLog
|
runFilebeatCmd.Stderr = filebeatLog
|
||||||
if err := runFilebeatCmd.Start(); err != nil {
|
if err := runFilebeatCmd.Start(); err != nil {
|
||||||
return fmt.Errorf("failed to run filebeat: %w", err)
|
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 {
|
if out, err := podman(ctx, "wait", "filebeat", "--condition=running", "--interval=15s").CombinedOutput(); err != nil {
|
||||||
logger.Error("Filebeat container failed to reach healthy status", "err", err, "output", out)
|
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 fmt.Errorf("waiting for filebeat container to reach healthy status: %w; output: %s", err, out)
|
||||||
}
|
}
|
||||||
@ -316,6 +316,11 @@ func (c *cmdLogger) Write(p []byte) (n int, err error) {
|
|||||||
return len(p), nil
|
return len(p), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func podman(ctx context.Context, args ...string) *exec.Cmd {
|
||||||
|
args = append([]string{"--runtime=runc"}, args...)
|
||||||
|
return exec.CommandContext(ctx, "podman", args...)
|
||||||
|
}
|
||||||
|
|
||||||
type providerMetadata interface {
|
type providerMetadata interface {
|
||||||
// Self retrieves the current instance.
|
// Self retrieves the current instance.
|
||||||
Self(ctx context.Context) (metadata.InstanceMetadata, error)
|
Self(ctx context.Context) (metadata.InstanceMetadata, error)
|
||||||
|
Loading…
Reference in New Issue
Block a user