Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1954820 - pulp3_migration_stats rake task can underestimate the migration timing
Summary: pulp3_migration_stats rake task can underestimate the migration timing
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Repositories
Version: 6.9.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: 6.9.4
Assignee: Ian Ballou
QA Contact: Cole Higgins
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-04-28 19:57 UTC by Ian Ballou
Modified: 2022-02-07 14:59 UTC (History)
4 users (show)

Fixed In Version: tfm-rubygem-katello-3.18.1.33-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1973344 (view as bug list)
Environment:
Last Closed: 2021-07-29 12:58:50 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 32449 0 Normal Closed pulp3_migration_stats rake task can underestimate the migration timing 2021-05-05 18:31:53 UTC
Red Hat Product Errata RHBA-2021:2948 0 None None None 2021-07-29 13:03:39 UTC

Description Ian Ballou 2021-04-28 19:57:48 UTC
Description of problem:

Internally, there is an error with the migration timing code that can cause a variable to go negative.  This can occur if the user has many on-demand repositories that are included in content views.

The fix involves changing this line (https://github.com/Katello/katello/blob/KATELLO-3.18/lib/katello/tasks/pulp3_migration_stats.rake#L13) to be `Katello::RepositoryRpm.where(:repository_id => Katello::Repository.yum_type.on_demand).select(:rpm_id).distinct.count`.

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

6.9

How reproducible:

Always, if there are on-demand repositories inside of content views.

Steps to Reproduce:
1. Create any repository that is on-demand
2. Put that repository in a content view and publish it
3. Run `Katello::RepositoryRpm.where(:repository_id => Katello::Repository.yum_type.on_demand).distinct.count` in the foreman console and notice that it is negative.

Actual results:
The `on_demand_rpm_count` is negative, which causes the estimation time to be too low.

Expected results:
The `on_demand_rpm_count` is accurate.


Additional info:

Comment 1 Ian Ballou 2021-04-28 19:59:54 UTC
Created redmine issue https://projects.theforeman.org/issues/32449 from this bug

Comment 2 Bryan Kearney 2021-04-29 00:01:07 UTC
Upstream bug assigned to iballou

Comment 3 Bryan Kearney 2021-04-29 00:01:10 UTC
Upstream bug assigned to iballou

Comment 4 Ian Ballou 2021-05-06 21:14:47 UTC
Moving to POST since the upstream PR is merged.

Comment 5 Justin Sherrill 2021-06-01 19:49:30 UTC
this should not be on 6.10

Comment 8 Ian Ballou 2021-07-21 15:41:59 UTC
Correction to the original BZ notes: immediate_unmigrated_rpm_count was the variable that could go negative. Here's a good way to test:

1) Follow the original verification steps

2) Ensure that the following is negative:

```
::Katello::Rpm.count - Katello::RepositoryRpm.where(:repository_id => Katello::Repository.yum_type.on_demand).distinct.count
```

3) Ensure that the following is not negative:

```
::Katello::Rpm.count - Katello::RepositoryRpm.where(:repository_id => Katello::Repository.yum_type.on_demand).select(:rpm_id).distinct.count
```


Explanation:

The original on_demand_rpm_count query left out the `select(:rpm_id)` part, which would lead to on_demand_rpm_count being potentially way too large.  If on_demand_rpm_count is too big, and the user has not yet migrated any RPM content to Pulp 3, migrated_rpm_count would be zero. So, on_demand_unmigrated_rpm_count would equal on_demand_rpm_count, which is then also extremely large.  Therefore, immediate_unmigrated_rpm_count could be negative in the following equation since:
```
    immediate_unmigrated_rpm_count = ::Katello::Rpm.count - migrated_rpm_count - on_demand_unmigrated_rpm_count
```

on_demand_unmigrated_rpm_count is "extremely large", i.e., much greater than even ::Katello::Rpm.count.  migrated_rpm_count here is assumed to be zero, so that's how you get a negative number.

Comment 9 Ian Ballou 2021-07-21 17:58:32 UTC
Here's a way to test using the pulp3_migration_stats rake task directly:

Prerequisite: start on Satellite 6.9 with Pulp 2 enabled, not Pulp 3 (the default).


*** On a Satellite 6.9 machine without my commit:

1) Sync the recommended RHEL 8 BaseOS and AppStream repos on a 6.9 box using the on demand downlaod policy.
2) Put the repos in a content view and publish it
3) Run `foreman-rake katello:pulp3_migration_stats`:
  -> See that the rake task gives this output in the middle: Estimated migration time based on yum content: fewer than 5 minutes
    -> This is the bug. This is an under-estimate.



*** On a Satellite 6.9 machine with my commit:


1) Follow steps 1 through 3 above:
  -> See that the rake task gives this output in the middle: Estimated migration time based on yum content: 0 hours, 11 minutes

Comment 15 errata-xmlrpc 2021-07-29 12:58:50 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 (Satellite 6.9.4 Async Bug Fix Update), 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/RHBA-2021:2948

Comment 16 errata-xmlrpc 2021-07-29 13:02:56 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 (Satellite 6.9.4 Async Bug Fix Update), 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/RHBA-2021:2948


Note You need to log in before you can comment on or make changes to this bug.