Skip to content

Commit be3b789

Browse files
authored
apacheGH-40954: [CI] Fix use of obsolete docker-compose command on Github Actions (apache#40949)
### Rationale for this change The `docker-compose` utility is progressively being removed from GHA-provided runners: actions/runner-images#9557 ### What changes are included in this PR? Use `docker` client CLI directly instead of `docker-compose` where possible. ### Are these changes tested? Yes, this should fix the sporadic CI failures because of the above migration. ### Are there any user-facing changes? No, except additional optional env var `ARCHERY_DEBUG`. * GitHub Issue: apache#40954 Authored-by: Antoine Pitrou <[email protected]> Signed-off-by: Antoine Pitrou <[email protected]>
1 parent 41a989c commit be3b789

23 files changed

+117
-87
lines changed

.github/workflows/archery.yml

+2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ on:
3232
- 'docker-compose.yml'
3333

3434
env:
35+
ARCHERY_DEBUG: 1
3536
ARCHERY_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
37+
ARCHERY_USE_DOCKER_CLI: 1
3638

3739
concurrency:
3840
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}

.github/workflows/cpp.yml

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ permissions:
5353
contents: read
5454

5555
env:
56+
ARCHERY_DEBUG: 1
5657
ARROW_ENABLE_TIMING_TESTS: OFF
5758
DOCKER_VOLUME_PREFIX: ".docker/"
5859

