Skip to content
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

[teleport-update] Support for CentOS 7 #52951

Merged
merged 7 commits into from
Mar 12, 2025
Merged

Conversation

sclevine
Copy link
Member

@sclevine sclevine commented Mar 11, 2025

The teleport-update binary uses systemctl commands that are not supported on CentOS 7. Although CentOS 7 is EOL and no longer receiving security patches as of June 2024, Teleport v17 is currently documented to support it.

These commands include list-unit-files, is-enabled, and the --now flag.

This PR avoids executing those commands when systemd is too old to support them. Edit: due to backports of the most of the functionality above, the last published version of CentOS 7 is fully-functional aside from a few missing warnings. I still plan to merge this PR to protect against unexpected behavior on Linux distros with older versions of systemd.

Additionally, this PR simplifies the uninstallation workflow by allowing a stopped but enabled teleport systemd service to be removed. This behavior is more logical, and avoids is-enabled.


changelog: Improve support for teleport-update on CentOS 7 and distros with older SystemD versions.


The teleport-update binary will be used to enable, disable, and trigger automatic Teleport agent updates. The new auto-updates system manages a local installation of the cluster-specified version of Teleport stored in /opt/teleport.

RFD: #47126
Goal (internal): https://github.com/gravitational/cloud/issues/11856

@sclevine sclevine requested review from vapopov and hugoShaka March 11, 2025 04:45
@github-actions github-actions bot requested review from kopiczko and zmb3 March 11, 2025 04:46
Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
@sclevine
Copy link
Member Author

sclevine commented Mar 11, 2025

Confusingly, after more extensive testing, it appears that a number of these commands are implemented in the last release of centos7, even though the systemd version reports 219 via systemctl --version. --now and is-enabled appear to work as specified in later versions of systemd.

They seem to be backported incompletely, as list-unit-files always returns 0, breaking some features, so I'm going to merge this regardless. (edit: looks like this was a bug that was fixed: systemd/systemd#15191)

CC: @hugoShaka

Comment on lines +375 to +377
// The --now flag is not supported in systemd versions older than 220,
// so perform enable + start commands instead.
code := s.systemctl(ctx, slog.LevelInfo, "enable", s.ServiceName)
Copy link
Contributor

@hugoShaka hugoShaka Mar 12, 2025

Choose a reason for hiding this comment

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

It looks like both RHEL7 and CentOS7 have systemctl enable --now:

$ docker run -it --rm centos:7 bash -c "systemctl enable --help | grep now"
     --now            Start or stop unit in addition to enabling or disabling it
$ [root@hugo-autoupdate-test-rhel7 ec2-user]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.9 (Maipo)

$ [root@hugo-autoupdate-test-rhel7 ec2-user]# systemctl enable --help | grep "now"
     --now            Start or stop unit in addition to enabling or disabling it

Note: they do both run systemd 219, so I suppose we either misunderstood when --now was introduced, or they did fun backports (likely as we're talking about RedHat).

Do we still want to do this change>

Copy link
Member Author

Choose a reason for hiding this comment

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

--now was added in 220: https://www.freedesktop.org/software/systemd/man/latest/systemctl.html#--now

Since we're aiming to support a wide range of distros, and older versions of rhel7/centos7 will not have the backport, it seems safer to stick to the spec and check the version for any APIs that have version requirements.

@sclevine sclevine added this pull request to the merge queue Mar 12, 2025
Merged via the queue into master with commit 93e28e5 Mar 12, 2025
41 checks passed
@sclevine sclevine deleted the sclevine/autoupdates-centos7 branch March 12, 2025 18:17
@public-teleport-github-review-bot

@sclevine See the table below for backport results.

Branch Result
branch/v17 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants