-
Notifications
You must be signed in to change notification settings - Fork 45
feat(updater): Support user configured systemd working directory / collector home #2530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(updater): Support user configured systemd working directory / collector home #2530
Conversation
ff04014 to
f5f9af7
Compare
| // We can't create the zap logger yet, because we don't know the install dir, which is needed | ||
| // to create the logger. So we pass a Nop logger here. | ||
| installDir, err := path.InstallDir(zap.NewNop()) | ||
| installDir, err := path.InstallDir(zap.NewNop(), path.DefaultConfigOverrides) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path.InstallDir takes a list of package overrides. On Linux this will be /etc/default/observiq-otel-collector and /etc/sysconfig/observiq-otel-collector. On Windows and Darwin, this option is ignored.
updater/internal/path/path_linux.go
Outdated
| if len(parts) == 2 { | ||
| value := strings.TrimSpace(parts[1]) | ||
| if value != "" { | ||
| return value, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InstallDir returns the value for BDOT_CONFIG_HOME right away. We do not expect users to configure both /etc/default/observiq-otel-collector (debian) and /etc/sysconfig/observiq-otel-collector (rhel). This function will read the one that exists and return the value if it is found.
updater/internal/path/path_linux.go
Outdated
| } | ||
| } | ||
|
|
||
| return DeafultLinuxInstallDir, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the files do not exist, continue using /opt/observiq-otel-collector.
f5f9af7 to
9e372a0
Compare
9b35715 to
b6596a8
Compare
b6596a8 to
79d7d5f
Compare
| // InstallDir returns the filepath to the install directory | ||
| func InstallDir(_ *zap.Logger) (string, error) { | ||
| return LinuxInstallDir, nil | ||
| func InstallDir(logger *zap.Logger, configOverrides []string) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is used by the collector service to determine where it is installed. Returns /opt/observiq-otel-collector unless an override is detected.
This function is also used by the updater to determine which install dir to slip into the generated systemd service file.
9c93bc5 to
d81ad0c
Compare
…llector home (#2530) * feat(updater): Support user configured working directory and collector home in systemd service * Use path.InstallDir instead of parsing installed systemd unit file. * only generate service files when Linux
…llector home (#2530) * feat(updater): Support user configured working directory and collector home in systemd service * Use path.InstallDir instead of parsing installed systemd unit file. * only generate service files when Linux
Proposed Change
We support a user configured install dir. See
scripts/package/postinstall.sh. This is a follow up change to support the user configured directory when using the updater.Updated the updater's systemd service file template to include a
.InstallDirvariable. The value used is extracted from the installed systemd service file. This follows the pattern established when detecting the runtimegroup.Testing
Working great when the install dir is not configured.
I tested an install dir override by setting
BDOT_CONFIG_HOME=/opt/collectorand then building this branch with two tags:The builds were identical, and allowed me to test upgrading with the new logic. We cannot upgrade from the latest release because it will fail to execute the updater binary, due to the
/opt/observiq-otel-collectorpath being hardcoded inupdater/internal/path/. This is okay because we will not support linux package customization for existing installs, only new installs.Checklist