Skip to content

Commit 68bbdec

Browse files
authored
Use Docker Compose v2 (docker compose) in the compose log collector (#148)
* Use Docker Compose v2 (`docker compose`) in the compose log collector The compose collector shells out to `docker-compose -f ... -p ... ps -q ...` (Compose v1) to locate containers for log collection. GitHub-hosted `ubuntu-24.04` runners no longer ship the standalone `docker-compose` (v1) binary, so collection fails with `docker-compose: command not found` on every failed e2e (setup already uses Compose v2 via testcontainers-go, so only the collector was still on v1). Switch `ComposeCommand` from `docker-compose` to `docker compose`. The command is run via `bash -ec`, so the two-word v2 plugin invocation works as-is, and v2 accepts the same `-f / -p / ps -q` flags. Validated locally with a compose e2e (nginx): with `docker-compose` v1 absent (and with a failing `docker-compose` stub shadowing PATH), `e2e run` completes green and the collector gathers container files via `docker compose` v2 without ever invoking `docker-compose`. * Add CI coverage for the compose log collector infra-e2e's own e2e (`test/e2e/e2e.yaml`) runs on `ubuntu-latest` (which ships only Docker Compose v2) but never exercised the compose log collector, so the v1->v2 breakage slipped through CI and the prior fix had no regression guard. Add a `cleanup.collect` config (httpbin / /etc/hostname) and a verify case that runs `e2e collect` against the already-running stack and asserts a container file was gathered. The collector now runs in CI on a v1-less runner, proving it works via `docker compose` v2 and failing the build if it ever regresses to `docker-compose` v1. Validated locally: `e2e collect` gathers /etc/hostname from the httpbin service and the verify case reports `1 passed`.
1 parent 0d91769 commit 68bbdec

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

internal/constant/compose.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ package constant
2020

2121
const (
2222
Compose = "compose"
23-
ComposeCommand = "docker-compose"
23+
ComposeCommand = "docker compose"
2424
)

test/e2e/collect-expected.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to Apache Software Foundation (ASF) under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Apache Software Foundation (ASF) licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
collected: "true"

test/e2e/e2e.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ setup:
2424
cleanup:
2525
# always never success failure
2626
on: always
27+
# Exercise the compose log collector in CI so a regression to Docker Compose v1 is
28+
# caught: GitHub-hosted runners ship only Compose v2, so the collector must use
29+
# `docker compose`. Auto-collect is off here; the verify case below invokes
30+
# `e2e collect` explicitly and asserts a file was collected.
31+
collect:
32+
on: never
33+
output-dir: /tmp/e2e-collect-check
34+
items:
35+
- service: httpbin
36+
paths:
37+
- /etc/hostname
2738

2839
verify:
2940
# verify with retry strategy
@@ -56,3 +67,13 @@ verify:
5667
query: './bin/linux/e2e verify -c ./test/e2e/concurrency/non-fail-fast/internal/verify.yaml --summary-only -o yaml'
5768
expected: ./concurrency/non-fail-fast/expected.yaml
5869

70+
# Guards the compose log collector against a regression to Docker Compose v1
71+
# (which is absent on GitHub-hosted runners). Runs `e2e collect` against the
72+
# already-running compose stack and asserts a container file was collected.
73+
- name: compose log collector works on Docker Compose v2
74+
query: |
75+
rm -rf /tmp/e2e-collect-check
76+
./bin/linux/e2e collect -c ./test/e2e/e2e.yaml > /dev/null 2>&1 || true
77+
if [ -s /tmp/e2e-collect-check/httpbin/etc/hostname ]; then echo 'collected: "true"'; else echo 'collected: "false"'; fi
78+
expected: ./collect-expected.yaml
79+

0 commit comments

Comments
 (0)