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

(MODULES-10873) Add support for puppet7 collection #524

Merged
merged 1 commit into from
Dec 2, 2020

Conversation

joshcooper
Copy link
Contributor

@joshcooper joshcooper commented Nov 19, 2020

This makes it possible to install puppet-agent from the puppet7 collection,
while keeping the current behavior of defaulting to puppet6.

Bump the github action to ruby 2.5 as puppet7 doesn't support earlier versions.

Add --trace argument to puppet apply run that performs the upgrade.

@joshcooper joshcooper requested a review from a team as a code owner November 19, 2020 20:32
@joshcooper joshcooper requested a review from a team November 19, 2020 20:32
@puppet-community-rangefinder
Copy link

puppet_agent::install::solaris is a class

that may have no external impact to Forge modules.

puppet_agent::service is a class

that may have no external impact to Forge modules.

This module is declared in 3 of 575 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

@joshcooper joshcooper closed this Nov 19, 2020
@joshcooper joshcooper reopened this Nov 19, 2020
@puppet-community-rangefinder
Copy link

puppet_agent::install::solaris is a class

that may have no external impact to Forge modules.

puppet_agent::service is a class

that may have no external impact to Forge modules.

This module is declared in 3 of 575 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

@gimmyxd
Copy link
Contributor

gimmyxd commented Nov 20, 2020

Seems like the task does not want to upgrade ubuntu 18.04 nodes:

  12:55:01 +0000 INFO: Version parameter defined: latest
  12:55:01 +0000 INFO: Downloading Puppet latest for Ubuntu...
  12:55:01 +0000 INFO: Ubuntu platform! Lets get you a DEB...
  12:55:01 +0000 INFO: Downloading http://apt.puppet.com/puppet7-release-bionic.deb
  12:55:01 +0000 INFO:   to file /tmp/install.sh.1361.60499/puppet7-release-bionic.deb
  12:55:01 +0000 INFO: Trying wget...
  12:55:01 +0000 INFO: Installing puppetlabs apt repo with dpkg...
  12:55:01 +0000 INFO: Version 6.19.1 detected...
  12:55:01 +0000 INFO: Collection upgrade detected, replacing puppet6-release
  Selecting previously unselected package puppet7-release.
  Hit:1 https://artifactory.delivery.puppetlabs.net/artifactory/ubuntu__remote bionic-security InRelease
  Hit:2 https://artifactory.delivery.puppetlabs.net/artifactory/ubuntu__remote bionic-updates InRelease
  Hit:3 https://artifactory.delivery.puppetlabs.net/artifactory/ubuntu__remote bionic InRelease
  Hit:4 http://apt.puppetlabs.com bionic InRelease
  Reading package lists...
  Reading package lists...
  Building dependency tree...
  Reading state information...
  puppet-agent is already the newest version (6.19.1-1bionic).
  0 upgraded, 0 newly installed, 0 to remove and 112 not upgraded.

@gimmyxd
Copy link
Contributor

gimmyxd commented Nov 20, 2020

I think i figured it out what is happening:
- we are installing puppet-agent 6, in order to do that we download puppet6-release and install it, but this install puppet-release instead of puppet6-release
- we start the upgrade to puppet 7, but first we need to remove the old release package, which we determine by the major version of the puppet-agent installed package: https://github.com/puppetlabs/puppetlabs-puppet_agent/blob/main/tasks/install_shell.sh#L464-L472
- this will fail to remove the release package and the next apt install -y puppet-agent will be a noop

host:~# dpkg -i puppet6-release-bionic.deb
Selecting previously unselected package puppet-release.
(Reading database ... 86341 files and directories currently installed.)
Preparing to unpack puppet6-release-bionic.deb ...
Unpacking puppet-release (1.0.0-14bionic) ...
Setting up puppet-release (1.0.0-14bionic) ...

host:~# dpkg -i --force-confmiss puppet7-release-bionic.deb
dpkg: regarding puppet7-release-bionic.deb containing puppet7-release:
 puppet7-release conflicts with puppet-release
  puppet-release (version 1.0.0-14bionic) is present and installed.

dpkg: error processing archive puppet7-release-bionic.deb (--install):
 conflicting packages - not installing puppet7-release
Errors were encountered while processing:
 puppet7-release-bionic.deb

@joshcooper
Copy link
Contributor Author

I verified I could upgrade from 6.19.1 to 7.0.0 on centos and ubuntu:

$ docker build -f docker/centos/Dockerfile . -t pa-6.19.1-dev:centos --build-arg before=6.19.1
...
$ docker run -it pa-6.19.1-dev:centos 7.0.0
...
Debug: Package[puppet-agent](provider=yum): Upgrading package puppet-agent from version 6.19.1-1.el7 to 7.0.0
Debug: Executing: '/usr/bin/yum -d 0 -e 0 -y update puppet-agent-7.0.0'
Debug: Executing: '/usr/bin/rpm -q puppet-agent --nosignature --nodigest --qf %{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n'
Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '6.19.1-1.el7' to '7.0.0'
$ docker build -f docker/ubuntu/Dockerfile . -t pa-6.19.1-dev:ubuntu --build-arg before=6.19.1
...
$ docker run -it pa-6.19.1-dev:ubuntu 7.0.0
...
Debug: Executing: '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold --force-yes install puppet-agent=7.0.0-1xenial'
Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '6.19.1-1xenial' to '7.0.0-1xenial'

