Bug 1522769

Summary: [V2] Regression in content view API
Product: Red Hat Satellite Reporter: Lukas Zapletal <lzap>
Component: API - ContentAssignee: Partha Aji <paji>
Status: CLOSED ERRATA QA Contact: Renzo Nuccitelli <rnuccite>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: bbuckingham, brubisch, dlezzoum, ehelms, jturel, peter.vreman, rnuccite
Target Milestone: UnspecifiedKeywords: Regression, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-3.4.5.47-1,tfm-rubygem-katello-3.4.5.53-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 16:54:17 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:
Bug Depends On:    
Bug Blocks: 1122832, 1533259, 1534215    

Description Lukas Zapletal 2017-12-06 12:19:42 UTC
In Satellite 6.3, there is an API V2 breakage for content views.

A) components_ids are missing
B) repository_ids are empty (they were likely empty even in 6.2)

Can you guys discuss what would be the best approach for
handling this? I general, we must avoid doing breaking changes in the
API, if we want we can bump version to V3. I think there are two good
options - add the missing _ids back as deprecated options (to be
removed in V3) or waive the change making an upgrade note in our docs
if there is some kind of technical limitation to do the former.

[root@zzzap ~]# curl -sku admin:changeme https://$(hostname
-f):443/katello/api/v2/content_views/4 | json_reformat
{
    "content_host_count": 0,
    "composite": true,
    "repository_ids": [

    ],
    "default": false,
    "force_puppet_environment": false,
    "version_count": 1,
    "latest_version": "1.0",
    "id": 4,
    "name": "ccv-soe",
    "label": "ccv-soe",
    "description": null,
    "organization": {
        "name": "MyOrg",
        "label": "MyOrg",
        "id": 1
    },
    "created_at": "2017-12-04 12:10:51 UTC",
    "updated_at": "2017-12-04 12:11:06 UTC",
    "environments": [
        {
            "id": 1,
            "name": "Library",
            "label": "Library",
            "permissions": {
                "readable": true
            }
        }
    ],
    "repositories": [
        {
            "id": 12,
            "name": "Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server",
            "label": "Red_Hat_Enterprise_Linux_7_Server_RPMs_x86_64_7Server",
            "content_type": "yum"
        },
        {
            "id": 16,
            "name": "Red Hat Satellite Tools 6.2 for RHEL 6 Server RPMs x86_64",
            "label":
"Red_Hat_Satellite_Tools_6_2_for_RHEL_6_Server_RPMs_x86_64",
            "content_type": "yum"
        },
        {
            "id": 14,
            "name": "Red Hat Satellite Tools 6.2 for RHEL 7 Server RPMs x86_64",
            "label":
"Red_Hat_Satellite_Tools_6_2_for_RHEL_7_Server_RPMs_x86_64",
            "content_type": "yum"
        }
    ],
    "puppet_modules": [

    ],
    "versions": [
        {
            "id": 4,
            "version": "1.0",
            "published": "2017-12-04 12:11:06 UTC",
            "environment_ids": [
                1
            ]
        }
    ],
    "components": [
        {
            "id": 2,
            "name": "cv-rhel7 1.0",
            "content_view_id": 2,
            "version": "1.0",
            "puppet_module_count": 0,
            "environments": [
                {
                    "id": 1,
                    "name": "Library",
                    "label": "Library"
                }
            ],
            "content_view": {
                "id": 2,
                "name": "cv-rhel7",
                "label": "cv-rhel7",
                "description": null,
                "next_version": 2,
                "latest_version": "1.0"
            },
            "repositories": [
                {
                    "id": 12,
                    "name": "Red Hat Enterprise Linux 7 Server RPMs
x86_64 7Server",
                    "label":
"Red_Hat_Enterprise_Linux_7_Server_RPMs_x86_64_7Server"
                }
            ]
        },
        {
            "id": 3,
            "name": "cv-tools 1.0",
            "content_view_id": 3,
            "version": "1.0",
            "puppet_module_count": 0,
            "environments": [
                {
                    "id": 1,
                    "name": "Library",
                    "label": "Library"
                }
            ],
            "content_view": {
                "id": 3,
                "name": "cv-tools",
                "label": "cv-tools",
                "description": null,
                "next_version": 2,
                "latest_version": "1.0"
            },
            "repositories": [
                {
                    "id": 16,
                    "name": "Red Hat Satellite Tools 6.2 for RHEL 6
Server RPMs x86_64",
                    "label":
"Red_Hat_Satellite_Tools_6_2_for_RHEL_6_Server_RPMs_x86_64"
                },
                {
                    "id": 14,
                    "name": "Red Hat Satellite Tools 6.2 for RHEL 7
Server RPMs x86_64",
                    "label":
"Red_Hat_Satellite_Tools_6_2_for_RHEL_7_Server_RPMs_x86_64"
                }
            ]
        }
    ],
    "content_view_components": [
        {
            "latest": true,
            "id": 1,
            "created_at": "2017-12-04 12:10:56 UTC",
            "updated_at": "2017-12-04 12:10:56 UTC",
            "composite_content_view": {
                "id": 4,
                "name": "ccv-soe",
                "label": "ccv-soe",
                "description": null,
                "next_version": 2,
                "latest_version": "1.0",
                "version_count": 1
            },
            "content_view": {
                "id": 2,
                "name": "cv-rhel7",
                "label": "cv-rhel7",
                "description": null,
                "next_version": 2,
                "latest_version": "1.0",
                "version_count": 1
            },
            "content_view_version": {
                "id": 2,
                "name": "cv-rhel7 1.0",
                "content_view_id": 2,
                "version": "1.0",
                "puppet_module_count": 0,
                "content_view": {
                    "id": 2,
                    "name": "cv-rhel7",
                    "label": "cv-rhel7",
                    "description": null
                },
                "environments": [
                    {
                        "id": 1,
                        "name": "Library",
                        "label": "Library"
                    }
                ],
                "repositories": [
                    {
                        "id": 12,
                        "name": "Red Hat Enterprise Linux 7 Server
RPMs x86_64 7Server",
                        "label":
"Red_Hat_Enterprise_Linux_7_Server_RPMs_x86_64_7Server"
                    }
                ]
            }
        },
        {
            "latest": true,
            "id": 2,
            "created_at": "2017-12-04 12:10:56 UTC",
            "updated_at": "2017-12-04 12:10:56 UTC",
            "composite_content_view": {
                "id": 4,
                "name": "ccv-soe",
                "label": "ccv-soe",
                "description": null,
                "next_version": 2,
                "latest_version": "1.0",
                "version_count": 1
            },
            "content_view": {
                "id": 3,
                "name": "cv-tools",
                "label": "cv-tools",
                "description": null,
                "next_version": 2,
                "latest_version": "1.0",
                "version_count": 1
            },
            "content_view_version": {
                "id": 3,
                "name": "cv-tools 1.0",
                "content_view_id": 3,
                "version": "1.0",
                "puppet_module_count": 0,
                "content_view": {
                    "id": 3,
                    "name": "cv-tools",
                    "label": "cv-tools",
                    "description": null
                },
                "environments": [
                    {
                        "id": 1,
                        "name": "Library",
                        "label": "Library"
                    }
                ],
                "repositories": [
                    {
                        "id": 16,
                        "name": "Red Hat Satellite Tools 6.2 for RHEL
6 Server RPMs x86_64",
                        "label":
"Red_Hat_Satellite_Tools_6_2_for_RHEL_6_Server_RPMs_x86_64"
                    },
                    {
                        "id": 14,
                        "name": "Red Hat Satellite Tools 6.2 for RHEL
7 Server RPMs x86_64",
                        "label":
"Red_Hat_Satellite_Tools_6_2_for_RHEL_7_Server_RPMs_x86_64"
                    }
                ]
            }
        }
    ],
    "activation_keys": [

    ],
    "next_version": "2.0",
    "last_published": "2017-12-04 12:11:06 UTC",
    "permissions": {
        "view_content_views": true,
        "edit_content_views": true,
        "destroy_content_views": true,
        "publish_content_views": true,
        "promote_or_remove_content_views": true


    }
}

