Bug 790602

Summary: Updating a sync plan fails after repo synchronization
Product: [Retired] Pulp Reporter: Tomas Strachota <tstrachota>
Component: user-experienceAssignee: Jason Connor <jconnor>
Status: CLOSED CURRENTRELEASE QA Contact: Preethi Thomas <pthomas>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 1.0.0CC: jconnor, mmccune, skarmark
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Tomas Strachota 2012-02-14 22:13:29 UTC
Description of problem:
After a repo synchronization first attempt to assign synchronization schedule with start date in past fails. Second attempt goes ok.


Steps to Reproduce:
1. create new repo
2. start synchronization and wait until it finishes
3. curl -H "Content-Type: application/json" -H "Accept: application/json" -# -X PUT -d {"schedule": "2012-01-01T09:00:00+01:00/P1D"} -k -u admin:admin https://localhost/pulp/api/repositories/REPO_ID/schedules/sync/

  
Actual results:
Fails with stacktrace.

Expected results:
Should schedule new synchronization at next possible time in future.

Additional info:

Comment 1 Tomas Strachota 2012-02-14 22:13:47 UTC
Relevant part of pulp.log:

2012-02-14 22:41:19,342 7848:139733086738176: pulp:WARNING: scheduler:122 IntervalScheduler created with start time more than one interval in the past: 2012-01-01 09:00:00+01:00, 1 day, 0:00:00
2012-02-14 22:41:19,343 7848:139733086738176: pulp.server.webservices.controllers.decorators:ERROR: decorators:52 Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/controllers/decorators.py", line 48, in report_error
    return method(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/controllers/decorators.py", line 127, in _auth_decorator
    value = method(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/controllers/repositories.py", line 753, in PUT
    scheduled_sync.update_repo_schedule(repo, new_schedule, new_options)
  File "/usr/lib/python2.7/site-packages/pulp/server/api/scheduled_sync.py", line 254, in update_repo_schedule
    _update_repo_scheduled_sync_task(repo, task)
  File "/usr/lib/python2.7/site-packages/pulp/server/api/scheduled_sync.py", line 201, in _update_repo_scheduled_sync_task
    return async.reschedule_async(task, new_scheduler)
  File "/usr/lib/python2.7/site-packages/pulp/server/async.py", line 106, in reschedule_async
    return _queue.reschedule(task, scheduler)
  File "/usr/lib/python2.7/site-packages/pulp/server/tasking/taskqueue/queue.py", line 387, in reschedule
    self.enqueue(task)
  File "/usr/lib/python2.7/site-packages/pulp/server/tasking/taskqueue/queue.py", line 262, in enqueue
    task.schedule() # UnscheduledTaskException
  File "/usr/lib/python2.7/site-packages/pulp/server/tasking/task.py", line 382, in schedule
    _log.warn(_('%s missed %d scheduled runs') % (str(self), adjustments - 1))
  File "/usr/lib/python2.7/site-packages/pulp/server/tasking/task.py", line 213, in __str__
    return 'Task %s: %s(%s, %s)' % (self.id, _name(), _args(), _kwargs())
  File "/usr/lib/python2.7/site-packages/pulp/server/tasking/task.py", line 199, in _kwargs
    return ', '.join(['='.join((str(k), str(v))) for k, v in self.kwargs.items()])
AttributeError: 'NoneType' object has no attribute 'items'

Comment 2 Jason Connor 2012-02-15 17:40:32 UTC
made the mistake of using the raw options sent up from the client on the first run, fixed pushed in 68a796a2240231aad36159b4133e88b8d8d7d827

Comment 3 Jeff Ortel 2012-02-17 17:17:43 UTC
build: 0.267

Comment 4 Jason Connor 2012-02-17 20:15:35 UTC
to test this bug, you'll need to do a PUT to the following uri path:
/pulp/api/repo/<repo id>/schedules/sync/
In the body of the put, you should set the field 'options' to null (None in python)

Further information can be found here:
https://fedorahosted.org/pulp/wiki/UGREST-Repositories#ScheduleCreateorReplace

Comment 5 Preethi Thomas 2012-02-17 21:13:55 UTC
[root@preethi ~]# rpm -q pulp
pulp-0.0.267-1.fc15.noarch


[root@preethi ~]# pulp-admin repo create --id=pulp --feed=http://repos.fedorapeople.org/repos/pulp/pulp/v1/testing/6Server/x86_64/
Successfully created repository [ pulp ]

[root@preethi ~]# pulp-admin repo sync --id=pulp  -F
Sync for repository pulp started
Sync: Finished
20/20 new items downloaded
0/20 existing items processed

Item Details: 
RPMs: 20/20

[root@preethi ~]# 
[root@preethi ~]# 
[root@preethi ~]# 
[root@preethi ~]#  curl -H "Content-Type: application/json" -H "Accept: application/json" -# -X  PUT -d '{"schedule": "2012-01-01T09:00:00+01:00/P1D"}' -k -u admin:admin https://localhost/pulp/api/repositories/pulp/schedules/sync/
{"href": "/pulp/api/repositories/pulp/", "options": {}, "id": "pulp", "schedule": "2012-01-01T03:00:00-05:00/P1D"}[root@preethi ~]# 
[root@preethi ~]# 
[root@preethi ~]# 
[root@preethi ~]# 
[root@preethi ~]# 
[root@preethi ~]# pulp-admin repo create --id=spacewalk --feed=http://spacewalk.redhat.com/yum/1.6/Fedora/16/x86_64/ 
Successfully created repository [ spacewalk ]

[root@preethi ~]# pulp-admin repo sync --id=spacewalk  -FSync for repository spacewalk started
Sync: Finished
130/130 new items downloaded
0/130 existing items processed

Item Details: 
RPMs: 130/130

[root@preethi ~]#  curl -H "Content-Type: application/json" -H "Accept: application/json" -# -X  PUT -d '{"schedule": "2012-01-01T09:00:00+01:00/P1D"}' -k -u admin:admin https://localhost/pulp/api/repositories/spacewalk/schedules/sync/
{"href": "/pulp/api/repositories/spacewalk/", "options": {}, "id": "spacewalk", "schedule": "2012-01-01T03:00:00-05:00/P1D"}[root@preethi ~]#

Comment 6 Preethi Thomas 2012-02-24 20:17:56 UTC
Pulp v1.0 is released
Closed Current Release.

Comment 7 Preethi Thomas 2012-02-24 20:18:41 UTC
Pulp v1.0 is released.