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

[RPM/DEB] Changes to binary distribution #6638

Open
wants to merge 53 commits into
base: main
Choose a base branch
from

Conversation

michalpristas
Copy link
Contributor

@michalpristas michalpristas commented Jan 30, 2025

What does this PR do?

Fixes behavior for RPM

  • RPM/DEB installs basic agent by default
  • installation respects value of ELATIC_AGENT_FLAVOR
  • on upgrade
    • in case previous installlation without flavor -> copy all
    • in case previous installation with flavor -> respect flavor

This takes a bit different approach as we cannot control what's being copied over during installations.
Before install we mark desired flavor into flavor file.
After install we execute new undocumented command apply-flavor that removes all unnecessary component from current version home.

Why is it important?

Reducing space on disk by omitting not needed components.

Checklist

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

How to test

DEB

install scenario
  • compile deb
  • run dpkg -i elastic-agent-{rest of filename}.deb
  • cat /var/lib/elastic-agent/.flavor (expected basic)
  • ls -la /var/lib/elastic-agent/data/elastic-agent-*/componentes expected limited set
  • uninstall and purge
  • run ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-{rest of filename}.deb
  • cat /var/lib/elastic-agent/.flavor (expected servers)
  • ls -la /var/lib/elastic-agent/data/elastic-agent-*/componentes expected apm fleet-server present
  • uninstall and purge
upgrade scenario
  • compile deb

  • install 8.17.2 snapshot dpkg -i elastic-agent-{rest of filename}.deb

  • cat /var/lib/elastic-agent/.flavor (expected file not found)

  • ls -la /var/lib/elastic-agent/data/elastic-agent-*/componentes expected whole set

  • install 9.0.0 snapshot dpkg -i elastic-agent-{rest of filename}.deb

  • cat /var/lib/elastic-agent/.flavor expected not found

  • ls -la /var/lib/elastic-agent/data/elastic-agent-*/componentes expected whole set

  • uninstall and purge

  • compile additional deb with different hash

  • install additional deb ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-{rest of filename}.deb

  • cat /var/lib/elastic-agent/.flavor (expected servers)

  • ls -la /var/lib/elastic-agent/data/elastic-agent-*/componentes expected servers set

  • install original build dpkg -i elastic-agent-{rest of filename}.deb

  • cat /var/lib/elastic-agent/.flavor expected servers

  • ls -la /var/lib/elastic-agent/data/elastic-agent-*/componentes expected servers set

same steps for rpm but use yum

Fixes: #6637

@michalpristas michalpristas added bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team backport-skip skip-changelog labels Jan 30, 2025
@michalpristas michalpristas requested a review from a team as a code owner January 30, 2025 08:54
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@michalpristas michalpristas self-assigned this Jan 30, 2025
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
4.0% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube

@cmacknz
Copy link
Member

cmacknz commented Jan 31, 2025

We have integration tests for these packages that should be updated to verify this works properly:

Is an environment variable the canonical way to provide options to these package types? If we do something that doesn't follow the system convention we'll be explaining it forever.

@cmacknz cmacknz requested a review from leehinman January 31, 2025 21:26
@leehinman
Copy link
Contributor

Is an environment variable the canonical way to provide options to these package types? If we do something that doesn't follow the system convention we'll be explaining it forever.

An env var is NOT what you would expect. For both RPM & DEB you would expect multiple RPM & DEB files that are built from the same source. I would expect 2 RPM & DEB files, one that installs the minimal, and one that installs the extra components. The extra components one would depend on the minimal. Any upgrade scenario would upgrade both.

vim is a good example.

RPM

You can install vim-minimal, and have a working vi, here are the package contents.