@@ -94,6 +95,7 @@ jobs:
9495
cat <<JSON >> "$GITHUB_OUTPUT"
9596
{
9697
"arch": "arm64v8",
98+
"archery-use-docker-cli": "0",
9799
"clang-tools": "10",
98100
"image": "ubuntu-cpp",
99101
"llvm": "10",
@@ -118,6 +120,9 @@ jobs:
118120
include: ${{ fromJson(needs.docker-targets.outputs.targets) }}
119121
env:
120122
ARCH: ${{ matrix.arch }}
123+
# By default, use Docker CLI because docker-compose v1 is obsolete,
124+
# except where the Docker client version is too old.
125+
ARCHERY_USE_DOCKER_CLI: ${{ matrix.archery-use-docker-cli || '1' }}
121126
ARROW_SIMD_LEVEL: ${{ matrix.simd-level }}
122127
CLANG_TOOLS: ${{ matrix.clang-tools }}
123128
LLVM: ${{ matrix.llvm }}

.github/workflows/dev.yml

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ concurrency:
2929
permissions:
3030
contents: read
3131

32+
env:
33+
ARCHERY_DEBUG: 1
34+
ARCHERY_USE_DOCKER_CLI: 1
35+
3236
jobs:
3337

3438
lint:

.github/workflows/docs.yml

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ permissions:
2424
contents: read
2525

2626
env:
27+
ARCHERY_DEBUG: 1
28+
ARCHERY_USE_DOCKER_CLI: 1
2729
ARROW_ENABLE_TIMING_TESTS: OFF
2830
DOCKER_VOLUME_PREFIX: ".docker/"
2931

.github/workflows/docs_light.yml

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ permissions:
3333
contents: read
3434

3535
env:
36+
ARCHERY_DEBUG: 1
37+
ARCHERY_USE_DOCKER_CLI: 1
3638
ARROW_ENABLE_TIMING_TESTS: OFF
3739
DOCKER_VOLUME_PREFIX: ".docker/"
3840

.github/workflows/go.yml

+9
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ concurrency:
4141
permissions:
4242
contents: read
4343

44+
env:
45+
ARCHERY_DEBUG: 1
46+
ARCHERY_USE_DOCKER_CLI: 1
47+
4448
jobs:
4549

4650
docker-targets:
@@ -75,12 +79,14 @@ jobs:
7579
{
7680
"arch-label": "ARM64",
7781
"arch": "arm64v8",
82+
"archery-use-docker-cli": "0",
7883
"go": "1.21",
7984
"runs-on": ["self-hosted", "arm", "linux"]
8085
},
8186
{
8287
"arch-label": "ARM64",
8388
"arch": "arm64v8",
89+
"archery-use-docker-cli": "0",
8490
"go": "1.22",
8591
"runs-on": ["self-hosted", "arm", "linux"]
8692
}
@@ -101,6 +107,9 @@ jobs:
101107
include: ${{ fromJson(needs.docker-targets.outputs.targets) }}
102108
env:
103109
ARCH: ${{ matrix.arch }}
110+
# By default, use Docker CLI because docker-compose v1 is obsolete,
111+
# except where the Docker client version is too old.
112+
ARCHERY_USE_DOCKER_CLI: ${{ matrix.archery-use-docker-cli || '1' }}
104113
GO: ${{ matrix.go }}
105114
steps:
106115
- name: Checkout Arrow

.github/workflows/integration.yml

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ permissions:
5151
contents: read
5252

5353
env:
54+
ARCHERY_DEBUG: 1
55+
ARCHERY_USE_DOCKER_CLI: 1
5456
DOCKER_VOLUME_PREFIX: ".docker/"
5557

5658
jobs:

.github/workflows/java.yml

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ permissions:
4545
contents: read
4646

4747
env:
48+
ARCHERY_DEBUG: 1
49+
ARCHERY_USE_DOCKER_CLI: 1
4850
DOCKER_VOLUME_PREFIX: ".docker/"
4951

5052
jobs:

.github/workflows/java_jni.yml

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ permissions:
4545
contents: read
4646

4747
env:
48+
ARCHERY_DEBUG: 1
49+
ARCHERY_USE_DOCKER_CLI: 1
4850
DOCKER_VOLUME_PREFIX: ".docker/"
4951

5052
jobs:

.github/workflows/js.yml

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ concurrency:
3838
permissions:
3939
contents: read
4040

41+
env:
42+
ARCHERY_DEBUG: 1
43+
ARCHERY_USE_DOCKER_CLI: 1
44+
4145
jobs:
4246

4347
docker:

.github/workflows/python.yml

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ permissions:
4141
contents: read
4242

4343
env:
44+
ARCHERY_DEBUG: 1
45+
ARCHERY_USE_DOCKER_CLI: 1
4446
DOCKER_VOLUME_PREFIX: ".docker/"
4547

4648
jobs:

.github/workflows/r.yml

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ permissions:
5151
contents: read
5252

5353
env:
54+
ARCHERY_DEBUG: 1
55+
ARCHERY_USE_DOCKER_CLI: 1
5456
DOCKER_VOLUME_PREFIX: ".docker/"
5557

5658
jobs:

.github/workflows/ruby.yml

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ permissions:
5353
contents: read
5454

5555
env:
56+
ARCHERY_DEBUG: 1
57+
ARCHERY_USE_DOCKER_CLI: 1
5658
DOCKER_VOLUME_PREFIX: ".docker/"
5759

5860
jobs:

.github/workflows/swift.yml

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ permissions:
4141
contents: read
4242

4343
env:
44+
ARCHERY_DEBUG: 1
45+
ARCHERY_USE_DOCKER_CLI: 1
4446
DOCKER_VOLUME_PREFIX: ".docker/"
4547

4648
jobs:

dev/archery/archery/cli.py

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
@click.group(context_settings={"help_option_names": ["-h", "--help"]})
4646
@click.option("--debug", type=BOOL, is_flag=True, default=False,
47+
envvar='ARCHERY_DEBUG',
4748
help="Increase logging with debugging output.")
4849
@click.option("--pdb", type=BOOL, is_flag=True, default=False,
4950
help="Invoke pdb on uncaught exception.")

dev/archery/archery/docker/cli.py

+26-53
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,19 @@ def _execute(self, *args, **kwargs):
4646
callback=validate_arrow_sources,
4747
help="Specify Arrow source directory.")
4848
@click.option('--dry-run/--execute', default=False,
49-
help="Display the docker-compose commands instead of executing "
50-
"them.")
49+
help="Display the docker commands instead of executing them.")
50+
@click.option('--using-docker-cli', default=False, is_flag=True,
51+
envvar='ARCHERY_USE_DOCKER_CLI',
52+
help="Use docker CLI directly for building instead of calling "
53+
"docker-compose. This may help to reuse cached layers.")
54+
@click.option('--using-docker-buildx', default=False, is_flag=True,
55+
envvar='ARCHERY_USE_DOCKER_BUILDX',
56+
help="Use buildx with docker CLI directly for building instead "
57+
"of calling docker-compose or the plain docker build "
58+
"command. This option makes the build cache reusable "
59+
"across hosts.")
5160
@click.pass_context
52-
def docker(ctx, src, dry_run):
61+
def docker(ctx, src, dry_run, using_docker_cli, using_docker_buildx):
5362
"""
5463
Interact with docker-compose based builds.
5564
"""
@@ -64,7 +73,10 @@ def docker(ctx, src, dry_run):
6473

