-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4fed1fe
commit 85b3813
Showing
8 changed files
with
231 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
set -exu | ||
|
||
. $(dirname $0)/../commonvar.sh | ||
|
||
# Install v5 LTS to register the repository | ||
curl --fail --silent --show-error --location https://toolbelt.treasuredata.com/sh/install-${distribution}-${code_name}-fluent-package5-lts.sh | sh | ||
|
||
sudo apt purge -y fluent-package | ||
|
||
# Install the current | ||
sudo apt install -V -y \ | ||
/host/${distribution}/pool/${code_name}/${channel}/*/*/fluent-package_*_${architecture}.deb | ||
|
||
# Test: service status | ||
systemctl status --no-pager fluentd | ||
systemctl status --no-pager td-agent | ||
main_pid=$(eval $(systemctl show td-agent --property=MainPID) && echo $MainPID) | ||
|
||
# Downgrade to v5 LTS | ||
apt install -V -y fluent-package=${fluent_package_lts_version}-1 --allow-downgrades | ||
|
||
systemctl status --no-pager fluentd | ||
systemctl status --no-pager td-agent | ||
|
||
# Fluentd should be restarted. | ||
test $main_pid -ne $(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
|
||
set -exu | ||
|
||
. $(dirname $0)/../commonvar.sh | ||
|
||
|
||
# If it update from v5 LTS without stopping Fluentd, Fluentd will not be restarted. | ||
# Install v5 LTS | ||
curl --fail --silent --show-error --location https://toolbelt.treasuredata.com/sh/install-${distribution}-${code_name}-fluent-package5-lts.sh | sh | ||
|
||
systemctl status --no-pager fluentd | ||
systemctl status --no-pager td-agent | ||
main_pid=$(eval $(systemctl show td-agent --property=MainPID) && echo $MainPID) | ||
|
||
# Install the current | ||
sudo apt install -V -y \ | ||
/host/${distribution}/pool/${code_name}/${channel}/*/*/fluent-package_*_${architecture}.deb | ||
|
||
# Test: service status | ||
systemctl status --no-pager fluentd | ||
systemctl status --no-pager td-agent | ||
|
||
# Fluentd should NOT be restarted. | ||
test $main_pid -eq $(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID) | ||
|
||
apt purge -y fluent-package | ||
|
||
# If it update from v5 LTS with stopping Fluentd, Fluentd will be started when service is enabled. | ||
# Install v5 LTS | ||
curl --fail --silent --show-error --location https://toolbelt.treasuredata.com/sh/install-${distribution}-${code_name}-fluent-package5-lts.sh | sh | ||
|
||
systemctl status --no-pager fluentd | ||
systemctl status --no-pager td-agent | ||
main_pid=$(eval $(systemctl show td-agent --property=MainPID) && echo $MainPID) | ||
|
||
systemctl stop fluentd | ||
|
||
# Install the current | ||
sudo apt install -V -y \ | ||
/host/${distribution}/pool/${code_name}/${channel}/*/*/fluent-package_*_${architecture}.deb | ||
|
||
systemctl status --no-pager fluentd | ||
systemctl status --no-pager td-agent | ||
|
||
# Fluentd should be started if service was stopped before update. | ||
test $main_pid -ne $(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID) | ||
|
||
# Test: environmental variables | ||
pid=$(systemctl show fluentd --property=MainPID --value) | ||
env_vars=$(sudo sed -e 's/\x0/\n/g' /proc/$pid/environ) | ||
test $(eval $env_vars && echo $HOME) = "/var/lib/fluent" | ||
test $(eval $env_vars && echo $LOGNAME) = "_fluentd" | ||
test $(eval $env_vars && echo $USER) = "_fluentd" | ||
test $(eval $env_vars && echo $FLUENT_CONF) = "/etc/fluent/fluentd.conf" | ||
test $(eval $env_vars && echo $FLUENT_PACKAGE_LOG_FILE) = "/var/log/fluent/fluentd.log" | ||
test $(eval $env_vars && echo $FLUENT_PLUGIN) = "/etc/fluent/plugin" | ||
test $(eval $env_vars && echo $FLUENT_SOCKET) = "/var/run/fluent/fluentd.sock" | ||
|
||
# Test: No error logs | ||
# (v5 default config outputs 'warn' log, so we should check only 'error' and 'fatal' logs) | ||
sleep 3 | ||
test -e /var/log/fluent/fluentd.log | ||
(! grep -e '\[error\]' -e '\[fatal\]' /var/log/fluent/fluentd.log) | ||
|
||
# Test: Guard duplicated instance | ||
(! sudo /usr/sbin/fluentd) | ||
(! sudo /usr/sbin/fluentd -v) | ||
sudo /usr/sbin/fluentd --dry-run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
set -exu | ||
|
||
. $(dirname $0)/commonvar.sh | ||
|
||
# Install v5 LTS to register the repository | ||
case $distribution in | ||
amazon) | ||
case $version in | ||
2023) | ||
curl -fsSL https://toolbelt.treasuredata.com/sh/install-amazon2023-fluent-package5-lts.sh | sh | ||
;; | ||
2) | ||
curl -fsSL https://toolbelt.treasuredata.com/sh/install-amazon2-fluent-package5-lts.sh | sh | ||
;; | ||
esac | ||
;; | ||
*) | ||
curl -fsSL https://toolbelt.treasuredata.com/sh/install-redhat-fluent-package5-lts.sh | sh | ||
;; | ||
esac | ||
|
||
sudo $DNF remove -y fluent-package | ||
|
||
# Install the current | ||
sudo $DNF install -y \ | ||
/host/${distribution}/${DISTRIBUTION_VERSION}/x86_64/Packages/fluent-package-[0-9]*.rpm | ||
|
||
sudo systemctl enable --now fluentd | ||
systemctl status --no-pager fluentd | ||
systemctl status --no-pager td-agent | ||
main_pid=$(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID) | ||
|
||
# Downgrade to v5 LTS | ||
sudo $DNF downgrade -y fluent-package-${fluent_package_lts_version} | ||
|
||
# Test: take over enabled state | ||
systemctl is-enabled fluentd | ||
|
||
# Test: service status | ||
systemctl status --no-pager fluentd | ||
systemctl status --no-pager td-agent | ||
|
||
# Fluentd should be restarted. | ||
test $main_pid -ne $(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/bash | ||
|
||
set -exu | ||
|
||
. $(dirname $0)/commonvar.sh | ||
|
||
# If it update from v5 LTS without stopping Fluentd, Fluentd will be restarted. | ||
# Install v5 LTS | ||
case $distribution in | ||
amazon) | ||
case $version in | ||
2023) | ||
curl -fsSL https://toolbelt.treasuredata.com/sh/install-amazon2023-fluent-package5-lts.sh | sh | ||
;; | ||
2) | ||
curl -fsSL https://toolbelt.treasuredata.com/sh/install-amazon2-fluent-package5-lts.sh | sh | ||
;; | ||
esac | ||
;; | ||
*) | ||
curl -fsSL https://toolbelt.treasuredata.com/sh/install-redhat-fluent-package5-lts.sh | sh | ||
;; | ||
esac | ||
|
||
sudo systemctl enable --now fluentd | ||
systemctl status --no-pager fluentd | ||
systemctl status --no-pager td-agent | ||
main_pid=$(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID) | ||
|
||
# Install the current | ||
sudo $DNF install -y \ | ||
/host/${distribution}/${DISTRIBUTION_VERSION}/x86_64/Packages/fluent-package-[0-9]*.rpm | ||
|
||
# Test: take over enabled state | ||
systemctl is-enabled fluentd | ||
|
||
# Test: service status | ||
systemctl status --no-pager fluentd | ||
systemctl status --no-pager td-agent | ||
|
||
# Fluentd should be restarted when update from v5 LTS. | ||
test $main_pid -ne $(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID) | ||
|
||
# Test: environmental variables | ||
pid=$(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID) | ||
env_vars=$(sudo sed -e 's/\x0/\n/g' /proc/$pid/environ) | ||
test $(eval $env_vars && echo $HOME) = "/var/lib/fluent" | ||
test $(eval $env_vars && echo $LOGNAME) = "fluentd" | ||
test $(eval $env_vars && echo $USER) = "fluentd" | ||
test $(eval $env_vars && echo $FLUENT_CONF) = "/etc/fluent/fluentd.conf" | ||
test $(eval $env_vars && echo $FLUENT_PACKAGE_LOG_FILE) = "/var/log/fluent/fluentd.log" | ||
test $(eval $env_vars && echo $FLUENT_PLUGIN) = "/etc/fluent/plugin" | ||
test $(eval $env_vars && echo $FLUENT_SOCKET) = "/var/run/fluent/fluentd.sock" | ||
|
||
# Test: No error logs | ||
# (v5 default config outputs 'warn' log, so we should check only 'error' and 'fatal' logs) | ||
sleep 3 | ||
test -e /var/log/fluent/fluentd.log | ||
(! grep -e '\[error\]' -e '\[fatal\]' /var/log/fluent/fluentd.log) | ||
|
||
# Test: Guard duplicated instance | ||
(! sudo /usr/sbin/fluentd) | ||
(! sudo /usr/sbin/fluentd -v) | ||
sudo /usr/sbin/fluentd --dry-run | ||
|
||
# Uninstall | ||
sudo $DNF remove -y fluent-package | ||
sudo systemctl daemon-reload | ||
|
||
getent passwd fluentd >/dev/null | ||
getent group fluentd >/dev/null | ||
|
||
# `sudo systemctl daemon-reload` clears the service completely. | ||
# (The result of `systemctl status` will be `unfound`) | ||
# Note: RPM does not leave links like `@/etc/systemd/system/fluentd.service`. | ||
# (Different from deb) | ||
|
||
(! systemctl status --no-pager td-agent) | ||
(! systemctl status --no-pager fluentd) |