$ rpm -ql vim-minimal
/etc/virc
/usr/bin/ex
/usr/bin/rvi
/usr/bin/rview
/usr/bin/vi
/usr/bin/view
/usr/lib/.build-id
/usr/lib/.build-id/5c
/usr/lib/.build-id/5c/ca9c420c7d69ce13f7cfe7ea0e7fdc7c18bc3f
/usr/libexec/vi
/usr/share/man/man1/ex.1.gz
/usr/share/man/man1/rvi.1.gz
/usr/share/man/man1/rview.1.gz
/usr/share/man/man1/vi.1.gz
/usr/share/man/man1/view.1.gz
/usr/share/man/man5/virc.5.gz

If you then want a more "full" vim experience you install vim-enhanced along side vim-minimal and you have:

$ rpm -ql vim-enhanced
/usr/bin/rvim
/usr/bin/vim
/usr/bin/vimdiff
/usr/bin/vimtutor
/usr/lib/.build-id
/usr/lib/.build-id/cc
/usr/lib/.build-id/cc/b0b26d3af0feb447e3f786a6b7be4f79f854bd

But both of these are built from the same RPM source:

vim-minimal

$ dnf info vim-minimal
Last metadata expiration check: 0:00:40 ago on Fri 31 Jan 2025 03:49:34 PM CST.
Installed Packages
Name         : vim-minimal
Epoch        : 2
Version      : 8.2.2637
Release      : 21.el9
Architecture : aarch64
Size         : 1.4 M
Source       : vim-8.2.2637-21.el9.src.rpm
Repository   : @System
From repo    : baseos
Summary      : A minimal version of the VIM editor
URL          : http://www.vim.org/
License      : Vim and MIT
Description  : VIM (VIsual editor iMproved) is an updated and improved version of the
             : vi editor.  Vi was the first real screen-based editor for UNIX, and is
             : still very popular.  VIM improves on vi by adding new features:
             : multiple windows, multi-level undo, block highlighting and more. The
             : vim-minimal package includes a minimal version of VIM, providing
             : the commands vi, view, ex, rvi, and rview. NOTE: The online help is
             : only available when the vim-common package is installed.

vim-enhanced

$ dnf info vim-enhanced
Last metadata expiration check: 0:00:29 ago on Fri 31 Jan 2025 03:49:34 PM CST.
Available Packages
Name         : vim-enhanced
Epoch        : 2
Version      : 8.2.2637
Release      : 21.el9
Architecture : aarch64
Size         : 1.7 M
Source       : vim-8.2.2637-21.el9.src.rpm
Repository   : appstream
Summary      : A version of the VIM editor which includes recent enhancements
URL          : http://www.vim.org/
License      : Vim and MIT
Description  : VIM (VIsual editor iMproved) is an updated and improved version of the
             : vi editor.  Vi was the first real screen-based editor for UNIX, and is
             : still very popular.  VIM improves on vi by adding new features:
             : multiple windows, multi-level undo, block highlighting and more.  The
             : vim-enhanced package contains a version of VIM with extra, recently
             : introduced features like Python and Perl interpreters.
             :
             : Install the vim-enhanced package if you'd like to use a version of the
             : VIM editor which includes recently added enhancements like
             : interpreters for the Python and Perl scripting languages.  You'll also
             : need to install the vim-common package.

Deb

You can install vim-tiny to get a minimal vi clone.

 dpkg -L vim-tiny
/.
/etc
/etc/vim
/etc/vim/vimrc.tiny
/usr
/usr/bin
/usr/bin/vim.tiny
/usr/share
/usr/share/bug
/usr/share/bug/vim-tiny
/usr/share/bug/vim-tiny/presubj
/usr/share/bug/vim-tiny/script
/usr/share/doc
/usr/share/doc/vim-tiny
/usr/share/doc/vim-tiny/changelog.Debian.gz
/usr/share/doc/vim-tiny/copyright
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/vim-tiny
/usr/share/vim
/usr/share/vim/vim91
/usr/share/vim/vim91/doc
/usr/share/vim/vim91/doc/README.Debian
/usr/share/vim/vim91/doc/help.txt
diverted by vim-runtime to: /usr/share/vim/vim91/doc/help.txt.vim-tiny
/usr/share/vim/vim91/doc/tags
diverted by vim-runtime to: /usr/share/vim/vim91/doc/tags.vim-tiny

