vectordotdev/vector · error

Failed to run cleanup command

Error message

Failed to run cleanup command: {e}

What it means

Compose test cleanup spawns `docker run alpine:3.20 sh -c "rm -rf /output/<test>/*"`. If the docker process cannot be spawned at all (the `status()` call errors), `cleanup_test_output` wraps the io::Error in this anyhow message. A nonzero exit only produces a warning, not this error.

Solutions

  1. Install/start Docker and confirm `docker run alpine:3.20 echo ok` works before running compose tests.
  2. Check that `docker` is on PATH in the environment running vdev.
  3. Note the previous run's output may remain: the failure is the spawn, but cleanup failures on exit status are only warnings — rerun after fixing Docker.
Defensive patterns

Strategy: try-catch

Validate before calling

import { execFileSync } from 'child_process';
try { execFileSync('docker', ['info'], { stdio: 'ignore' }); } catch {
  throw new Error('Docker is not available; compose test cleanup will fail');
}

Try / catch

try {
  await runCleanup();
} catch (e) {
  if (/Failed to run cleanup command/.test(String(e))) {
    // Docker unavailable: warn and continue, previous output may remain
    console.warn('Skipping compose output cleanup:', e.message);
  } else throw e;
}

Prevention

When it happens

Trigger: `docker` binary is missing from PATH; the Docker daemon is unreachable such that the client errors; volume/mount flags are invalid; OS-level permission failures prevent spawning the command.

Common situations: Running compose tests on a machine without Docker installed or with the daemon not running; PATH differs in CI; stale docker context pointing at a dead remote host.

Related errors


AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/512bdca550d36680. Report an issue: GitHub.

Appendix: source

Thrown at vdev/src/commands/compose_tests/run.rs:131

}

/// Clean up previous test output from the docker volume
fn cleanup_test_output(test_name: &str) -> Result<()> {
    debug!("Cleaning up previous test output for '{test_name}'");

    let status = Command::new(CONTAINER_TOOL.clone())
        .args([
            "run",
            "--rm",
            "-v",
            &format!("vector_target:/output/{test_name}"),
            "alpine:3.20",
            "sh",
            "-c",
            &format!("rm -rf /output/{test_name}/*"),
        ])
        .status()
        .map_err(|e| anyhow::anyhow!("Failed to run cleanup command: {e}"))?;

    if !status.success() {
        warn!("Failed to clean up previous test output (this may be okay if it didn't exist)");
    }

    Ok(())
}

/// Upload test results to Datadog (in CI only, no-op locally)
///
/// The script itself checks for CI environment and handles the logic.
fn upload_test_results() {
    let result = Command::script("upload-test-results.sh").status();

    match result {
        Ok(status) if !status.success() => {
            warn!("Upload script exited with non-zero status");
        }

View on GitHub (pinned to bdb87aeaa4)