6574
# take the docker-compose parameters like PYTHON, PANDAS, UBUNTU from the
6675
# environment variables to keep the usage similar to docker-compose
76+
using_docker_cli |= using_docker_buildx
6777
compose = DockerCompose(config_path, params=os.environ,
78+
using_docker=using_docker_cli,
79+
using_buildx=using_docker_buildx,
6880
debug=ctx.obj.get('debug', False))
6981
if dry_run:
7082
_mock_compose_calls(compose)
@@ -83,24 +95,19 @@ def check_config(obj):
8395

8496
@docker.command('pull')
8597
@click.argument('image')
86-
@click.option('--using-docker-cli', default=False, is_flag=True,
87-
envvar='ARCHERY_USE_DOCKER_CLI',
88-
help="Use docker CLI directly for pulling instead of calling "
89-
"docker-compose. This may help to reuse cached layers.")
9098
@click.option('--pull-leaf/--no-leaf', default=True,
9199
help="Whether to pull leaf images too.")
92100
@click.option('--ignore-pull-failures/--no-ignore-pull-failures', default=True,
93101
help="Whether to ignore pull failures.")
94102
@click.pass_obj
95-
def docker_pull(obj, image, *, using_docker_cli, pull_leaf,
96-
ignore_pull_failures):
103+
def docker_pull(obj, image, *, pull_leaf, ignore_pull_failures):
97104
"""
98105
Execute docker-compose pull.
99106
"""
100107
compose = obj['compose']
101108

