Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1474249

Summary: Satellite shouldn't allow to delete the default organization of a puppet content view environment generated by Katello.
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: Content ViewsAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 6.2.10CC: dhawke, hyu, inecas, mjahangi, satellite6-bugs
Target Milestone: Unspecified   
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1479736 (view as bug list) Environment:
Last Closed: 2017-08-22 13:58:07 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 Hao Chang Yu 2017-07-24 08:33:44 UTC
Description of problem:
When a restricted user trying to promote a content view, Satellite will attempt to destroy the puppet environment content view. This is due to the fact that the puppet environment content view doesn't have any organization and cause the restricted user cannot find it.

Steps to Reproduce:
1. Create a content view with puppet modules
2. Publish and promote it to a life cycle environment, such as develop
3. Add the generated puppet content view environment to a hostgroup or host.
3. Go to Configure > Environment > click the puppet environment cv, such as KT_org_develop_my_puppet_cv_1_36 > remove all organizations > Submit
4. Logout and Login as a restricted user
5. Publish and promote the content view again, then you should get the following error.

337: Actions::Katello::ContentViewPuppetEnvironment::Destroy (error) [ 2375.02s / 0.15s ]  Skip
Started at: 2017-07-06 21:51:15 UTC

Ended at: 2017-07-06 22:30:50 UTC

Real time: 2375.02s

Execution time (excluding suspended state): 0.15s

Input:

---
content_view_puppet_environment:
  id: <id>
  name: my-test-cv
Output:

--- {}
Error:

RuntimeError

---
- "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.137/app/models/katello/model.rb:8:in
  `destroy!'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.137/app/lib/actions/katello/content_view_puppet_environment/destroy.rb:15:in
  `finalize'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/action.rb:528:in
  `block (2 levels) in execute_finalize'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/middleware/stack.rb:26:in
  `call'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/middleware/stack.rb:26:in
  `pass'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/middleware.rb:17:in
  `pass'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/action/progress.rb:30:in
  `with_progress_calculation'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/action/progress.rb:22:in
  `finalize'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/middleware/stack.rb:22:in
  `call'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/middleware/stack.rb:26:in
  `pass'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/middleware.rb:17:in
  `pass'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.137/app/lib/actions/middleware/keep_locale.rb:15:in
  `block in finalize'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.137/app/lib/actions/middleware/keep_locale.rb:22:in
  `with_locale'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.137/app/lib/actions/middleware/keep_locale.rb:15:in
  `finalize'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/middleware/stack.rb:22:in
  `call'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/middleware/stack.rb:26:in
  `pass'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/middleware.rb:17:in
  `pass'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/middleware.rb:38:in
  `finalize'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/middleware/stack.rb:22:in
  `call'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/middleware/world.rb:30:in
  `execute'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/action.rb:527:in
  `block in execute_finalize'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/action.rb:419:in
  `call'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/action.rb:419:in
  `block in with_error_handling'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/action.rb:419:in
  `catch'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/action.rb:419:in
  `with_error_handling'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/action.rb:526:in
  `execute_finalize'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.4/lib/dynflow/action.rb:260:in

The task has given a Runtime error without an error message. After some investigations, I found that puppet environment cannot be deleted because there is at least one hostgroup/host using it.

Actual results:
Satellite try to delete the puppet content view environment that is still in use by host/hostgroup

Expected results:
Satellite should not delete the puppet content view environment that is still in use by host/hostgroup

Comment 15 Ivan Necas 2017-08-09 10:01:01 UTC
I've created an additional BZ describing the behavior that leads to this state.

https://bugzilla.redhat.com/show_bug.cgi?id=1479736

Comment 16 Ivan Necas 2017-08-22 13:58:07 UTC
Given the fix in https://bugzilla.redhat.com/show_bug.cgi?id=1479736 should also lead to fixing this issue, I'm closing this issue as duplicate.

*** This bug has been marked as a duplicate of bug 1479736 ***