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 1506237

Summary: foreman-tasks-delete always failed showing Invalid State
Product: Red Hat Satellite Reporter: Nikhil Kathole <nkathole>
Component: Satellite MaintainAssignee: Kavita <kgaikwad>
Status: CLOSED ERRATA QA Contact: Nikhil Kathole <nkathole>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: apatel, bbuckingham, inecas, kgaikwad, mmccune, sthirugn
Target Milestone: UnspecifiedKeywords: Triaged
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: Environment:
Last Closed: 2018-04-04 14:02:54 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: 1496794    

Description Nikhil Kathole 2017-10-25 13:17:45 UTC
Description of problem: We were trying foreman-tasks-delete from foreman-maintain advanced procedure run with --state as pending/paused/running/stopped. But it always display Invalid state error.

Version-Release number of selected component (if applicable): foreman-maintain snap 3

 # rpm -q rubygem-foreman_maintain
rubygem-foreman_maintain-0.0.10-1.el7sat.noarch


How reproducible: always


Steps to Reproduce:
1.# foreman-maintain advanced procedure  run foreman-tasks-delete --state paused
Running ForemanMaintain::Scenario
================================================================================
Delete tasks:
/ Deleting paused task                                                [FAIL]
Invalid State
--------------------------------------------------------------------------------
Scenario [ForemanMaintain::Scenario] failed.

The following steps ended up in failing state:

  [foreman-tasks-delete]

Resolve the failed steps and rerun
the command. In case the failures are false positives,
use --whitelist="foreman-tasks-delete"


Actual results:
FAIL showing Invalid State and Runtime error in foreman-maintain.log

I, [2017-10-25 09:16:32-0400 #24695]  INFO -- : Running foreman-maintain command with arguments [["advanced", "procedure", "run", "foreman-tasks-delete", "--state", "paused"]]
E, [2017-10-25 09:16:32-0400 #24695] ERROR -- : Invalid State (RuntimeError)
/usr/share/gems/gems/foreman_maintain-0.0.10/definitions/features/foreman_tasks.rb:87:in `condition'
/usr/share/gems/gems/foreman_maintain-0.0.10/definitions/features/foreman_tasks.rb:67:in `count'
/usr/share/gems/gems/foreman_maintain-0.0.10/definitions/procedures/foreman_tasks/delete.rb:10:in `block in run'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/reporter/cli_reporter.rb:135:in `with_spinner'
/usr/share/gems/gems/foreman_maintain-0.0.10/definitions/procedures/foreman_tasks/delete.rb:9:in `run'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/executable.rb:118:in `__run__'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/runner/execution.rb:76:in `block (2 levels) in run'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/runner/execution.rb:99:in `capture_errors'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/runner/execution.rb:75:in `block in run'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/runner/execution.rb:93:in `with_metadata_calculation'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/runner/execution.rb:74:in `run'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/runner.rb:108:in `run_step'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/runner.rb:97:in `run_steps'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/runner.rb:90:in `execute_scenario_steps'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/runner.rb:45:in `run_scenario'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/runner.rb:30:in `block in run'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/runner.rb:29:in `each'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/runner.rb:29:in `run'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/cli/base.rb:48:in `run_scenario'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/cli/advanced/procedure/abstract_procedure_command.rb:12:in `execute'
/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
/usr/share/gems/gems/foreman_maintain-0.0.10/lib/foreman_maintain/cli.rb:21:in `run'
/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run'
/usr/share/gems/gems/foreman_maintain-0.0.10/bin/foreman-maintain:12:in `<top (required)>'
/usr/bin/foreman-maintain:23:in `load'
/usr/bin/foreman-maintain:23:in `<main>'


Expected results: 


Additional info:

Comment 1 Swapnil Abnave 2017-10-26 07:04:57 UTC
Created redmine issue http://projects.theforeman.org/issues/21472 from this bug

Comment 3 Satellite Program 2017-11-08 23:01:06 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/21472 has been resolved.

Comment 4 Kavita 2017-12-15 07:09:27 UTC
Attached upstream ticket is not fully serving the purpose of BZ.

Using foreman-tasks-delete procedure, we are only deleting below foreman-tasks:
1. Having state - planning/pending and
2. paused/stopped tasks which are older than 30 days.

Here, expected possible values are old, planning or pending for --state option.

Attaching a upstream bug - http://projects.theforeman.org/issues/21974
and modifying status of this BZ ticket.

Comment 5 sthirugn@redhat.com 2018-01-16 14:18:49 UTC
Updated outdated Target Milestone.

Comment 6 Anurag Patel 2018-04-03 12:08:36 UTC
Closing this since this is not a relevant issue. We do not try to delete paused tasks, we just try to resume them. So, run `foreman-tasks-delete --state paused` should never be run. 

The only valid values are 'old', 'planning' or 'pending'. With PR ( https://github.com/theforeman/foreman_maintain/pull/132 ) foreman-maintain would validate values passed to --state option and won't throw an error.

Comment 7 sthirugn@redhat.com 2018-04-03 14:45:24 UTC
Moved to ON_QA as per Anurag's email that this is present from rubygem-foreman_maintain-0.1.4 onwards.

Comment 8 Nikhil Kathole 2018-04-03 14:48:18 UTC
VERIFIED

# rpm -qa | grep maintain
rubygem-foreman_maintain-0.1.5-1.el7sat.noarch

# foreman-maintain advanced procedure run foreman-tasks-delete --state paused
'paused' not allowed for state param. Possible values are old, planning, pending

# foreman-maintain advanced procedure run foreman-tasks-delete --state old
Running ForemanMaintain::Scenario
================================================================================
Delete tasks:
/ Deleting old task                                                   [OK]
--------------------------------------------------------------------------------
# foreman-maintain advanced procedure run foreman-tasks-delete --state planning
Running ForemanMaintain::Scenario
================================================================================
Delete tasks:
/ Deleting planning task                                              [OK]
--------------------------------------------------------------------------------

# foreman-maintain advanced procedure run foreman-tasks-delete --state pending
Running ForemanMaintain::Scenario
================================================================================
Delete tasks:
/ Deleting pending task                                               [OK]
--------------------------------------------------------------------------------

Error gets properly handled and foreman-tasks-delete procedure working fine with 
possible values old, planning and pending.

Comment 11 errata-xmlrpc 2018-04-04 14:02:54 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/RHBA-2018:0633