From 6428b3985f961ec82fac13a34a1a4f315442fa4c Mon Sep 17 00:00:00 2001 From: Miki Bonacci Date: Wed, 3 Jul 2024 22:58:37 +0200 Subject: [PATCH 1/8] Updating the *before_notebook* 20_ and 40_ files. Fixings are done as for arm64 I encountered the issues in restarting the container. 1- Deleting old ${PSQL_LOGFILE}.1.gz file before trying to compressed again. Otherwise, this can give errors and so the container will exit with non-zero status. 2- Clean stop of the daemon before the "verdi storage migrate --force" in `40_prepare_aiida.sh`. This is done because sometimes the restart of the docker container will give error in trying to migrate, as the daemon is still running. I am not able to reproduce the error in a standard way, however. --- .../before-notebook.d/20_start-postgresql.sh | 6 +++++- stack/base/before-notebook.d/40_prepare-aiida.sh | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh index bed884b4..12e263e2 100644 --- a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh +++ b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh @@ -22,7 +22,11 @@ else chmod -R g-rwxs "${PGDATA}" if [[ -f ${PGDATA}/logfile ]]; then - mv "${PSQL_LOGFILE}" "${PSQL_LOGFILE}.1" && gzip "${PSQL_LOGFILE}.1" + if [[ -f ${PSQL_LOGFILE}.1.gz ]]; then + echo "Deleting old ${PSQL_LOGFILE}.1.gz compressed file" + rm "${PSQL_LOGFILE}.1.gz" + fi + mv "${PSQL_LOGFILE}" "${PSQL_LOGFILE}.1" && gzip "${PSQL_LOGFILE}.1" fi # Cleaning up the mess if PostgreSQL was not shutdown properly. rm -vf "${PGDATA}/postmaster.pid" diff --git a/stack/base/before-notebook.d/40_prepare-aiida.sh b/stack/base/before-notebook.d/40_prepare-aiida.sh index bb6adca0..1ba2922b 100755 --- a/stack/base/before-notebook.d/40_prepare-aiida.sh +++ b/stack/base/before-notebook.d/40_prepare-aiida.sh @@ -74,6 +74,8 @@ load_computer('${computer_name}').set_minimum_job_poll_interval(${job_poll_inter else # Migration will run for the default profile. + ## We need to stop the daemon before. + verdi daemon stop verdi storage migrate --force fi From 9bb923455efb0863d2350fc9b0a681c0f47370bb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2024 21:15:32 +0000 Subject: [PATCH 2/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- stack/base/before-notebook.d/40_prepare-aiida.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack/base/before-notebook.d/40_prepare-aiida.sh b/stack/base/before-notebook.d/40_prepare-aiida.sh index 1ba2922b..160ae89c 100755 --- a/stack/base/before-notebook.d/40_prepare-aiida.sh +++ b/stack/base/before-notebook.d/40_prepare-aiida.sh @@ -74,7 +74,7 @@ load_computer('${computer_name}').set_minimum_job_poll_interval(${job_poll_inter else # Migration will run for the default profile. - ## We need to stop the daemon before. + ## We need to stop the daemon before. verdi daemon stop verdi storage migrate --force From 604d0e6a4766c009576289016e9dfb6e0949b51d Mon Sep 17 00:00:00 2001 From: Miki Bonacci <46074008+mikibonacci@users.noreply.github.com> Date: Thu, 4 Jul 2024 00:06:53 +0200 Subject: [PATCH 3/8] Update stack/base-with-services/before-notebook.d/20_start-postgresql.sh Co-authored-by: Daniel Hollas --- .../before-notebook.d/20_start-postgresql.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh index 12e263e2..9272d613 100644 --- a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh +++ b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh @@ -22,10 +22,7 @@ else chmod -R g-rwxs "${PGDATA}" if [[ -f ${PGDATA}/logfile ]]; then - if [[ -f ${PSQL_LOGFILE}.1.gz ]]; then - echo "Deleting old ${PSQL_LOGFILE}.1.gz compressed file" - rm "${PSQL_LOGFILE}.1.gz" - fi + rm -f "${PSQL_LOGFILE}.1.gz" mv "${PSQL_LOGFILE}" "${PSQL_LOGFILE}.1" && gzip "${PSQL_LOGFILE}.1" fi # Cleaning up the mess if PostgreSQL was not shutdown properly. From 23c6120a930d47bf0370879c5f1fb4a3e0797c05 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2024 22:06:58 +0000 Subject: [PATCH 4/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../base-with-services/before-notebook.d/20_start-postgresql.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh index 9272d613..57292fb0 100644 --- a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh +++ b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh @@ -22,7 +22,7 @@ else chmod -R g-rwxs "${PGDATA}" if [[ -f ${PGDATA}/logfile ]]; then - rm -f "${PSQL_LOGFILE}.1.gz" + rm -f "${PSQL_LOGFILE}.1.gz" mv "${PSQL_LOGFILE}" "${PSQL_LOGFILE}.1" && gzip "${PSQL_LOGFILE}.1" fi # Cleaning up the mess if PostgreSQL was not shutdown properly. From 8be6bf6b42df6d1d2e93943dc68b2a563dcd4ed8 Mon Sep 17 00:00:00 2001 From: Miki Bonacci Date: Thu, 4 Jul 2024 10:05:15 +0200 Subject: [PATCH 5/8] Clean up stale PID-files before `verdi migrate --force` in `40_prepare-aiida.sh` This is faster than `verdi daemon stop`. We suppose that the daemon is not running when we start/restart the container. --- stack/base/before-notebook.d/40_prepare-aiida.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stack/base/before-notebook.d/40_prepare-aiida.sh b/stack/base/before-notebook.d/40_prepare-aiida.sh index 160ae89c..ee9b165b 100755 --- a/stack/base/before-notebook.d/40_prepare-aiida.sh +++ b/stack/base/before-notebook.d/40_prepare-aiida.sh @@ -74,8 +74,8 @@ load_computer('${computer_name}').set_minimum_job_poll_interval(${job_poll_inter else # Migration will run for the default profile. - ## We need to stop the daemon before. - verdi daemon stop + ## clean up stale PID-files -> .aiida/daemon/circus-{profile-name}.pid + rm -f "/home/${NB_USER}/.aiida/daemon/circus-${AIIDA_PROFILE_NAME}.pid" verdi storage migrate --force fi From 75e68110d5a58a4ebdf170eba8c0dcebcabe6929 Mon Sep 17 00:00:00 2001 From: Miki Bonacci <46074008+mikibonacci@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:01:23 +0200 Subject: [PATCH 6/8] Update stack/base/before-notebook.d/40_prepare-aiida.sh Co-authored-by: Daniel Hollas --- stack/base/before-notebook.d/40_prepare-aiida.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack/base/before-notebook.d/40_prepare-aiida.sh b/stack/base/before-notebook.d/40_prepare-aiida.sh index ee9b165b..b3cb46df 100755 --- a/stack/base/before-notebook.d/40_prepare-aiida.sh +++ b/stack/base/before-notebook.d/40_prepare-aiida.sh @@ -75,7 +75,7 @@ else # Migration will run for the default profile. ## clean up stale PID-files -> .aiida/daemon/circus-{profile-name}.pid - rm -f "/home/${NB_USER}/.aiida/daemon/circus-${AIIDA_PROFILE_NAME}.pid" + rm -f "/home/${NB_USER}/.aiida/daemon/circus-*.pid" verdi storage migrate --force fi From 201ba780cc72f83f3b459509e54fd07b449548f9 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Thu, 4 Jul 2024 13:43:03 +0100 Subject: [PATCH 7/8] pgrep verdi daemon --- stack/base/before-notebook.d/40_prepare-aiida.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/stack/base/before-notebook.d/40_prepare-aiida.sh b/stack/base/before-notebook.d/40_prepare-aiida.sh index b3cb46df..1138903a 100755 --- a/stack/base/before-notebook.d/40_prepare-aiida.sh +++ b/stack/base/before-notebook.d/40_prepare-aiida.sh @@ -74,6 +74,7 @@ load_computer('${computer_name}').set_minimum_job_poll_interval(${job_poll_inter else # Migration will run for the default profile. + pgrep -af 'verdi.* daemon' && echo "ERROR: AiiDA daemon is already running!" && exit 1 ## clean up stale PID-files -> .aiida/daemon/circus-{profile-name}.pid rm -f "/home/${NB_USER}/.aiida/daemon/circus-*.pid" verdi storage migrate --force From 25e937b6dd112444fadfe84d0dcfc12a87646242 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Thu, 4 Jul 2024 16:09:50 +0100 Subject: [PATCH 8/8] Fix rm command --- stack/base/before-notebook.d/40_prepare-aiida.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack/base/before-notebook.d/40_prepare-aiida.sh b/stack/base/before-notebook.d/40_prepare-aiida.sh index 1138903a..d3d97643 100755 --- a/stack/base/before-notebook.d/40_prepare-aiida.sh +++ b/stack/base/before-notebook.d/40_prepare-aiida.sh @@ -76,7 +76,7 @@ else # Migration will run for the default profile. pgrep -af 'verdi.* daemon' && echo "ERROR: AiiDA daemon is already running!" && exit 1 ## clean up stale PID-files -> .aiida/daemon/circus-{profile-name}.pid - rm -f "/home/${NB_USER}/.aiida/daemon/circus-*.pid" + rm -f /home/${NB_USER}/.aiida/daemon/circus-*.pid verdi storage migrate --force fi