Bug 1582982

Summary: softwarechannel_setsyncschedule InvalidParamException
Product: [Community] Spacewalk Reporter: Eric Burgueño <nevermind85>
Component: ServerAssignee: Tomáš Kašpárek <tkasparek>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 2.8   
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-01-15 07:59:22 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: 1653216    

Description Eric Burgueño 2018-05-28 03:15:34 UTC
Description of problem:

After creating a Software Channel and repository, I want to set a sync schedule with spacecmd softwarechannel_setsyncschedule. This does not seem to be parsing the Quartz CronTrigger schedule correctly.

Setting the same schedule on the GUI works, but it's impossible to do from the command line:

spacecmd {SSM:0}> softwarechannel_listsyncschedule
  key  Channel Name                             Update Schedule     
-----  ---------------------                    ---------------     
  101  centos6-x86_64                           0 0 22 ? * 6


spacecmd {SSM:0}> softwarechannel_setsyncschedule centos6-x86_64 0 0 22 ? * 6
ERROR: redstone.xmlrpc.XmlRpcFault: unhandled internal exception: redstone.xmlrpc.XmlRpcFault: com.redhat.rhn.taskomatic.InvalidParamException: Cron trigger: 0 0 22 ? .* 6

spacecmd {SSM:0}> softwarechannel_setsyncschedule centos6-x86_64 0 0 22 ? \* 6
ERROR: redstone.xmlrpc.XmlRpcFault: unhandled internal exception: redstone.xmlrpc.XmlRpcFault: com.redhat.rhn.taskomatic.InvalidParamException: Cron trigger: 0 0 22 ? .* 6

spacecmd {SSM:0}> softwarechannel_setsyncschedule centos6-x86_64 0 0 22 ? \\* 6
ERROR: redstone.xmlrpc.XmlRpcFault: unhandled internal exception: redstone.xmlrpc.XmlRpcFault: com.redhat.rhn.taskomatic.InvalidParamException: Cron trigger: 0 0 22 ? \.* 6

spacecmd {SSM:0}> softwarechannel_setsyncschedule centos6-x86_64 0 0 22 ? "*" 6
ERROR: redstone.xmlrpc.XmlRpcFault: unhandled internal exception: redstone.xmlrpc.XmlRpcFault: com.redhat.rhn.taskomatic.InvalidParamException: Cron trigger: 0 0 22 ? .* 6

spacecmd {SSM:0}> softwarechannel_setsyncschedule centos6-x86_64 0 0 22 ? '*' 6
ERROR: redstone.xmlrpc.XmlRpcFault: unhandled internal exception: redstone.xmlrpc.XmlRpcFault: com.redhat.rhn.taskomatic.InvalidParamException: Cron trigger: 0 0 22 ? .* 6

Version:
# rpm -qa|grep spacecmd
spacecmd-2.8.25-1.el7.centos.noarch

How reproducible:
Always

Steps to Reproduce:
As above

Comment 1 Tomáš Kašpárek 2018-05-28 05:50:25 UTC
This should be already fixed in master by commit 3e8942219def2910ca45e0cfc4a337e69fee8efa

Could you please try to use latest nightly version of spacecmd to see whether it fails or not?
It can be easily found here: https://copr.fedorainfracloud.org/coprs/g/spacewalkproject/nightly/build/758551/

Comment 2 Eric Burgueño 2018-05-28 21:58:43 UTC
Yes, that seems to work. I do however find it odd that the exit code is still 0 when the command fails:

# spacecmd -- softwarechannel_setsyncschedule --sync-kickstart "epel7-centos7-x86_64" "0 15 0 \? \* 7"
INFO: Connected to https://spacewalk.example.com/rpc/api as admin
softwarechannel_setsyncschedule: 
Sets the repo sync schedule for a software channel

usage: softwarechannel_setsyncschedule <CHANNEL> <SCHEDULE>
Options:
    -e/--no-errata : Do not sync errata
    -f/--fail : Terminate upon any error
    -k/--sync-kickstart : Create kickstartable tree
    -l/--latest : Only download latest package versions when repo syncs

The schedule is specified in Quartz CronTrigger format without enclosing quotes.
For example, to set a schedule of every day at 1am, <SCHEDULE> would be 0 0 1 * * ?
If <SCHEDULE> is left empty, it will be disabled.

# echo $?
0


This makes it hard to implement with Config Management tools like Ansible.

Should I open a new bug about it?

Comment 3 Tomáš Kašpárek 2018-05-29 06:00:51 UTC
If you'd be so kind, please open a new bug regarding the exit code, I'd appreciate that.

Also if you could state if the exit code is always zero (even for other failing commands) that would be great information for me to begin with.

Comment 4 Michael Mráka 2018-11-26 09:43:51 UTC
Move Spacewalk 2.9 bugs ON_QA.

Comment 5 Michael Mráka 2019-01-15 07:59:22 UTC
Spacewalk 2.9 has been released.
https://github.com/spacewalkproject/spacewalk/wiki/ReleaseNotes29