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

Fix failing to install packages with -noarch in name #9085

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

anhpt379
Copy link
Contributor

We're missing a \. at the beginning, since .join() only puts |\. in between items:

>> ARCH_REGEX = Regexp.new(ARCH_LIST.join('|\.'))
=> /noarch|\.i386|\.i686|\.ppc|\.ppc64|\.armv3l|\.armv4b|\.armv4l|\.armv4tl|\.armv5tel|\.armv5tejl|\.armv6l|\.armv7l|\.m68kmint|\.s390|\.s390x|\.ia64|\.x86_64|\.sh3|\.sh4/

Currently puppet is failing to install package with -noarch string in its name because of the invalid ARCH_REGEX:

package { 'package-name-noarch':
  ensure => '1.0.0.el8'
}
Debug: Executing: '/bin/dnf -d 0 -e 1 -y install package-name--1.0.0.el8noarch'
Error: Could not update: Execution of '/bin/dnf -d 0 -e 1 -y install package-name--1.0.0.el8noarch' returned 1: Error: Unable to find a match: package-name--1.0.0.el7noarch

We're missing a `\.` at the beginning, since `.join()` only puts `|\.`
in between items:

```
>> ARCH_REGEX = Regexp.new(ARCH_LIST.join('|\.'))
=> /noarch|\.i386|\.i686|\.ppc|\.ppc64|\.armv3l|\.armv4b|\.armv4l|\.armv4tl|\.armv5tel|\.armv5tejl|\.armv6l|\.armv7l|\.m68kmint|\.s390|\.s390x|\.ia64|\.x86_64|\.sh3|\.sh4/
```

Currently puppet is failing to install package with `-noarch` string in
its name because of the invalid ARCH_REGEX:

```
package { 'package-name-noarch':
  ensure => '1.0.0.el8'
}
```

```
Debug: Executing: '/bin/dnf -d 0 -e 1 -y install package-name--1.0.0.el8noarch'
Error: Could not update: Execution of '/bin/dnf -d 0 -e 1 -y install package-name--1.0.0.el8noarch' returned 1: Error: Unable to find a match: package-name--1.0.0.el7noarch
```
@anhpt379 anhpt379 requested a review from a team as a code owner July 10, 2023 12:55
@puppetlabs-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@CLAassistant
Copy link

CLAassistant commented Jul 10, 2023

CLA assistant check
All committers have signed the CLA.

@joshcooper
Copy link
Contributor

Hi @anhpt379 thank you for your contribution. Could you sign the CLA?

@joshcooper
Copy link
Contributor

Hi @anhpt379 could you review my last comment?

@joshcooper joshcooper added the bug Something isn't working label Nov 15, 2023
@anhpt379
Copy link
Contributor Author

I have signed it at least 2 times, but the status doesn't get updated. I've signed it again. Please check now.

@joshcooper
Copy link
Contributor

@anhpt379 sorry I completely missed that you signed it. We've updated our rspec checks since you submitted this, so I need to close and reopen the PR to trigger the correct set of checks.

@joshcooper joshcooper closed this Nov 15, 2023
@joshcooper joshcooper reopened this Nov 15, 2023
@joshcooper joshcooper added triaged Jira issue has been created for this and removed triaged Jira issue has been created for this labels Mar 12, 2024
@joshcooper
Copy link
Contributor

I agree the ARCH_REGEX seems wrong, but I am able to manage noarch packages without this change.

# puppet --version
8.5.1
# cat manifest.pp 
package { 'ant.noarch':
  ensure => installed
}
# puppet apply manifest.pp --debug
...
Debug: Prefetching dnf resources for package
Debug: Executing: '/usr/bin/rpm --version'
Debug: Executing '/usr/bin/rpm -qa --nosignature --nodigest --qf '%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n' | sort'
Debug: Executing: '/usr/bin/rpm -q ant.noarch --nosignature --nodigest --qf %{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n'
Debug: Executing: '/usr/bin/rpm -q ant.noarch --nosignature --nodigest --qf %{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n --whatprovides'
Debug: Package[ant.noarch](provider=dnf): Ensuring => present
Debug: Executing: '/usr/bin/dnf -d 0 -e 1 -y install ant.noarch'
Notice: /Stage[main]/Main/Package[ant.noarch]/ensure: created
...
# rpm -q ant
ant-1.10.12-5.amzn2023.0.4.noarch

@joshcooper
Copy link
Contributor

Ah I see, I can reproduce as:

# /opt/puppetlabs/puppet/bin/puppet apply -e "package { 'python3-gobject-base-noarch': ensure => '3.42.1' }"
Notice: Compiled catalog for blunt-fortnight.vmpooler-prod.puppet.net in environment production in 0.40 seconds
Error: Could not update: Execution of '/usr/bin/dnf -d 0 -e 1 -y install python3-gobject-base--3.42.1noarch' returned 1: Error: Unable to find a match: python3-gobject-base--3.42.1noarch

With this change:

# /opt/puppetlabs/puppet/bin/puppet apply -e "package { 'python3-gobject-base-noarch': ensure => '3.42.1' }"
Notice: Compiled catalog for blunt-fortnight.vmpooler-prod.puppet.net in environment production in 0.38 seconds
Notice: /Stage[main]/Main/Package[python3-gobject-base-noarch]/ensure: created
Notice: Applied catalog in 3.73 seconds
# rpm -qa | grep gobject
gobject-introspection-1.72.1-1.fc36.x86_64
python3-gobject-base-noarch-3.42.1-1.fc36.noarch
python3-gobject-base-3.42.1-1.fc36.x86_64

@joshcooper joshcooper merged commit 47f7f3b into puppetlabs:main Apr 11, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants