Bug 824583

Summary: spacewalk-clone-by-date fails with traceback.
Product: [Community] Spacewalk Reporter: Stephen Herr <sherr>
Component: ClientsAssignee: Stephen Herr <sherr>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: low Docs Contact:
Priority: unspecified    
Version: 1.8CC: dyordano, jpazdziora
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: spacewalk-utils-1.8.16-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 817410 Environment:
Last Closed: 2012-11-01 16:20:04 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: 817410    
Bug Blocks: 871344    

Description Stephen Herr 2012-05-23 19:12:37 UTC
+++ This bug was initially created as a clone of Bug #817410 +++

Description of problem:

 spacewalk-clone-by-date fails and generates a traceback when executed to Sat550 with PostgreSQL.
 The problem is not presented on Sat 550 with Oracle.

Version-Release number of selected component (if applicable):
Sat 550 with PostgreSQL.

How reproducible:
100%

Steps to Reproduce:
1. Create a Custom channel with Child channel
2. Create  100 RPM packages (50 base + 50 updates)
3. Push the packages to the Custom channel.
4. Create 50 Errata from the update packages in the Custom channel.
5. Create  100 RPM packages (50 base + 50 updates)
6. Push the packages to the Chiled channel.
7. Create 50 Errata from the update packages in the Custom channel.
8. Execute:
spacewalk-clone-by-date --assumeyes --channel=chann_1 clone-chann_1 --channel=child_chann_1 child_chann_1 --username admin --password admin --to_date=2007-03-06 --blacklist='test-regular-1_chann_1,test-regular-1_child_chann_1' --removelist='test-regular-0_chann_1,test-regular-0_child_chann_1'
  
Actual results:

Copying repodata, please wait.
Solving Dependencies (100): 
________________________________________
######################################## - complete
Processing Dependencies:
________________________________________
######################################## - complete
Traceback (most recent call last):
  File "/usr/bin/spacewalk-clone-by-date", line 205, in <module>
    sys.exit(abs(main() or 0))
  File "/usr/bin/spacewalk-clone-by-date", line 195, in main
    return cloneByDate.main(args)
  File "/usr/share/rhn/utils/cloneByDate.py", line 158, in main
    tree_cloner.prepare()
  File "/usr/share/rhn/utils/cloneByDate.py", line 297, in prepare
    cloner.prepare()            
  File "/usr/share/rhn/utils/cloneByDate.py", line 422, in prepare
    self.errata_to_clone, self.available_errata = self.get_errata()     
  File "/usr/share/rhn/utils/cloneByDate.py", line 506, in get_errata
    if err['issue_date'] <= self.to_date:
TypeError: can't compare offset-naive and offset-aware datetimes

Expected results:
PASS.

Additional info:

Comment 1 Stephen Herr 2012-05-23 19:25:24 UTC
Committed to spacewalk-master: 7e066ddf8b08acc67f2f0eab80545edf600ed728

This error occures only on Postgres because Postgres returns a datetime object with timezone info, whereas Oracle does not. The tool then compares the date with a datetime that does not have timezone info, which is illegal. 

The fix is simply to compare date objects instead of datetime objects. This is safe becuase errata release timestamps are dates anyway, there is no time info associated with them.

Comment 2 Jan Pazdziora 2012-10-30 19:24:42 UTC
Moving ON_QA. Packages that address this bugzilla should now be available in yum repos at http://yum.spacewalkproject.org/nightly/

Comment 3 Jan Pazdziora 2012-11-01 16:20:04 UTC
Spacewalk 1.8 has been released: https://fedorahosted.org/spacewalk/wiki/ReleaseNotes18