If you want the full vim experience you would install vim-nox along side vim-tiny

$ dpkg -L vim-nox
/.
/usr
/usr/bin
/usr/bin/vim.nox
/usr/share
/usr/share/bug
/usr/share/bug/vim-nox
/usr/share/bug/vim-nox/presubj
/usr/share/bug/vim-nox/script
/usr/share/doc
/usr/share/doc/vim-nox
/usr/share/doc/vim-nox/changelog.Debian.gz
/usr/share/doc/vim-nox/copyright
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/vim-nox

Deb packages use the alternates system to set symlink so vi could point to either /usr/bin/vim.tiny or /usr/bin/vim-nox

But as you can see from the apt info for each, they are built from the same source.

vim-tiny

$ apt info vim-tiny
Package: vim-tiny
Version: 2:9.1.0016-1ubuntu7.6
Priority: important
Section: editors
Source: vim
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Debian Vim Maintainers <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 1,850 kB
Provides: editor
Depends: vim-common (= 2:9.1.0016-1ubuntu7.6), libacl1 (>= 2.2.23), libc6 (>= 2.34), libselinux1 (>= 3.1~), libtinfo6 (>= 6)
Suggests: indent
Homepage: https://www.vim.org/
Task: minimal
Download-Size: 770 kB
APT-Manual-Installed: no
APT-Sources: http://ports.ubuntu.com/ubuntu-ports noble-updates/main arm64 Packages
Description: Vi IMproved - enhanced vi editor - compact version
 Vim is an almost compatible version of the UNIX editor Vi.
 .
 This package contains a minimal version of Vim compiled with no GUI and
 a small subset of features. This package's sole purpose is to provide
 the vi binary for base installations.
 .
 If a vim binary is wanted, try one of the following more featureful
 packages: vim, vim-nox, vim-motif, or vim-gtk3.

vim-nox

$ apt info vim-nox
Package: vim-nox
Version: 2:9.1.0016-1ubuntu7.6
Priority: extra
Section: universe/editors
Source: vim
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Debian Vim Maintainers <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 4,950 kB
Provides: editor, vim (= 2:9.1.0016-1ubuntu7.6), vim-lua (= 2:9.1.0016-1ubuntu7.6), vim-perl (= 2:9.1.0016-1ubuntu7.6), vim-python3 (= 2:9.1.0016-1ubuntu7.6), vim-ruby (= 2:9.1.0016-1ubuntu7.6), vim-tcl (= 2:9.1.0016-1ubuntu7.6)
Depends: vim-common (= 2:9.1.0016-1ubuntu7.6), vim-runtime (= 2:9.1.0016-1ubuntu7.6), libacl1 (>= 2.2.23), libc6 (>= 2.38), libgpm2 (>= 1.20.7), liblua5.1-0, libperl5.38t64 (>= 5.38.2), libpython3.12t64 (>= 3.12.1), libruby3.2 (>= 3.2.2), libselinux1 (>= 3.1~), libsodium23 (>= 1.0.14), libtcl8.6 (>= 8.6.0), libtinfo6 (>= 6)
Suggests: cscope, vim-doc
Homepage: https://www.vim.org/
Download-Size: 2,040 kB
APT-Manual-Installed: yes
APT-Sources: http://ports.ubuntu.com/ubuntu-ports noble-updates/universe arm64 Packages
Description: Vi IMproved - enhanced vi editor - with scripting languages support
 Vim is an almost compatible version of the UNIX editor Vi.
 .
 Many new features have been added: multi level undo, syntax
 highlighting, command line history, on-line help, filename
 completion, block operations, folding, Unicode support, etc.
 .
 This package contains a version of vim compiled with support for
 scripting with Lua, Perl, Python 3, Ruby, and Tcl but no GUI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip bug Something isn't working skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEB/RPM not defaulting to basic agent
4 participants