Comment 3 David Davis 2017-12-06 16:42:21 UTC
The component_ids field missing is definitely a bug and I am not sure why that's happening given that it's in the code (see https://git.io/vbcEu). 

It looks like repository_ids captures repos that are directly associated with a content view whereas the 'repositories' field will either display repositories associated with a content view OR repos associated with a composite view's components (see https://git.io/vbcEC). I am not sure how to resolve this discrepancy.

Comment 5 Jonathon Turel 2018-01-08 21:31:29 UTC
Created redmine issue http://projects.theforeman.org/issues/22180 from this bug

Comment 7 Renzo Nuccitelli 2018-01-16 12:44:58 UTC
I've run some tests on Satellite 6.3 snap 32. First for a simple CV:

{
    "content_host_count": 0,
    "composite": false,
    "component_ids": [
        2
    ],
    "default": false,
    "force_puppet_environment": false,
    "version_count": 1,
    "latest_version": "1.0",
    "repository_ids": [
        1
    ],
    "id": 2,
    "name": "simple-cv",
    "label": "simple-cv",
    "description": null,
    "organization": {
        "name": "Default Organization",
        "label": "Default_Organization",
        "id": 1
    },
    "created_at": "2018-01-16 12:27:15 UTC",
    "updated_at": "2018-01-16 12:27:31 UTC",
    "environments": [
        {
            "id": 1,
            "name": "Library",
            "label": "Library",
            "permissions": {
                "readable": true
            }
        }
    ],
    "repositories": [
        {
            "id": 1,
            "name": "Red Hat Enterprise Linux 7 Server RPMs x86_64 7.4",
            "label": "Red_Hat_Enterprise_Linux_7_Server_RPMs_x86_64_7_4",
            "content_type": "yum"
        }
    ],,
    "puppet_modules": [

    ],
    "versions": [
        {
            "id": 2,
            "version": "1.0",
            "published": "2018-01-16 12:27:31 UTC",
            "environment_ids": [
                1
            ]
        }
    ],
    "components": [

    ],


It has the correct repository_ids (1). component_ids has id 2 but the components itself is empty which seems a mismatch.

I have also tried a composite CV:

{
    "content_host_count": 0,
    "composite": true,
    "component_ids": [
        3
    ],
    "default": false,
    "force_puppet_environment": false,
    "version_count": 1,
    "latest_version": "1.0",
    "repository_ids": [
        2
    ],
    "id": 3,
    "name": "cv-composite",
    "label": "cv-composite",
    "description": null,
    "organization": {
        "name": "Default Organization",
        "label": "Default_Organization",
        "id": 1
    },
    "created_at": "2018-01-16 12:28:15 UTC",
    "updated_at": "2018-01-16 12:28:36 UTC",
    "environments": [
        {
            "id": 1,
            "name": "Library",
            "label": "Library",
            "permissions": {
                "readable": true
            }
        }
    ],
    "repositories": [
        {
            "id": 2,
            "name": "Red Hat Enterprise Linux 7 Server RPMs x86_64 7.4",
            "label": "Red_Hat_Enterprise_Linux_7_Server_RPMs_x86_64_7_4",
            "content_type": "yum"
        }
    ],
    "puppet_modules": [

    ],
    "versions": [
        {
            "id": 3,
            "version": "1.0",
            "published": "2018-01-16 12:28:36 UTC",
            "environment_ids": [
                1
            ]
        }
    ],
    "components": [
        {
            "id": 2,
            "name": "simple-cv 1.0",
            "content_view_id": 2,
            "version": "1.0",
            "puppet_module_count": 0,
            "environments": [
                {
                    "id": 1,
                    "name": "Library",
                    "label": "Library"
                }
            ],
            "content_view": {
                "id": 2,
                "name": "simple-cv",
                "label": "simple-cv",
                "description": null,
                "next_version": 2,
                "latest_version": "1.0"
            },
            "repositories": [
                {
                    "id": 2,
                    "name": "Red Hat Enterprise Linux 7 Server RPMs x86_64 7.4",
                    "label": "Red_Hat_Enterprise_Linux_7_Server_RPMs_x86_64_7_4"
                }
            ]
        }
    ],
    "content_view_components": [
        {
            "latest": true,
            "id": 1,
            "created_at": "2018-01-16 12:28:22 UTC",
            "updated_at": "2018-01-16 12:28:22 UTC",
            "composite_content_view": {
                "id": 3,
                "name": "cv-composite",
                "label": "cv-composite",
                "description": null,
                "next_version": 2,
                "latest_version": "1.0",
                "version_count": 1
            },
            "content_view": {
                "id": 2,
                "name": "simple-cv",
                "label": "simple-cv",
                "description": null,
                "next_version": 2,
                "latest_version": "1.0",
                "version_count": 1
            },
            "content_view_version": {
                "id": 2,
                "name": "simple-cv 1.0",
                "content_view_id": 2,
                "version": "1.0",
                "puppet_module_count": 0,
                "content_view": {
                    "id": 2,
                    "name": "simple-cv",
                    "label": "simple-cv",
                    "description": null
                },
                "environments": [
                    {
                        "id": 1,
                        "name": "Library",
                        "label": "Library"
                    }
                ],
                "repositories": [
                    {
                        "id": 2,
                        "name": "Red Hat Enterprise Linux 7 Server RPMs x86_64 7.4",
                        "label": "Red_Hat_Enterprise_Linux_7_Server_RPMs_x86_64_7_4"
                    }
                ]
            }
        }
    ],


Again the repository_ids has the matching id on repositories (2). Yet again component_id has a mismatching value (3) compared to components fields (2).

So I ask: what should be expected on component_ids for in both examples:

Comment 8 Partha Aji 2018-01-16 16:47:27 UTC
*** Bug 1534468 has been marked as a duplicate of this bug. ***

Comment 9 Partha Aji 2018-01-16 16:58:56 UTC
Connecting redmine issue http://projects.theforeman.org/issues/22288 from this bug

Comment 10 Partha Aji 2018-01-16 20:13:13 UTC
Connecting redmine issue http://projects.theforeman.org/issues/22288 from this bug

Comment 11 Partha Aji 2018-01-16 20:13:37 UTC
Connecting redmine issue http://projects.theforeman.org/issues/22288 from this bug

Comment 13 Renzo Nuccitelli 2018-01-25 16:09:19 UTC
Test performed on satellite 6.3 snap 34.

both repository_ids and component_ids are fine on simple CV:


{
    "content_host_count": 0,
    "composite": false,
    "component_ids": [

    ],
    "default": false,
    "force_puppet_environment": false,
    "version_count": 1,
    "latest_version": "1.0",
    "repository_ids": [
        1
    ],
    "id": 2,
    "name": "cv-simple",
    "label": "cv-simple",
    "description": null,
    "organization": {
        "name": "Default Organization",
        "label": "Default_Organization",
        "id": 1
    },
    "created_at": "2018-01-25 16:02:08 UTC",
    "updated_at": "2018-01-25 16:02:22 UTC",
    "environments": [
        {
            "id": 1,
            "name": "Library",
            "label": "Library",
            "permissions": {
                "readable": true
            }
        }
    ],
    "repositories": [
        {
            "id": 1,
            "name": "Red Hat Enterprise Linux 7 Server RPMs x86_64 7.4",
            "label": "Red_Hat_Enterprise_Linux_7_Server_RPMs_x86_64_7_4",
            "content_type": "yum"
        }
    ],
    "puppet_modules": [

    ],
    "versions": [
        {
            "id": 2,
            "version": "1.0",
            "published": "2018-01-25 16:02:22 UTC",
            "environment_ids": [
                1
            ]
        }
    ],
    "components": [

    ],
    "content_view_components": [

    ],
    "activation_keys": [

    ],
    "next_version": "2.0",
    "last_published": "2018-01-25 16:02:22 UTC",
    "permissions": {
        "view_content_views": true,
        "edit_content_views": true,
        "destroy_content_views": true,
        "publish_content_views": true,
        "promote_or_remove_content_views": true
    }
}


And they are also consistent for composite CV:

{
    "content_host_count": 0,
    "composite": true,
    "component_ids": [
        2
    ],
    "default": false,
    "force_puppet_environment": false,
    "version_count": 1,
    "latest_version": "1.0",
    "repository_ids": [
        2
    ],
    "id": 3,
    "name": "cv-composite",
    "label": "cv-composite",
    "description": null,
    "organization": {
        "name": "Default Organization",
        "label": "Default_Organization",
        "id": 1
    },
    "created_at": "2018-01-25 16:03:09 UTC",
    "updated_at": "2018-01-25 16:03:27 UTC",
    "environments": [
        {
            "id": 1,
            "name": "Library",
            "label": "Library",
            "permissions": {
                "readable": true
            }
        }
    ],
    "repositories": [
        {
            "id": 2,
            "name": "Red Hat Enterprise Linux 7 Server RPMs x86_64 7.4",
            "label": "Red_Hat_Enterprise_Linux_7_Server_RPMs_x86_64_7_4",
            "content_type": "yum"
        }
    ],
    "puppet_modules": [

    ],
    "versions": [
        {
            "id": 3,
            "version": "1.0",
            "published": "2018-01-25 16:03:27 UTC",
            "environment_ids": [
                1
            ]
        }
    ],
    "components": [
        {
            "id": 2,
            "name": "cv-simple 1.0",
            "content_view_id": 2,
            "version": "1.0",
            "puppet_module_count": 0,
            "environments": [
                {
                    "id": 1,
                    "name": "Library",
                    "label": "Library"
                }
            ],
            "content_view": {
                "id": 2,
                "name": "cv-simple",
                "label": "cv-simple",
                "description": null,
                "next_version": 2,
                "latest_version": "1.0"
            },
            "repositories": [
                {
                    "id": 2,
                    "name": "Red Hat Enterprise Linux 7 Server RPMs x86_64 7.4",
                    "label": "Red_Hat_Enterprise_Linux_7_Server_RPMs_x86_64_7_4"
                }
            ]
        }
    ],
    "content_view_components": [
        {
            "latest": true,
            "id": 1,
            "created_at": "2018-01-25 16:03:19 UTC",
            "updated_at": "2018-01-25 16:03:19 UTC",
            "composite_content_view": {
                "id": 3,
                "name": "cv-composite",
                "label": "cv-composite",
                "description": null,
                "next_version": 2,
                "latest_version": "1.0",
                "version_count": 1
            },
            "content_view": {
                "id": 2,
                "name": "cv-simple",
                "label": "cv-simple",
                "description": null,
                "next_version": 2,
                "latest_version": "1.0",
                "version_count": 1
            },
            "content_view_version": {
                "id": 2,
                "name": "cv-simple 1.0",
                "content_view_id": 2,
                "version": "1.0",
                "puppet_module_count": 0,
                "content_view": {
                    "id": 2,
                    "name": "cv-simple",
                    "label": "cv-simple",
                    "description": null
                },
                "environments": [
                    {
                        "id": 1,
                        "name": "Library",
                        "label": "Library"
                    }
                ],
                "repositories": [
                    {
                        "id": 2,
                        "name": "Red Hat Enterprise Linux 7 Server RPMs x86_64 7.4",
                        "label": "Red_Hat_Enterprise_Linux_7_Server_RPMs_x86_64_7_4"
                    }
                ]
            }
        }
    ],
    "activation_keys": [

    ],
    "next_version": "2.0",
    "last_published": "2018-01-25 16:03:27 UTC",
    "permissions": {
        "view_content_views": true,
        "edit_content_views": true,
        "destroy_content_views": true,
        "publish_content_views": true,
        "promote_or_remove_content_views": true
    }
}

Thus I'm moving this BZ to VERIFIED.

Comment 14 Satellite Program 2018-02-21 16:54:17 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.
> 
> For information on the advisory, and where to find the updated files, follow the link below.
> 
> If the solution does not work for you, open a new bug report.
> 
> https://access.redhat.com/errata/RHSA-2018:0336