Bug 1683096

Summary: hammer sync-plan update does not work with custom cron
Product: Red Hat Satellite Reporter: Stephen Wadeley <swadeley>
Component: Sync PlansAssignee: Samir Jha <sajha>
Status: CLOSED ERRATA QA Contact: Stephen Wadeley <swadeley>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.0.0CC: akofink, egolov
Target Milestone: 6.5.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-3.10.0.30-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-05-14 12:40: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:

Description Stephen Wadeley 2019-02-26 09:19:49 UTC
Description of problem:

When trying to update a sync-plan created with interval set to custom cron, the command always fails with:

Could not update the sync plan:
  Cron expression is not valid!

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

~]# hammer --version
hammer (0.15.1)


How reproducible:

I tried many different commands against sync-plan created in web UI and using hammer.


Steps to Reproduce:
1. ~]# hammer sync-plan create  --name BugTest --sync-date "2019/02/01" --enabled 1  --interval "custom cron" --cron-expression "1 2 3 4 5" --organization-id 1 
2. ~]# hammer sync-plan info --name BugTest --organization-id 1

3. ~]# hammer sync-plan update --name BugTest --organization-id 1 --description Hello
Could not update the sync plan:
  Cron expression is not valid!

4. ~]# hammer sync-plan update --name BugTest --organization-id 1 --description Hello --cron-expression "1 2 3 4 5"
Could not update the sync plan:
  Cron expression is not valid!


Actual results:

Could not update the sync plan

Expected results:

Could update the sync plan

Comment 4 Andrew Kofink 2019-02-26 14:04:27 UTC
This is definitely an issue in Katello. The following works just fine (with --interval _and_ --cron-expression):

hammer -d sync-plan update --id 3 --cron-expression "1 2 3 4 5" --interval "custom cron"

This logic in Katello isn't quite right https://github.com/Katello/katello/blob/master/app/models/katello/sync_plan.rb#L59. It only checks the params and not the currently set value (self.interval rather than params["interval"]). It looks like this is a regression starting in Katello 3.9 https://github.com/Katello/katello/commit/8ac17807def.

Comment 5 jcallaha 2019-03-08 16:58:10 UTC
This also breaks with valid cron

hammer sync-plan create  --name BugTest --sync-date "2019/02/01" --enabled 1  --interval "custom cron" --cron-expression "0 0 12 1 1 ? *" --organization-id 1
Could not create the sync plan:
  Cron expression is not valid!

Comment 6 Samir Jha 2019-03-08 21:26:19 UTC
Created redmine issue http://projects.theforeman.org/issues/26283 from this bug

Comment 7 Bryan Kearney 2019-03-14 18:04:41 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/26283 has been resolved.

Comment 12 errata-xmlrpc 2019-05-14 12:40: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-2019:1222