Bug 2209758

Summary: /katello/api/content_views/ endpoint returns CV versions unsorted when multiple CVVs are published
Product: Red Hat Satellite Reporter: Vladimír Sedmík <vsedmik>
Component: Content ViewsAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED CURRENTRELEASE QA Contact: Vladimír Sedmík <vsedmik>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.13.0CC: riehecky, sajha
Target Milestone: UnspecifiedKeywords: EasyFix, Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-05-29 18:45:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vladimír Sedmík 2023-05-24 16:24:29 UTC
Description of problem:
When we have a CV with multiple versions published, the /katello/api/content_views/<id> endpoint returns CV versions unsorted, which results in unsorted output of `hammer content-view info` command.


Version-Release number of selected component (if applicable):
6.13.0


How reproducible:
always for higher (~10 or more) count of CVV published


Steps to Reproduce:
1. Have a CV with some repo, publish it multiple times (in a loop, no changes needed)
2. Display the CV details using hammer:
# hammer content-view info --id <cv_id>
3. GET the CV details using /katello/api/content_views/ endpoint:
# curl -sku admin:passwd -X GET https://$(hostname)/katello/api/content_views/<cv_id> | jq


Actual results:
2. # hammer content-view info --id="27"
Id:                           27
Name:                         ydKgmVXuAF
Label:                        ydKgmVXuAF
Composite:                    false
Description:                  
Content Host Count:           0
Solve Dependencies:           false
Organization:                 UwcidX
Yum Repositories:             
 1) Id:    63
    Name:  XTrVRTDYMPnmkBS
    Label: XTrVRTDYMPnmkBS
Container Image Repositories: 

OSTree Repositories:          

Lifecycle Environments:       
 1) Id:   13
    Name: Library
Versions:                     
 1) Id:        64
    Version:   8.0                      <---------------
    Published: 2023/05/24 12:39:35
 2) Id:        57
    Version:   1.0
    Published: 2023/05/24 12:38:29
 3) Id:        58
    Version:   2.0
    Published: 2023/05/24 12:38:47
 4) Id:        59
    Version:   3.0
    Published: 2023/05/24 12:38:55
 5) Id:        60
    Version:   4.0
    Published: 2023/05/24 12:39:03
 6) Id:        61
    Version:   5.0
    Published: 2023/05/24 12:39:11
 7) Id:        62
    Version:   6.0
    Published: 2023/05/24 12:39:19
 8) Id:        63
    Version:   7.0
    Published: 2023/05/24 12:39:27
 9) Id:        65
    Version:   9.0                    <---------------
    Published: 2023/05/24 12:39:43
 10)Id:        66
    Version:   10.0
    Published: 2023/05/24 12:39:51

3. # curl -sku admin:passwd -X GET https://$(hostname)/katello/api/content_views/27 | jq
  ...
  "versions": [
    {
      "id": 64,
      "version": "8.0",
      "published": "2023-05-24 12:39:35 UTC",
      "environment_ids": [],
      "filters_applied": false
    },
    {
      "id": 57,
      "version": "1.0",
      "published": "2023-05-24 12:38:29 UTC",
      "environment_ids": [],
      "filters_applied": false
    },
    {
      "id": 58,
      "version": "2.0",
      "published": "2023-05-24 12:38:47 UTC",
      "environment_ids": [],
      "filters_applied": false
    },
    {
      "id": 59,
      "version": "3.0",
      "published": "2023-05-24 12:38:55 UTC",
      "environment_ids": [],
      "filters_applied": false
    },
    {
      "id": 60,
      "version": "4.0",
      "published": "2023-05-24 12:39:03 UTC",
      "environment_ids": [],
      "filters_applied": false
    },
    {
      "id": 61,
      "version": "5.0",
      "published": "2023-05-24 12:39:11 UTC",
      "environment_ids": [],
      "filters_applied": false
    },
    {
      "id": 62,
      "version": "6.0",
      "published": "2023-05-24 12:39:19 UTC",
      "environment_ids": [],
      "filters_applied": false
    },
    {
      "id": 63,
      "version": "7.0",
      "published": "2023-05-24 12:39:27 UTC",
      "environment_ids": [],
      "filters_applied": false
    },
    {
      "id": 65,
      "version": "9.0",
      "published": "2023-05-24 12:39:43 UTC",
      "environment_ids": [],
      "filters_applied": false
    },
    {
      "id": 66,
      "version": "10.0",
      "published": "2023-05-24 12:39:51 UTC",
      "environment_ids": [
        13
      ],
      "filters_applied": false
    }
   ...

Expected results:
Output sorted by Id or Version.

Comment 1 Vladimír Sedmík 2024-03-07 13:26:52 UTC
Might have been already fixed together with https://bugzilla.redhat.com/show_bug.cgi?id=2215310

Comment 2 Vladimír Sedmík 2024-03-07 15:07:54 UTC
Verified in 6.15.0 snap 9.0 and 6.14.3 snap 1.0 - versions are now sorted in CLI and API.

Comment 3 Brad Buckingham 2024-05-29 18:45:12 UTC
Closing bugzilla as it was VERIFIED on Satellite 6.15.