Skip to content

Commit

Permalink
Increased Timeouts and prevent upgrade process from being disturbed b…
Browse files Browse the repository at this point in the history
…y connections during upgrade.
  • Loading branch information
expaso committed Apr 4, 2022
1 parent 83e4d0f commit 6c3fca6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README-DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
To build the lastest version using local docker, switch to the folder where the `dockerfile` resides, and run:

```
docker build --tag husselhans/hassos-addon-timescaledb-aarch64:dev .
docker build --platform linux/aarch64 --tag husselhans/hassos-addon-timescaledb-aarch64:dev .
```
The dockerfile already contains the default build architecture and the default base image:

Expand Down
2 changes: 1 addition & 1 deletion timescaledb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ RUN set -ex \

# Make sure that S6 is not so hard on our service startup/shutdown
ENV \
S6_SERVICES_GRACETIME=18000
S6_SERVICES_GRACETIME=50000

# Copy data
COPY rootfs /
Expand Down
2 changes: 1 addition & 1 deletion timescaledb/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"boot": "auto",
"init": false,
"map": ["share:rw"],
"timeout": 20,
"timeout": 60,
"ports": {
"5432/tcp": null
},
Expand Down
20 changes: 18 additions & 2 deletions timescaledb/rootfs/etc/cont-init.d/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ upgradePostgreSQL12to14 () {
# And upgrade PostgreSQL
bashio::log.notice "Upgrading PostgreSql..."

#First, start postgres on the old data-dir
# Backup old HBA.conf and create a temp one...
mv ${postgres_data}12/pg_hba.conf ${postgres_data}12/pg_hba_backup.conf
echo "local all all trust" > ${postgres_data}12/pg_hba.conf

#Start postgres on the old data-dir
bashio::log.info "Starting PostgreSQL-12 first.."
su - postgres -c "/usr/libexec/postgresql12/postgres -D ${postgres_data}12" &
postgres_pid=$!
Expand All @@ -79,7 +83,11 @@ upgradePostgreSQL12to14 () {

# Stop server
kill ${postgres_pid}
wait ${postgres_pid}
wait ${postgres_pid} || true

# Restore HBA.CONF
rm ${postgres_data}12/pg_hba.conf
mv ${postgres_data}12/pg_hba_backup.conf ${postgres_data}12/pg_hba.conf

# And upgrade!
bashio::log.notice "Upgrading databases.."
Expand Down Expand Up @@ -112,6 +120,14 @@ if bashio::var.true "${new_install}"; then
bashio::addon.version > ${version_file}
initializeDataDirectory
else

# # Check if an aborted upgrade is present.. (not working.. some users already upgraded..)
# if bashio::fs.directory_exists "${postgres_data}12"; then
# bashio::log.notice "An aborted upgrade from 12 to 14 was detected. Retrying..."
# mv ${postgres_data} ${postgres_data}_backup_2_0_1 || true
# mv ${postgres_data}12 ${postgres_data} || true
# fi

# Check if we need to upgrade from 12 to 14.
if [[ $(< ${postgres_data}/PG_VERSION) == "12" ]]; then
bashio::log.notice "A database upgrade is required from Postgres 12."
Expand Down

0 comments on commit 6c3fca6

Please sign in to comment.