Skip to content

Conversation

Niyakiy
Copy link

@Niyakiy Niyakiy commented Jul 6, 2021

Fix improper pgdg repo file creation for Amazon Linux 2.

Description:
Current formula implementation uses
baseurl: 'https://download.postgresql.org/pub/repos/yum/{{ repo.version }}/redhat/rhel-$releasever-$basearch'
setting $releasever to 2 for Amazon Linux 2 and making formula install fail due to missing rhel-2 packages.

The fix makes a newly created formula repo file to use rhel-7 as the proper repository to use during install.

@Niyakiy Niyakiy requested review from myii and vutny as code owners July 6, 2021 08:19
Copy link
Contributor

@myii myii left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @Niyakiy. Please see the requested change below.

Comment on lines 64 to 68
{%- if grains.get('osfullname', "") == "Amazon Linux" and grains.get('osmajorrelease', 0) == 2 %}
baseurl: 'https://download.postgresql.org/pub/repos/yum/{{ repo.version }}/redhat/rhel-7-$basearch'
{%- else %}
baseurl: 'https://download.postgresql.org/pub/repos/yum/{{ repo.version }}/redhat/rhel-$releasever-$basearch'
{%- endif %}
Copy link
Contributor

Choose a reason for hiding this comment

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

@Niyakiy This if block can be avoided by adding this change to osmap.yaml instead, in a similar manner to this block:

Fedora:
pkg_repo:
# yamllint disable-line rule:line-length
baseurl: 'https://download.postgresql.org/pub/repos/yum/{{ repo.version }}/fedora/fedora-$releasever-$basearch'

I.e. Probably:

Amazon:
  pkg_repo:
    baseurl: 'https://download.postgresql.org/pub/repos/yum/{{ repo.version }}/redhat/rhel-7-$basearch'

This isn't perfect, since it doesn't specify the version of Amazon Linux but it is probably sufficient, since we're no longer supporting Amazon Linux 1 (2018). We could use the oscodename grain (Amazon Linux 2) in codenamemap.yaml but that's overkill in my opinion. Ultimately, we have a new map.jinja that is being introduced across formulas and we can provide the best solution when that becomes available.

Copy link
Author

Choose a reason for hiding this comment

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

@myii Thanks for the heads up on a better and easier way to introduce a fix. Having AL1 already deprecated it looks reasonable to leave Amazon inside osmap.yaml as we have only the 2nd version available. However, it will require additional code changes here once AWS releases a new major version of AL.
I'm about to push the requested code changes along with reworded commit message.

@myii
Copy link
Contributor

myii commented Jul 6, 2021

Just another note, doesn't necessarily have to be addressed by this PR.


We're not currently testing use_upstream_repo for most platforms, so this PR isn't actually being tested properly. Need to consider updating this block in the test pillar:

postgres:
# UPSTREAM REPO
# Set True to configure upstream postgresql.org repository for YUM/APT/ZYPP
{%- if grains.os_family != 'Debian' and salt['grains.get']('osfinger') != 'CentOS-6' %}
use_upstream_repo: False
{%- else %}
use_upstream_repo: True
# Version to install from upstream repository (if upstream_repo: True)
version: '13'

I'll try to run some tests when I get a chance. Let's not make this a blocker for this PR, if I don't report back soon.

@Niyakiy Please don't go out of your way to run these tests, what you've already provided is more than enough, thanks.

@Niyakiy Niyakiy force-pushed the dev/fix-amazon-linux-install-from-upstream-repo branch from 43c5696 to 2de775b Compare July 6, 2021 12:14
@Niyakiy Niyakiy requested a review from myii July 6, 2021 12:14
@myii myii changed the title fix(osfamilymap.yaml): fix PGDG repo file creation for Amazon Linux 2 fix(osmap.yaml): fix PGDG repo file creation for Amazon Linux 2 Jul 6, 2021
@myii myii merged commit 097d4e4 into saltstack-formulas:master Jul 6, 2021
@myii
Copy link
Contributor

myii commented Jul 6, 2021

Thanks, @Niyakiy -- merged.

Out of interest, did you need to adjust the pkg_deps to also install these packages?

  pkgs_deps:
    - libicu
    - systemd-sysv

I had to do that to get PostgreSQL 13 installed on Amazon Linux 2:

@saltstack-formulas-travis

🎉 This PR is included in version 0.41.9 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@myii
Copy link
Contributor

myii commented Jul 7, 2021

@Niyakiy I've refactored this Amazon Linux 2 support in #315 -- feel free to comment on it there.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants