Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ workspace = true
name = "vector"
section = "admin"
maintainer-scripts = "distribution/debian/scripts/"
conf-files = ["/etc/default/vector"]
conf-files = ["/etc/default/vector", "/etc/vector/vector.yaml"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid conffile prompts on upgrades

For Debian users who installed a version where /etc/vector/vector.yaml was not package-owned and then created that file themselves, adding the same path as a new dpkg conffile makes dpkg -i stop at the “File on system created by you” conffile prompt; without explicit --force-confold/confnew options, unattended apt/dpkg upgrades fail before the package is configured. The new verify path only reinstalls this same package, so it misses the transition from an unowned user config to a packaged conffile; please add a maintainer-script transition or another approach that preserves the existing file without prompting.

Useful? React with 👍 / 👎.

assets = [
["target/release/vector", "/usr/bin/", "755"],
["distribution/debian/vector.yaml", "/etc/vector/vector.yaml", "644"],
["config/vector.yaml", "/usr/share/vector/examples/vector.yaml", "644"],
["config/examples/*", "/etc/vector/examples/", "644"],
["config/examples/*", "/usr/share/doc/vector/examples/", "644"],
Comment thread
thomasqueirozb marked this conversation as resolved.
["distribution/systemd/vector.service", "/lib/systemd/system/vector.service", "644"],
["distribution/systemd/vector.default", "/etc/default/vector", "600"],
["licenses/*", "/usr/share/vector/licenses/", "644"],
Expand Down
4 changes: 4 additions & 0 deletions changelog.d/deb-conffile-examples-location.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fixed two Debian packaging issues: `/etc/vector/vector.yaml` is now shipped as a proper Debian conffile (a stub with no active sources/sinks) so local modifications are preserved across upgrades; example configurations have been moved from `/etc/vector/examples/` to `/usr/share/doc/vector/examples/` where they belong as documentation rather than administrator-managed configuration.

Since `/etc/vector/vector.yaml` was not previously a dpkg conffile, a pre-existing file at that path (created by a user, or by a Vector version prior to this fix) would otherwise make `dpkg` stop with an interactive "file created by you" conffile prompt, breaking unattended upgrades. Maintainer scripts now move any such untracked file aside before install and restore it afterwards, so upgrades complete without prompting and existing content is preserved byte-for-byte.
authors: koenserry
31 changes: 31 additions & 0 deletions distribution/debian/scripts/postinst
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
#!/bin/sh
set -e

# Complete the rm_conffile transition started in preinst; see preinst for context.
for _example_conffile in \
docs_example.yaml \
environment_variables.yaml \
es_s3_hybrid.yaml \
file_to_cloudwatch_metrics.yaml \
file_to_prometheus.yaml \
http_sink_custom_retry.yaml \
prometheus_to_console.yaml \
stdio.yaml \
varint_framing_protobuf.yaml \
wrapped_json.yaml \
namespacing/sinks/es_cluster.yaml \
namespacing/sinks/s3_archives.yaml \
namespacing/sources/apache_logs.yaml \
namespacing/transforms/apache_parser.yaml \
namespacing/transforms/apache_sample.yaml \
namespacing/vector.yaml
do
dpkg-maintscript-helper rm_conffile \
"/etc/vector/examples/$_example_conffile" 0.57.0-1 vector -- "$@"
done

# Restore a pre-existing /etc/vector/vector.yaml that preinst moved aside
# (see preinst for why). This puts the user's original content back in
# place of the stub conffile dpkg just unpacked, so nothing is lost and no
# conffile prompt was ever shown.
if [ -e /etc/vector/vector.yaml.vector-preserve ]; then
mv -f /etc/vector/vector.yaml.vector-preserve /etc/vector/vector.yaml
Comment on lines +31 to +32

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore preserved config on aborted installs

Because the only restore of .vector-preserve is in postinst configure, an install/upgrade that reaches the preinst move and then aborts during unpack before postinst runs leaves the user's active /etc/vector/vector.yaml displaced as /etc/vector/vector.yaml.vector-preserve while the package is not configured. Add an abort-install/abort-upgrade cleanup path, such as a postrm handler, so failed upgrades do not leave Vector without its original config at the default path.

Useful? React with 👍 / 👎.

fi

# Add Vector to adm group to read /var/logs
usermod --append --groups adm vector || true

Expand Down
41 changes: 41 additions & 0 deletions distribution/debian/scripts/preinst
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
#!/bin/sh
set -e

# /etc/vector/examples/*.yaml were conffiles through v0.57.0; they moved to
# /usr/share/doc/vector/examples/. Remove unmodified copies on upgrade.
for _example_conffile in \
docs_example.yaml \
environment_variables.yaml \
es_s3_hybrid.yaml \
file_to_cloudwatch_metrics.yaml \
file_to_prometheus.yaml \
http_sink_custom_retry.yaml \
prometheus_to_console.yaml \
stdio.yaml \
varint_framing_protobuf.yaml \
wrapped_json.yaml \
namespacing/sinks/es_cluster.yaml \
namespacing/sinks/s3_archives.yaml \
namespacing/sources/apache_logs.yaml \
namespacing/transforms/apache_parser.yaml \
namespacing/transforms/apache_sample.yaml \
namespacing/vector.yaml
do
dpkg-maintscript-helper rm_conffile \
"/etc/vector/examples/$_example_conffile" 0.57.0-1 vector -- "$@"
Comment on lines +24 to +25

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add the postrm half of rm_conffile

Although this adds the rm_conffile calls to preinst/postinst, I checked dpkg-maintscript-helper --help and it states that rm_conffile must be called in preinst, postinst, and postrm. Without a matching postrm call, an upgrade from a version that owned /etc/vector/examples/*.yaml can run preinst and move old examples to .dpkg-remove/.dpkg-backup, then if the upgrade aborts before postinst the abort path never restores them; purges also leave helper backup files behind. Please add the corresponding postrm transition for the same file list.

Useful? React with 👍 / 👎.

done

# Add vector:vector user & group
id --user vector >/dev/null 2>&1 || \
useradd --system --shell /sbin/nologin --home-dir /var/lib/vector --user-group \
Expand All @@ -12,4 +36,21 @@ mkdir -p /var/lib/vector
# Make vector:vector the owner of the Vector data directory
chown -R vector:vector /var/lib/vector

# /etc/vector/vector.yaml was not a dpkg conffile before this version. If a
# file already exists at that path, dpkg has no record of it and will treat
# it as "created by you", prompting interactively (or failing outright on
# unattended upgrades) before it will unpack the new conffile over it. Move
# any such untracked file out of the way so dpkg can install the conffile
# cleanly; postinst restores it afterwards so the user's content is kept
# byte-for-byte, without ever prompting.
case "$1" in
install|upgrade)
if [ -e /etc/vector/vector.yaml ] && [ ! -L /etc/vector/vector.yaml ]; then
if ! dpkg-query -W -f='${Conffiles}' vector 2>/dev/null | grep -qE ' /etc/vector/vector\.yaml [0-9a-f]'; then
mv /etc/vector/vector.yaml /etc/vector/vector.yaml.vector-preserve

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Don't move files owned by another package

If /etc/vector/vector.yaml is provided by a local configuration package or any other Debian package while vector is not installed, this mv runs before dpkg's file-conflict check and hides the other package's file; I verified with dummy packages that dpkg still aborts on the ownership conflict after preinst, leaving only vector.yaml.vector-preserve and no file at the path owned by the other package. Please check package ownership (not only Vector's conffile list) before moving the file aside.

Useful? React with 👍 / 👎.

fi
fi
;;
esac

#DEBHELPER#
41 changes: 41 additions & 0 deletions distribution/debian/vector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# __ __ __
# \ \ / / / /
# \ V / / /
# \_/ \/
#
# V E C T O R
# Configuration
#
# ------------------------------------------------------------------------------
# Website: https://vector.dev
# Docs: https://vector.dev/docs
# Chat: https://chat.vector.dev
# ------------------------------------------------------------------------------

# Change this to use a non-default directory for Vector data storage:
# data_dir: "/var/lib/vector"

# Example configurations are available at /usr/share/doc/vector/examples/

# Add your sources, transforms, and sinks here.
# See https://vector.dev/docs/reference/configuration/ for full reference.

# sources:
# my_source:
# type: "..."

# transforms:
# my_transform:
# type: "..."
# inputs: ["my_source"]

# sinks:
# my_sink:
# type: "..."
# inputs: ["my_transform"]

# Vector's API (disabled by default)
# Uncomment to try it out with the `vector top` command
# api:
# enabled: true
# address: "127.0.0.1:8686"
31 changes: 29 additions & 2 deletions scripts/verify-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,43 @@ install_package () {
esac
}

case "$package" in
*.deb)
# Simulate a pre-existing /etc/vector/vector.yaml that predates this file
# being a dpkg conffile (e.g. a user-created file from before this fix, or
# an earlier Vector version that didn't ship one at all). Installing over
# it must not prompt (dpkg has no tty here, so a prompt would hang/fail
# this script) and must leave the user's content untouched.
mkdir -p /etc/vector
echo "unmanaged: pre-existing-config" > /etc/vector/vector.yaml
;;
esac

install_package "$package"

case "$package" in
*.deb)
grep -q "unmanaged: pre-existing-config" /etc/vector/vector.yaml || \
(echo "pre-existing, dpkg-untracked /etc/vector/vector.yaml was not preserved on install" && exit 1)
;;
esac

getent passwd vector || (echo "vector user missing" && exit 1)
getent group vector || (echo "vector group missing" && exit 1)
vector --version || (echo "vector --version failed" && exit 1)
test -f /etc/default/vector || (echo "/etc/default/vector doesn't exist" && exit 1)
test ! -e /etc/vector/vector.yaml || (echo "/etc/vector/vector.yaml should not be installed by default" && exit 1)
test -f /usr/share/vector/examples/vector.yaml || (echo "/usr/share/vector/examples/vector.yaml doesn't exist" && exit 1)
case "$package" in
*.deb)
test -f /etc/vector/vector.yaml || (echo "/etc/vector/vector.yaml should be installed by default" && exit 1)
test ! -d /etc/vector/examples || (echo "examples should not be installed under /etc/vector/examples" && exit 1)
test -f /usr/share/doc/vector/examples/stdio.yaml || (echo "/usr/share/doc/vector/examples/ examples missing" && exit 1)
;;
*.rpm)
test ! -e /etc/vector/vector.yaml || (echo "/etc/vector/vector.yaml should not be installed by default" && exit 1)
;;
esac

mkdir -p /etc/vector
echo "FOO=bar" > /etc/default/vector
echo "foo: bar" > /etc/vector/vector.yaml

Expand Down
Loading