102109
try:
103-
compose.pull(image, pull_leaf=pull_leaf, using_docker=using_docker_cli,
110+
compose.pull(image, pull_leaf=pull_leaf,
104111
ignore_pull_failures=ignore_pull_failures)
105112
except UndefinedImage as e:
106113
raise click.ClickException(
@@ -115,16 +122,6 @@ def docker_pull(obj, image, *, using_docker_cli, pull_leaf,
115122
@click.argument('image')
116123
@click.option('--force-pull/--no-pull', default=True,
117124
help="Whether to force pull the image and its ancestor images")
118-
@click.option('--using-docker-cli', default=False, is_flag=True,
119-
envvar='ARCHERY_USE_DOCKER_CLI',
120-
help="Use docker CLI directly for building instead of calling "
121-
"docker-compose. This may help to reuse cached layers.")
122-
@click.option('--using-docker-buildx', default=False, is_flag=True,
123-
envvar='ARCHERY_USE_DOCKER_BUILDX',
124-
help="Use buildx with docker CLI directly for building instead "
125-
"of calling docker-compose or the plain docker build "
126-
"command. This option makes the build cache reusable "
127-
"across hosts.")
128125
@click.option('--use-cache/--no-cache', default=True,
129126
help="Whether to use cache when building the image and its "
130127
"ancestor images")
@@ -133,22 +130,17 @@ def docker_pull(obj, image, *, using_docker_cli, pull_leaf,
133130
"passed as the argument. To disable caching for both the "
134131
"image and its ancestors use --no-cache option.")
135132
@click.pass_obj
136-
def docker_build(obj, image, *, force_pull, using_docker_cli,
137-
using_docker_buildx, use_cache, use_leaf_cache):
133+
def docker_build(obj, image, *, force_pull, use_cache, use_leaf_cache):
138134
"""
139135
Execute docker-compose builds.
140136
"""
141137
compose = obj['compose']
142138

143-
using_docker_cli |= using_docker_buildx
144139
try:
145140
if force_pull:
146-
compose.pull(image, pull_leaf=use_leaf_cache,
147-
using_docker=using_docker_cli)
141+
compose.pull(image, pull_leaf=use_leaf_cache)
148142
compose.build(image, use_cache=use_cache,
149143
use_leaf_cache=use_leaf_cache,
150-
using_docker=using_docker_cli,
151-
using_buildx=using_docker_buildx,
152144
pull_parents=force_pull)
153145
except UndefinedImage as e:
154146
raise click.ClickException(
@@ -172,16 +164,6 @@ def docker_build(obj, image, *, force_pull, using_docker_cli,
172164
help="Whether to force build the image and its ancestor images")
173165
@click.option('--build-only', default=False, is_flag=True,
174166
help="Pull and/or build the image, but do not run it")
175-
@click.option('--using-docker-cli', default=False, is_flag=True,
176-
envvar='ARCHERY_USE_DOCKER_CLI',
177-
help="Use docker CLI directly for building instead of calling "
178-
"docker-compose. This may help to reuse cached layers.")
179-
@click.option('--using-docker-buildx', default=False, is_flag=True,
180-
envvar='ARCHERY_USE_DOCKER_BUILDX',
181-
help="Use buildx with docker CLI directly for building instead "
182-
"of calling docker-compose or the plain docker build "
183-
"command. This option makes the build cache reusable "
184-
"across hosts.")
185167
@click.option('--use-cache/--no-cache', default=True,
186168
help="Whether to use cache when building the image and its "
187169
"ancestor images")
@@ -191,16 +173,16 @@ def docker_build(obj, image, *, force_pull, using_docker_cli,
191173
"image and its ancestors use --no-cache option.")
192174
@click.option('--resource-limit', default=None,
193175
help="A CPU/memory limit preset to mimic CI environments like "
194-
"GitHub Actions. Implies --using-docker-cli. Note that "
176+
"GitHub Actions. Mandates --using-docker-cli. Note that "
195177
"exporting ARCHERY_DOCKER_BIN=\"sudo docker\" is likely "
196178
"required, unless Docker is configured with cgroups v2 "
197179
"(else Docker will silently ignore the limits).")
198180
@click.option('--volume', '-v', multiple=True,
199181
help="Set volume within the container")
200182
@click.pass_obj
201183
def docker_run(obj, image, command, *, env, user, force_pull, force_build,
202-
build_only, using_docker_cli, using_docker_buildx, use_cache,
203-
use_leaf_cache, resource_limit, volume):
184+
build_only, use_cache, use_leaf_cache, resource_limit,
185+
volume):
204186
"""
205187
Execute docker-compose builds.
206188
@@ -234,26 +216,21 @@ def docker_run(obj, image, command, *, env, user, force_pull, force_build,
234216
archery docker run ubuntu-cpp bash
235217
"""
236218
compose = obj['compose']
237-
using_docker_cli |= using_docker_buildx
238219

239220
env = dict(kv.split('=', 1) for kv in env)
240221
try:
241222
if force_pull:
242-
compose.pull(image, pull_leaf=use_leaf_cache,
243-
using_docker=using_docker_cli)
223+
compose.pull(image, pull_leaf=use_leaf_cache)
244224
if force_build:
245225
compose.build(image, use_cache=use_cache,
246-
use_leaf_cache=use_leaf_cache,
247-
using_docker=using_docker_cli,
248-
using_buildx=using_docker_buildx)
226+
use_leaf_cache=use_leaf_cache)
249227
if build_only:
250228
return
251229
compose.run(
252230
image,
253231
command=command,
254232
env=env,
255233
user=user,
256-
using_docker=using_docker_cli,
257234
resource_limit=resource_limit,
258235
volumes=volume
259236
)
@@ -273,15 +250,11 @@ def docker_run(obj, image, command, *, env, user, force_pull, force_build,
273250
@click.option('--password', '-p', required=False,
274251
envvar='ARCHERY_DOCKER_PASSWORD',
275252
help='Docker repository password')
276-
@click.option('--using-docker-cli', default=False, is_flag=True,
277-
help="Use docker CLI directly for building instead of calling "
278-
"docker-compose. This may help to reuse cached layers.")
279253
@click.pass_obj
280-
def docker_compose_push(obj, image, user, password, using_docker_cli):
254+
def docker_compose_push(obj, image, user, password):
281255
"""Push the generated docker-compose image."""
282256
compose = obj['compose']
283-
compose.push(image, user=user, password=password,
284-
using_docker=using_docker_cli)
257+
compose.push(image, user=user, password=password)
285258

286259

287260
@docker.command('images')

0 commit comments

Comments
 (0)