Skip to content

Commit

Permalink
fix: Improve v2 packaging (#20329)
Browse files Browse the repository at this point in the history

Co-authored-by: Phillip Steinbachs <phil@steinbachs.org>
  • Loading branch information
danxmoran and psteinbachs authored Dec 14, 2020
1 parent 0b81731 commit c86020f
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 28 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This release includes our initial ARM64 "preview" build.

### Breaking Changes

#### influxd upgrade
Previously, `influxd upgrade` would attempt to write upgraded `config.toml` files into the same directory as the source
`influxdb.conf` file. If this failed, a warning would be logged and `config.toml` would be written into the `HOME` directory.

Expand All @@ -17,6 +18,11 @@ This release breaks this behavior in two ways:
Users can use the new `--v2-config-path` option to override the output path for upgraded config if they can't or don't
want to use the default.

#### v2 packaging
Based on community feedback, the v2 deb and rpm packaging has been improved to avoid confusion between versions. The package
name is now influxdb2 and conflicts with any previous influxdb package (including initial 2.0.0, 2.0.1, and 2.0.2 packages).
Additionally, v2 specific path defaults are now defined and helper scripts are provided for `influxd upgrade` and cleanup cases.

### Features

1. [20128](https://github.com/influxdata/influxdb/pull/20128): Allow password to be specified as a CLI option in `influx v1 auth create`.
Expand All @@ -39,6 +45,7 @@ want to use the default.
1. [20202](https://github.com/influxdata/influxdb/pull/20202): Optimize shard lookup in groups containing only one shard. Thanks @StoneYunZhao!
1. [20235](https://github.com/influxdata/influxdb/pull/20235): Respect the `--name` option in `influx setup` whether configs already exist or not.
1. [20235](https://github.com/influxdata/influxdb/pull/20235): Allow for 0 (infinite) values for `--retention` in `influx setup`.
1. [20329](https://github.com/influxdata/influxdb/pull/20329): Set v2 default paths and provide upgrade helper scripts in release packages.

## v2.0.2 [2020-11-18]
----------------------
Expand Down Expand Up @@ -137,7 +144,7 @@ want to use the default.
1. [19819](https://github.com/influxdata/influxdb/pull/19819): Isolate telegraf config service and remove URM interactions
1. [19853](https://github.com/influxdata/influxdb/pull/19853): Use updated HTTP client for authorization service
1. [19856](https://github.com/influxdata/influxdb/pull/19856): Make tagKeys and tagValues work for edge cases involving fields
1. [19870](https://github.com/influxdata/influxdb/pull/19870): Correctly parse float as 64-bits
1. [19870](https://github.com/influxdata/influxdb/pull/19870): Correctly parse float as 64-bits
1. [19873](https://github.com/influxdata/influxdb/pull/19873): Add simple metrics related to installed templates
1. [19885](https://github.com/influxdata/influxdb/pull/19885): Remove extra multiplication of retention policies in onboarding
1. [19887](https://github.com/influxdata/influxdb/pull/19887): Use fluxinit package to init flux library instead of builtin
Expand Down
2 changes: 1 addition & 1 deletion scripts/influxdb.service
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ After=network-online.target
User=influxdb
Group=influxdb
LimitNOFILE=65536
EnvironmentFile=-/etc/default/influxdb
EnvironmentFile=-/etc/default/influxdb2
ExecStart=/usr/bin/influxd
KillMode=control-group
Restart=on-failure
Expand Down
83 changes: 83 additions & 0 deletions scripts/influxdb2-upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash

# Environment defaults
INFLUXD_CONFIG_PATH=/etc/influxdb/config.toml
INFLUXD_BOLT_PATH=/var/lib/influxdb/influxd.bolt
INFLUXD_ENGINE_PATH=/var/lib/influxdb/engine

export INFLUXD_CONFIG_PATH INFLUXD_BOLT_PATH INFLUXD_ENGINE_PATH

# Check upgrade status
bolt_dir="/root/.influxdbv2 /var/lib/influxdb/.influxdbv2 /var/lib/influxdb"
for bolt in $bolt_dir
do
if [[ -s ${bolt}/influxd.bolt ]]; then
echo "An existing ${bolt}/influxd.bolt file was found indicating InfluxDB is"
echo "already upgraded to v2. Exiting."
exit 1
fi
done

# Perform upgrade
sudo /usr/bin/influxd upgrade \
--config-file=/etc/influxdb/influxdb.conf \
--log-path=/var/log/influxdb/upgrade.log \
--continuous-query-export-path=/var/lib/influxdb/continuous_queries.txt \
--v2-config-path=${INFLUXD_CONFIG_PATH} \
-m $INFLUXD_BOLT_PATH -e $INFLUXD_ENGINE_PATH

if [[ $? -eq 0 ]]; then

cat << EOF
The upgrade completed successfully. Execute the following to start InfluxDB:
sudo systemctl start influxdb
A complete copy of v1 data was created as part of the upgrade process.
After confirming v2 is functioning as intended, removal of v1 data can be
performed by executing:
sudo /var/tmp/influxdbv1-remove.sh
NOTE: This script will erase all previous v1 data and config files!
EOF

cat << EOF > /var/tmp/influxdbv1-remove.sh
#!/bin/bash
sudo rm -f /etc/influxdb/influxdb.conf
sudo rm -rf /var/lib/influxdb/data
sudo rm -rf /var/lib/influxdb/wal
sudo rm -rf /var/lib/influxdb/meta
EOF
sudo chmod +x /var/tmp/influxdbv1-remove.sh

sudo cp /root/.influxdbv2/configs /var/lib/influxdb
sudo chown influxdb:influxdb /var/lib/influxdb/influxd.bolt /var/lib/influxdb/configs
sudo chown -R influxdb:influxdb /var/lib/influxdb/engine

else

cat << EOF
The upgrade encountered an error. Please review the
/var/log/influxdb/upgrade.log file for more information. Before attempting
another upgrade, removal of v2 data should be performed by executing:
sudo /var/tmp/influxdbv2-remove.sh
NOTE: This script will erase all previous v2 data and config files!
EOF

cat << EOF > /var/tmp/influxdbv2-remove.sh
#!/bin/bash
sudo rm -f /etc/influxdb/config.toml /var/lib/influxdb/influxd.bolt
sudo rm -f /var/lib/influxdb/configs /root/.influxdbv2/configs
sudo rm -f /var/lib/influxdb/continuous_queries.txt
sudo rm -rf /var/lib/influxdb/engine
EOF
sudo chmod +x /var/tmp/influxdbv2-remove.sh

fi
70 changes: 44 additions & 26 deletions scripts/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ DATA_DIR=/var/lib/influxdb
LOG_DIR=/var/log/influxdb
SCRIPT_DIR=/usr/lib/influxdb/scripts
LOGROTATE_DIR=/etc/logrotate.d
INFLUXD_CONFIG_PATH=/etc/influxdb/config.toml

function install_init {
cp -f $SCRIPT_DIR/init.sh /etc/init.d/influxdb
Expand All @@ -24,9 +25,39 @@ function install_chkconfig {
chkconfig --add influxdb
}

function upgrade_notice {
cat << EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Important 1.x to 2.x Upgrade Notice !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Thank you for installing InfluxDB v2. Due to significant changes between
the v1 and v2 versions, upgrading to v2 requires additional steps. If
upgrading to v2 was not intended, simply re-install the v1 package now.
An upgrade helper script is available that should be reviewed and executed
prior to starting the influxdb systemd service. In order to start the v2
upgrade, execute the following:
sudo /usr/share/influxdb/influxdb2-upgrade.sh
Visit our website for complete details on the v1 to v2 upgrade process:
https://docs.influxdata.com/influxdb/v2.0/upgrade/v1-to-v2/
For new or upgrade installations, please review the getting started guide:
https://docs.influxdata.com/influxdb/v2.0/get-started/
EOF
}

# Add defaults file, if it doesn't exist
if [[ ! -f /etc/default/influxdb ]]; then
touch /etc/default/influxdb
if [[ ! -s /etc/default/influxdb2 ]]; then
cat << EOF > /etc/default/influxdb2
INFLUXD_CONFIG_PATH=/etc/influxdb/config.toml
INFLUXD_BOLT_PATH=/var/lib/influxdb/influxd.bolt
INFLUXD_ENGINE_PATH=/var/lib/influxdb/engine
EOF
fi

# Remove legacy symlink, if it exists
Expand Down Expand Up @@ -73,27 +104,14 @@ elif [[ -f /etc/os-release ]]; then
fi
fi

# Upgrade notice
cat << EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Important 1.x to 2.x Upgrade Notice !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Thank you for installing InfluxDB v2. Due to significant changes between
the v1 and v2 versions, upgrading to v2 requires additional steps. If
upgrading to v2 was not intended, please simply re-install the v1 package now.
Please review the complete upgrade procedure:
https://docs.influxdata.com/influxdb/v2.0/upgrade/v1-to-v2/
Minimally, the following steps will be necessary:
* Make a copy of all underlying v1 data (typically under /var/lib/influxdb)
* Run the 'influxd upgrade' command
* Follow the prompts to complete the upgrade process
For new or upgrade installations, please also review the getting started guide:
https://docs.influxdata.com/influxdb/v2.0/get-started/
EOF
# Check upgrade status
bolt_dir="/root/.influxdbv2 /var/lib/influxdb/.influxdbv2 /var/lib/influxdb"
for bolt in $bolt_dir
do
if [[ -s ${bolt}/influxd.bolt ]]; then
# Found a bolt file, assume previous v2 upgrade
exit 0
fi
done

upgrade_notice

0 comments on commit c86020f

Please sign in to comment.