Bug 1951878 - Introduce a valid solution to fix the error "Katello::Errors::CandlepinError: Environment with id XXXX could not be found" in Satellite 6
Summary: Introduce a valid solution to fix the error "Katello::Errors::CandlepinError:...
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Content Views
Version: 6.8.0
Hardware: All
OS: Linux
Target Milestone: 6.10.0
Assignee: Jonathon Turel
QA Contact: Lai
Depends On:
TreeView+ depends on / blocked
Reported: 2021-04-21 03:23 UTC by Sayan Das
Modified: 2023-10-06 21:35 UTC (History)
5 users (show)

Fixed In Version: tfm-rubygem-katello-
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1985318 (view as bug list)
Last Closed: 2021-11-16 14:10:33 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 33019 0 High Ready For Testing Introduce a valid solution to fix the error "Katello::Errors::CandlepinError: Environment with id XXXX could not be foun... 2021-07-22 13:55:48 UTC
Red Hat Knowledge Base (Solution) 2931671 0 None None None 2021-06-07 15:01:05 UTC
Red Hat Knowledge Base (Solution) 3389101 0 None None None 2021-04-21 03:32:29 UTC
Red Hat Knowledge Base (Solution) 4323801 0 None None None 2021-04-21 03:32:29 UTC
Red Hat Product Errata RHSA-2021:4702 0 None None None 2021-11-16 14:10:52 UTC

Description Sayan Das 2021-04-21 03:23:44 UTC
1. Proposed title of this feature request

Introduce a valid foreman-rake based solution to counter and fix the error "Katello::Errors::CandlepinError: Environment with id 5a6ac4b9ba58f37e93b155ec4eaa3e07 could not be found" 

2. What is the nature and description of the request?

Change in code\Inclusion of new code for the product is required to achieve the desired goal. 

3. Why does the customer need this? (List the business requirements here)

To avoid manual workaround and achieve a clean CV or CV version deletion without having any DB inconsistencies present.

4. How would the customer like to achieve this? (List the functional requirements here)

The error "Katello::Errors::CandlepinError: Environment with id 5a6ac4b9ba58f37e93b155ec4eaa3e07 could not be found", usually can be seen when the Customer is trying to delete a CV and CV version and suddenly the task went to Paused state. 

And at the backend, 5a6ac4b9ba58f37e93b155ec4eaa3e07 environment-id will hopefully be missing from cp_environment and\or cp2_environment_content table of candlepin DB due to which this error message pops up.

In 99% of the cases, we provide this solution or go on the remote session to do following :

	* Open the task
	* Open Dynflow COnsole
	* Skip the step with error related to "Environment with id 5a6ac4b9ba58f37e93b155ec4eaa3e07 could not be found"
	* Resume the task

Customers will not always be able to understand the instructions and we will end up connecting on a remote session to perform the same thing again.

In my opinion, we should not be doing this kind of manual hack as this leaves inconsistent information in Candlepin DB. So expectation here is to have a rake-based solution present, that can recreate the missing environment and then we can resume the task gracefully without needing to skip any steps from dynflow.

5. For each functional requirement listed, specify how Red Hat and the customer can test to confirm the requirement is successfully implemented.
- Create some inconsistency in Candlepin DB
- Try to delete a CV or CV version to reproduce the error "Katello::Errors::CandlepinError: Environment with id 5a6ac4b9ba58f37e93b155ec4eaa3e07 could not be found"
- At this stage the task will be in paused state.
- Execute the foreman-rake command (or the solution prepared by Redhat) to fix the missing environment with id XXX in Candlepin DB
- Resume the paused task and wait for it to get completed successfully.

6. Is there already an existing RFE upstream or in Red Hat Bugzilla?

7. Does the customer have any specific timeline dependencies and which release would they like to target (i.e. RHEL5, RHEL6)?

As soon as possible

8. Is the sales team involved in this request and do they have any additional input?

9. List any affected packages or components.
- Katello \ Candlepin \ Postgres \ Rake

10. Would the customer be able to assist in testing this functionality if implemented?

NA but Support folks can

11. Additional information:

Some additional information will be provided in the private comments

Comment 4 Jonathon Turel 2021-07-14 19:35:48 UTC
Created redmine issue https://projects.theforeman.org/issues/33019 from this bug

Comment 5 Bryan Kearney 2021-07-27 16:02:15 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/33019 has been resolved.

Comment 9 Lai 2021-08-19 16:18:34 UTC
Steps to retest:

1. Create a new LCE
2. Create a custom product with custom repo and sync
3. Create a cv and add the repo from step 2
4. Tail candlepin.log
5. Publish cv from 3 and do a promote
6. Confirm that new environment was created in log
7. Delete environment from rails console: Katello::Resources::Candlepin::Environment.destroy('<environment id from candlepin.log>')
8. Publish cv again and promote and see the environment is recreated in candlepin.log
9. Delete the environment again from Rails console (the new lce created from step 1)
10. Delete the LCE that you created in step 1 from UI as well.
11. Ensure that no error appear in candlepin.log

Expected result:
6) Should be able to see new environment being created in log
8) Should be able to see environment is created in log
11) Should not see any errors being raised in log

6) Able to see new environment being created in log
8) Able to see environment being recreated in log
org.candlepin.common.filter.LoggingFilter - Request: verb=GET, uri=/candlepin/environments/d5aa01ea4a4f2d907d5d7735233fee5a
11) There was no errors appearing in log after deleting environments on both rake console and the webUI

Verified on 6.10 snap 13 with tfm-rubygem-katello-

Comment 12 errata-xmlrpc 2021-11-16 14:10:33 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 (Moderate: Satellite 6.10 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


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