Skip to content

Commit a02775f

Browse files
authored
Fix make compose (#1077)
The change from "docker-compose" to "docker compose" was broken. Also it turns out we need to have the CITUSTAG to PGVERSION compat matrix around when preparing the "docker compose build" command line.
1 parent 8749d82 commit a02775f

File tree

4 files changed

+70
-44
lines changed

4 files changed

+70
-44
lines changed

Dockerfile

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# target version of Postgres. In the Makefile, we use that to our advantage
44
# and tag test images such as pg_auto_failover_test:pg14.
55
#
6-
ARG PGVERSION=14
6+
ARG PGVERSION=17
77

88
#
99
# Define a base image with all our build dependencies.
@@ -18,18 +18,18 @@ RUN apt-get update \
1818
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
1919
build-essential \
2020
ca-certificates \
21-
curl \
22-
gnupg \
23-
git \
24-
gawk \
25-
flex \
26-
bison \
21+
curl \
22+
gnupg \
23+
git \
24+
gawk \
25+
flex \
26+
bison \
2727
iproute2 \
28-
libcurl4-gnutls-dev \
29-
libicu-dev \
30-
libncurses-dev \
31-
libxml2-dev \
32-
zlib1g-dev \
28+
libcurl4-gnutls-dev \
29+
libicu-dev \
30+
libncurses-dev \
31+
libxml2-dev \
32+
zlib1g-dev \
3333
libedit-dev \
3434
libkrb5-dev \
3535
liblz4-dev \
@@ -41,27 +41,27 @@ RUN apt-get update \
4141
libxslt1-dev \
4242
libzstd-dev \
4343
uuid-dev \
44-
make \
45-
autoconf \
44+
make \
45+
autoconf \
4646
openssl \
4747
pipenv \
4848
python3-nose \
4949
python3 \
50-
python3-setuptools \
51-
python3-psycopg2 \
50+
python3-setuptools \
51+
python3-psycopg2 \
5252
python3-pip \
53-
sudo \
53+
sudo \
5454
tmux \
5555
watch \
5656
lsof \
5757
psutils \
5858
psmisc \
5959
htop \
6060
less \
61-
mg \
61+
mg \
6262
valgrind \
6363
postgresql-common \
64-
&& rm -rf /var/lib/apt/lists/*
64+
&& rm -rf /var/lib/apt/lists/*
6565

6666
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
6767
RUN echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.list
@@ -84,7 +84,7 @@ RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
8484
FROM base AS citus
8585

8686
ARG PGVERSION
87-
ARG CITUSTAG=v11.1.2
87+
ARG CITUSTAG=v13.0.1
8888

8989
ENV PG_CONFIG=/usr/lib/postgresql/${PGVERSION}/bin/pg_config
9090

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ CLUSTER_OPTS = ""
1616
# XXXX This should be in Makefile.citus only
1717
# but requires to clean up dockerfile and make targets related to citus first.
1818
# Default Citus Data version
19-
CITUSTAG ?= v13.0.0
19+
CITUSTAG ?= v13.0.1
2020

2121
# TODO should be abs_top_dir ?
2222
TOP := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
@@ -273,8 +273,8 @@ endif
273273

274274
# We use pg not PG in uppercase in the var name to ease implicit rules matching
275275
BUILD_ARGS_pg13 = --build-arg PGVERSION=13 --build-arg CITUSTAG=v10.2.9
276-
BUILD_ARGS_pg14 = --build-arg PGVERSION=14 --build-arg CITUSTAG=$(CITUSTAG)
277-
BUILD_ARGS_pg15 = --build-arg PGVERSION=15 --build-arg CITUSTAG=$(CITUSTAG)
276+
BUILD_ARGS_pg14 = --build-arg PGVERSION=14 --build-arg CITUSTAG=v12.1.5
277+
BUILD_ARGS_pg15 = --build-arg PGVERSION=15 --build-arg CITUSTAG=v12.1.5
278278
BUILD_ARGS_pg16 = --build-arg PGVERSION=16 --build-arg CITUSTAG=$(CITUSTAG)
279279
BUILD_ARGS_pg17 = --build-arg PGVERSION=17 --build-arg CITUSTAG=$(CITUSTAG)
280280

Makefile.citus

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Default Citus Data version
2-
CITUSTAG ?= v13.0.0
2+
CITUSTAG ?= v13.0.1
33

44
# Citus testing
55
CITUS = 0

src/bin/pg_autoctl/cli_do_tmux_compose.c

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,6 @@ tmux_compose_add_volume(PQExpBuffer script, const char *name)
252252
static void
253253
prepare_tmux_compose_config(TmuxOptions *options, PQExpBuffer script)
254254
{
255-
/* that's optional, but we still fill it as an header of sorts */
256-
appendPQExpBuffer(script, "version: \"3.9\"\n");
257-
appendPQExpBuffer(script, "\n");
258-
259255
appendPQExpBuffer(script, "services:\n");
260256

261257
/* first, the monitor */
@@ -348,16 +344,17 @@ tmux_compose_docker_build(TmuxOptions *options)
348344

349345
log_info("docker compose build");
350346

351-
char dockerCompose[MAXPGPATH] = { 0 };
347+
char docker[MAXPGPATH] = { 0 };
352348

353-
if (!search_path_first("docker", dockerCompose, LOG_ERROR))
349+
if (!search_path_first("docker", docker, LOG_ERROR))
354350
{
355-
log_fatal("Failed to find program docker compose in PATH");
351+
log_fatal("Failed to find program docker in PATH");
356352
exit(EXIT_CODE_INTERNAL_ERROR);
357353
}
358354

359355
char pgversion[5] = { 0 };
360356
char pgversionArg[15] = { 0 };
357+
char citustagArg[20] = { 0 };
361358

362359
if (env_exists("PGVERSION"))
363360
{
@@ -373,16 +370,53 @@ tmux_compose_docker_build(TmuxOptions *options)
373370
strlcpy(pgversion, "14", sizeof(pgversion));
374371
}
375372

373+
/* prepare Postgres/Citus compatibility matrix */
374+
char *pgCitusMatrix[18] = { 0 };
375+
pgCitusMatrix[13] = "v10.2.9";
376+
pgCitusMatrix[14] = "v12.1.5";
377+
pgCitusMatrix[15] = "v12.1.5";
378+
pgCitusMatrix[16] = "v13.0.1";
379+
pgCitusMatrix[17] = "v13.0.1";
380+
381+
int pgVersionNum;
382+
char *citustag = NULL;
383+
384+
if (!stringToInt(pgversion, &pgVersionNum))
385+
{
386+
log_error("Failed to parse PGVERSION \"%s\" into an int", pgversion);
387+
exit(EXIT_CODE_INTERNAL_ERROR);
388+
}
389+
390+
if (pgVersionNum > 12 && pgVersionNum < 18)
391+
{
392+
citustag = pgCitusMatrix[pgVersionNum];
393+
}
394+
else
395+
{
396+
log_fatal("Unsupported PGVERSION=%s", pgversion);
397+
exit(EXIT_CODE_INTERNAL_ERROR);
398+
}
399+
400+
if (citustag == NULL)
401+
{
402+
log_fatal("Unknown CITUSTAG for PGVERSION=%s", pgversion);
403+
exit(EXIT_CODE_INTERNAL_ERROR);
404+
}
405+
376406
/* prepare our --build-arg PGVERSION=XX */
377407
sformat(pgversionArg, sizeof(pgversionArg), "PGVERSION=%s", pgversion);
408+
sformat(citustagArg, sizeof(citustagArg), "CITUSTAG=%s", citustag);
378409

379410
char *args[16];
380411
int argsIndex = 0;
381412

382-
args[argsIndex++] = (char *) dockerCompose;
413+
args[argsIndex++] = (char *) docker;
414+
args[argsIndex++] = "compose";
383415
args[argsIndex++] = "build";
384416
args[argsIndex++] = "--build-arg";
385417
args[argsIndex++] = (char *) pgversionArg;
418+
args[argsIndex++] = "--build-arg";
419+
args[argsIndex++] = (char *) citustagArg;
386420
args[argsIndex++] = "--quiet";
387421
args[argsIndex] = NULL;
388422

@@ -519,19 +553,19 @@ tmux_compose_rm_volume(const char *docker, const char *nodeName)
519553
static bool
520554
tmux_compose_down(TmuxOptions *options)
521555
{
522-
char dockerCompose[MAXPGPATH] = { 0 };
556+
char docker[MAXPGPATH] = { 0 };
523557

524-
if (!search_path_first("docker", dockerCompose, LOG_ERROR))
558+
if (!search_path_first("docker", docker, LOG_ERROR))
525559
{
526-
log_fatal("Failed to find program docker compose in PATH");
560+
log_fatal("Failed to find program docker in PATH");
527561
return false;
528562
}
529563

530564
/* first docker compose down */
531565
log_info("docker compose down");
532566

533567
Program program =
534-
run_program(dockerCompose, "down",
568+
run_program(docker, "compose", "down",
535569
"--volumes", "--remove-orphans", NULL);
536570

537571
if (program.returnCode != 0)
@@ -552,14 +586,6 @@ tmux_compose_down(TmuxOptions *options)
552586
/*
553587
* Now remove all the docker volumes
554588
*/
555-
char docker[MAXPGPATH] = { 0 };
556-
557-
if (!search_path_first("docker", docker, LOG_ERROR))
558-
{
559-
log_fatal("Failed to find program docker in PATH");
560-
return false;
561-
}
562-
563589
(void) tmux_compose_rm_volume(docker, "monitor");
564590

565591
for (int i = 0; i < tmuxNodeArray.count; i++)

0 commit comments

Comments
 (0)