Jira (PUP-11235) versioncmp() thinks 11.0 is greater than 11

2 views
Skip to first unread message

Tim Meusel (Jira)

unread,
Sep 1, 2021, 4:48:03 AM9/1/21
to puppe...@googlegroups.com
Tim Meusel created an issue
 
Puppet / Bug PUP-11235
versioncmp() thinks 11.0 is greater than 11
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2021/09/01 1:47 AM
Priority: Normal Normal
Reporter: Tim Meusel

Puppet Version: 6.24.0
Puppet Server Version: none
OS Name/Version: Debian 11

while debugging https://github.com/puppetlabs/puppetlabs-apache/pull/2186 i noticed that versioncmp('11.0', '11') doesn't return 0, it returns 1. Is that expected?

Desired Behavior:

I think 11.0 and 11 should be treated as equal

Actual Behavior:

versioncmp() thinks 11.0 is greater than 11

to debug:

notify { "operatingsystemrelease compared to 11: ${versioncmp($::operatingsystemrelease, '11')}":
}
notify { "operatingsystemmajrelease compared to 11: ${versioncmp($::operatingsystemmajrelease, '11')}":
}
notify { "operatingsystemrelease: ${::operatingsystemrelease}":
}
notify { "operatingsystemmajrelease: ${::operatingsystemrelease}":
}

which brings us:

puppet apply test.pp
Notice: Compiled catalog for blal in environment production in 0.02 seconds
Notice: operatingsystemrelease compared to 11: 1
Notice: /Stage[main]/Main/Notify[operatingsystemrelease compared to 11: 1]/message: defined 'message' as 'operatingsystemrelease compared to 11: 1'
Notice: operatingsystemmajrelease compared to 11: 0
Notice: /Stage[main]/Main/Notify[operatingsystemmajrelease compared to 11: 0]/message: defined 'message' as 'operatingsystemmajrelease compared to 11: 0'
Notice: operatingsystemrelease: 11.0
Notice: /Stage[main]/Main/Notify[operatingsystemrelease: 11.0]/message: defined 'message' as 'operatingsystemrelease: 11.0'
Notice: operatingsystemmajrelease: 11.0
Notice: /Stage[main]/Main/Notify[operatingsystemmajrelease: 11.0]/message: defined 'message' as 'operatingsystemmajrelease: 11.0'
Notice: Applied catalog in 0.01 seconds

and the facts:

:~> facter operatingsystemmajrelease
11
:~> facter operatingsystemrelease
11.0

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Tim Meusel (Jira)

unread,
Sep 14, 2021, 2:33:03 PM9/14/21
to puppe...@googlegroups.com
Tim Meusel commented on Bug PUP-11235
 
Re: versioncmp() thinks 11.0 is greater than 11

The awesome Josh Cooper did some digging during the latest office-hours through the issue. The conversation: https://puppetcommunity.slack.com/archives/CFD8Z9A4T/p1631641997091600

tl;dr:
> the algorithm is a little strange, if the version strings are different lengths, it'll always fall back to comparing the entire string...

maybe it makes sense to add a python like coerce() method for all versioncmp() inputs?

Josh Cooper (Jira)

unread,
Sep 16, 2021, 1:22:03 PM9/16/21
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-11235

One thing I remembered is many packages don't follow SemVer. For example, we ran into issues while adding ensure => '> 1.0.0' for package resources in PUP-10298, PUP-10416, etc. For this issue, it might be worth just solving the general problem of implicit 0 minor and/or patch components.

Ciprian Badescu (Jira)

unread,
Sep 20, 2021, 10:24:02 AM9/20/21
to puppe...@googlegroups.com

Ciprian Badescu (Jira)

unread,
Sep 20, 2021, 10:25:02 AM9/20/21
to puppe...@googlegroups.com
Ciprian Badescu updated an issue
Change By: Ciprian Badescu
Sprint: NW - 2021-10-20

Ciprian Badescu (Jira)

unread,
Sep 20, 2021, 10:25:03 AM9/20/21
to puppe...@googlegroups.com

Ciprian Badescu (Jira)

unread,
Sep 29, 2021, 3:41:02 AM9/29/21
to puppe...@googlegroups.com

Ciprian Badescu (Jira)

unread,
Sep 29, 2021, 3:41:02 AM9/29/21
to puppe...@googlegroups.com
Ciprian Badescu updated an issue
Change By: Ciprian Badescu
Sprint: NW - 2021-10- 20 06

Dorin Pleava (Jira)

unread,
Sep 29, 2021, 1:11:02 PM9/29/21
to puppe...@googlegroups.com
Dorin Pleava assigned an issue to Dorin Pleava
Change By: Dorin Pleava
Assignee: Dorin Pleava

Ciprian Badescu (Jira)

unread,
Oct 6, 2021, 5:01:03 AM10/6/21
to puppe...@googlegroups.com
Ciprian Badescu updated an issue
Change By: Ciprian Badescu
Sprint: NW - 2021-10-06 , NW - 2021-10-20

Josh Cooper (Jira)

unread,
Oct 11, 2021, 12:14:02 PM10/11/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Oct 11, 2021, 12:14:03 PM10/11/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
 
Change By: Josh Cooper
Fix Version/s: PUP 6.26.0
Fix Version/s: PUP 7.13.0

Michael Hashizume (Jira)

unread,
Dec 6, 2021, 6:03:01 PM12/6/21
to puppe...@googlegroups.com
Michael Hashizume updated an issue
Change By: Michael Hashizume
Release Notes: Bug Fix
Release Notes Summary: versioncmp() strips redundant numbers

Parker Leach (Jira)

unread,
Dec 7, 2021, 11:46:02 PM12/7/21
to puppe...@googlegroups.com
Parker Leach updated an issue
Change By: Parker Leach
Labels: docs_reviewed help_wanted
This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages