Skip to content

Commit 011426f

Browse files
fix: automatic upgrade works with 1.x containers (#557)
1 parent 06a1e02 commit 011426f

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

influxdb/2.1/alpine/entrypoint.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -331,19 +331,6 @@ function init_influxd () {
331331
sed -i "s#http://localhost:${INFLUXD_INIT_PORT}#${final_host_scheme}://localhost:${final_port}#g" "${INFLUX_CONFIGS_PATH}"
332332
}
333333

334-
# Run influxd, with optional setup logic.
335-
function influxd_main () {
336-
if [ -f "${BOLT_PATH}" ]; then
337-
log info "found existing boltdb file, skipping setup wrapper" bolt_path "${BOLT_PATH}"
338-
elif [ -z "${DOCKER_INFLUXDB_INIT_MODE}" ]; then
339-
log warn "boltdb not found at configured path, but DOCKER_INFLUXDB_INIT_MODE not specified, skipping setup wrapper" bolt_path "${bolt_path}"
340-
else
341-
init_influxd "${@}"
342-
fi
343-
344-
exec influxd "${@}"
345-
}
346-
347334
# Check if the --help or -h flag is set in a list of CLI args.
348335
function check_help_flag () {
349336
for arg in "${@}"; do
@@ -386,12 +373,25 @@ function main () {
386373
create_directories
387374
fi
388375

376+
if [ -f "${BOLT_PATH}" ]; then
377+
log info "found existing boltdb file, skipping setup wrapper" bolt_path "${BOLT_PATH}"
378+
elif [ -z "${DOCKER_INFLUXDB_INIT_MODE}" ]; then
379+
log warn "boltdb not found at configured path, but DOCKER_INFLUXDB_INIT_MODE not specified, skipping setup wrapper" bolt_path "${bolt_path}"
380+
else
381+
init_influxd "${@}"
382+
# Set correct permission on volume directories again. This is necessary so that if the container was run as the
383+
# root user, the files from the automatic upgrade/initialization will be correctly set when stepping down to the
384+
# influxdb user.
385+
create_directories
386+
fi
387+
389388
if [ "$(id -u)" = 0 ]; then
390389
exec gosu influxdb "$BASH_SOURCE" "${@}"
391390
return
392391
fi
393392

394-
influxd_main "${@}"
393+
# Run influxd.
394+
exec influxd "${@}"
395395
}
396396

397397
main "${@}"

influxdb/2.1/entrypoint.sh

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -331,19 +331,6 @@ function init_influxd () {
331331
sed -i "s#http://localhost:${INFLUXD_INIT_PORT}#${final_host_scheme}://localhost:${final_port}#g" "${INFLUX_CONFIGS_PATH}"
332332
}
333333

334-
# Run influxd, with optional setup logic.
335-
function influxd_main () {
336-
if [ -f "${BOLT_PATH}" ]; then
337-
log info "found existing boltdb file, skipping setup wrapper" bolt_path "${BOLT_PATH}"
338-
elif [ -z "${DOCKER_INFLUXDB_INIT_MODE}" ]; then
339-
log warn "boltdb not found at configured path, but DOCKER_INFLUXDB_INIT_MODE not specified, skipping setup wrapper" bolt_path "${bolt_path}"
340-
else
341-
init_influxd "${@}"
342-
fi
343-
344-
exec influxd "${@}"
345-
}
346-
347334
# Check if the --help or -h flag is set in a list of CLI args.
348335
function check_help_flag () {
349336
for arg in "${@}"; do
@@ -376,7 +363,6 @@ function main () {
376363
shift 1
377364
fi
378365

379-
380366
if ! check_help_flag "${@}"; then
381367
# Configure logging for our wrapper.
382368
set_global_log_level "${@}"
@@ -386,12 +372,25 @@ function main () {
386372
create_directories
387373
fi
388374

375+
if [ -f "${BOLT_PATH}" ]; then
376+
log info "found existing boltdb file, skipping setup wrapper" bolt_path "${BOLT_PATH}"
377+
elif [ -z "${DOCKER_INFLUXDB_INIT_MODE}" ]; then
378+
log warn "boltdb not found at configured path, but DOCKER_INFLUXDB_INIT_MODE not specified, skipping setup wrapper" bolt_path "${bolt_path}"
379+
else
380+
init_influxd "${@}"
381+
# Set correct permission on volume directories again. This is necessary so that if the container was run as the
382+
# root user, the files from the automatic upgrade/initialization will be correctly set when stepping down to the
383+
# influxdb user.
384+
create_directories
385+
fi
386+
389387
if [ "$(id -u)" = 0 ]; then
390388
exec gosu influxdb "$BASH_SOURCE" "${@}"
391389
return
392390
fi
393391

394-
influxd_main "${@}"
392+
# Run influxd.
393+
exec influxd "${@}"
395394
}
396395

397396
main "${@}"

0 commit comments

Comments
 (0)