The upgrade from 5.5.21 completes but fails to save the report due code mismatch. Filed as https://tickets.puppetlabs.com/browse/MODULES-10875

@joshcooper
Copy link
Contributor Author

joshcooper commented Nov 20, 2020

 we start the upgrade to puppet 7, but first we need to remove the old release package, which we determine by the major version of the puppet-agent installed package: https://github.com/puppetlabs/puppetlabs-puppet_agent/blob/main/tasks/install_shell.sh#L464-L472

Thanks @gimmyxd that makes sense. If I change the line to dpkg --purge "puppet-release" then it correctly removes the old repo and upgrades to puppet7:

  20:10:50 +0000 INFO: Installing puppetlabs apt repo with dpkg...
  20:10:50 +0000 INFO: Version 6.19.1 detected...
  20:10:50 +0000 INFO: Collection upgrade detected, replacing puppet6-release
  (Reading database ... 84315 files and directories currently installed.)
  Removing puppet-release (1.0.0-14bionic) ...
  Purging configuration files for puppet-release (1.0.0-14bionic) ...
  (Reading database ... 84310 files and directories currently installed.)
  Preparing to unpack .../puppet7-release-bionic.deb ...
  Unpacking puppet7-release (7.0.0-1bionic) ...
  Setting up puppet7-release (7.0.0-1bionic) ...
  Hit:1 https://artifactory.delivery.puppetlabs.net/artifactory/ubuntu__remote bionic-security InRelease
  Hit:2 http://apt.puppetlabs.com bionic InRelease
  Hit:3 https://artifactory.delivery.puppetlabs.net/artifactory/ubuntu__remote bionic-updates InRelease
  Hit:4 https://artifactory.delivery.puppetlabs.net/artifactory/ubuntu__remote bionic InRelease
  Get:5 http://apt.puppetlabs.com bionic/puppet7 amd64 Packages [2,414 B]
  Get:6 http://apt.puppetlabs.com bionic/puppet7 all Packages [1,725 B]
  Get:7 http://apt.puppetlabs.com bionic/puppet7 i386 Packages [1,725 B]
  Fetched 5,864 B in 1s (10.6 kB/s)
  Reading package lists...
  Reading package lists...
  Building dependency tree...
  Reading state information...
  The following packages will be upgraded:
    puppet-agent
  1 upgraded, 0 newly installed, 0 to remove and 112 not upgraded.
  Need to get 21.0 MB of archives.
  After this operation, 5,439 kB disk space will be freed.
  Get:1 http://apt.puppetlabs.com bionic/puppet7 amd64 puppet-agent amd64 7.0.0-1bionic [21.0 MB]
  Fetched 21.0 MB in 1s (40.3 MB/s)
(Reading database ... 84315 files and directories currently installed.)
  Preparing to unpack .../puppet-agent_7.0.0-1bionic_amd64.deb ...
  Unpacking puppet-agent (7.0.0-1bionic) over (6.19.1-1bionic) ...
  Setting up puppet-agent (7.0.0-1bionic) ...
  Processing triggers for libc-bin (2.27-3ubuntu1) ...

That said I'm thinking either the module should check if the package is actually installed prior to purging it, or somehow capture the fact that dpkg --purge didn't do anything. It doesn't seem we can rely on the exit code:

# dpkg --purge doesntexist
dpkg: warning: ignoring request to remove doesntexist which isn't installed
# echo $?
0

Is there a flag we can pass to dpkg --purge so the command fails if the package isn't installed?

Also note this PR should pass once we resolve the release packages for bionic (and buster and el8).

@joshcooper
Copy link
Contributor Author

Is there a flag we can pass to dpkg --purge so the command fails if the package isn't installed?

Ah, it looks like the code assumes if $installed_version is set (which is done by cat /opt/puppetlabs/puppet/VERSION, then the corresponding release package named puppet${major}-release must be installed. And normally it should be. We could add a more defensive check on all platforms, but I think that is a separate ticket.

@joshcooper
Copy link
Contributor Author

bionic packages were updated, should be good to go now

@gimmyxd gimmyxd requested a review from a team November 24, 2020 10:06
tasks/install_shell.sh Outdated Show resolved Hide resolved
This makes it possible to install puppet-agent from the puppet7 collection,
while keeping the current behavior of defaulting to puppet6.

Bump the github action to ruby 2.5 as puppet7 doesn't support earlier versions.

Add `--trace` argument to puppet apply run that performs the upgrade.
Copy link
Contributor

@Dorin-Pleava Dorin-Pleava left a comment

Choose a reason for hiding this comment

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

Tested with PE on debian and centos agents, and works as expected

@Dorin-Pleava Dorin-Pleava merged commit be06195 into puppetlabs:main Dec 2, 2020
@joshcooper joshcooper deleted the puppet7 branch December 3, 2020 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants