Bug 817484

Summary: delete-old-systems-interactive does not work
Product: Red Hat Satellite 5 Reporter: Dimitar Yordanov <dyordano>
Component: OtherAssignee: Michael Mráka <mmraka>
Status: CLOSED CURRENTRELEASE QA Contact: Dimitar Yordanov <dyordano>
Severity: medium Docs Contact:
Priority: medium    
Version: 541CC: cperry, jpazdziora, mmraka
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: spacewalk-utils-1.7.15-35 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-09-21 09:33:38 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: 819081    
Attachments:
Description Flags
Script with all the fixes.
none
Fixed Script Final. none

Comment 1 Tomas Lestach 2012-05-02 09:00:02 UTC
I checked the system.list_user_systems query and basically it's the same since ages. Only minor changes were done to make it work with PostgreSQL.

I'm afraid that the reproducer isn't sufficient.

It's always better to write the BZ overview as the summary.

Comment 2 Dimitar Yordanov 2012-05-02 11:43:25 UTC
I am not sure that it I provide reproducer it will work for you.
I tried to use the tool and I noticed that profiles that should be removed from the script are not removed.
I looked into the code and what I discovered was that there is a comparison between GMT local time and EDT time returned from the "system.list_user_systems" API call.

I did the following changes in order the script to work correctly if Satellite runs on localhost.


#my ($sec, $min, $h, $d, $m, $y) = gmtime($not_before);
my ($sec, $min, $h, $d, $m, $y) = localtime($not_before);

my $cutoff = sprintf '%04d%02d%02dT%02d:%02d:%02d',
				$y + 1900,$m + 1, $d, $h, $min, $sec;
#print "Lookup on [$host] systems with last checkin before [$cutoff] GMT\n";
print "Lookup on [$host] systems with last checkin before [$cutoff] \n";

my $client = new Frontier::Client(url => "http://$host/rpc/api", debug=>0);
my $session = $client->call('auth.login', $username, $passwd)
	or die "Failed to login to [$host]\n";

my $systems = $client->call('system.list_user_systems', $session);
$systems = [
	sort { $a->{last_checkin} cmp $b->{last_checkin} }
	map { if (ref $_->{last_checkin}) {
		$_->{last_checkin} = $_->{last_checkin}->value
	} else {
		$_->{last_checkin} =~ s/-//g;
	}; $_;} @$systems
]; 


For all the changes that I made please see attachment.

Comment 3 Dimitar Yordanov 2012-05-02 11:44:51 UTC
Created attachment 581590 [details]
Script with all the fixes.

Comment 4 Tomas Lestach 2012-05-28 12:33:36 UTC
Miroslav, would you, please check, whether Dimitar's changes of utils/delete-old-systems-interactive are acceptable?

Comment 6 Michael Mráka 2012-06-14 12:21:15 UTC
Fixed in spacewalk master by
commit babadbfbc3036036a389788f311eaf38d8baf9ee
    system.list_user_systems() now returns localtime

Comment 7 Michael Mráka 2012-06-14 12:26:52 UTC
Backported to SATELLITE-5.5 as
commit 9e9d4315b3e243d84c75552b3d446165479d852d
    system.list_user_systems() now returns localtime

Comment 9 Dimitar Yordanov 2012-06-21 20:08:16 UTC
Created attachment 593574 [details]
Fixed Script Final.

Comment 10 Michael Mráka 2012-08-06 09:34:33 UTC
Fixed in spacewalk master as
commit 8018f8d70ccb0070678f0c968ca3b4b5d5663e7e
    817484 - strip non-number chars from date format
    because we compare dates as numbers

Comment 11 Michael Mráka 2012-08-06 09:35:18 UTC
Backported to SATELLITE-5.5 as
commit fabff987e299bb98c1816c15df171ff42f67e0ab
    817484 - strip non-number chars from date format

Comment 14 Jan Pazdziora 2012-08-06 18:03:47 UTC
(In reply to comment #10)
> Fixed in spacewalk master as
> commit 8018f8d70ccb0070678f0c968ca3b4b5d5663e7e
>     817484 - strip non-number chars from date format
>     because we compare dates as numbers

This is not true. We do "lt" which is string operation. The whole "let's remove non-numbers and compare as numeric values" is wrong.

Please revert the commit 8018f8d70ccb0070678f0c968ca3b4b5d5663e7e.

Comment 15 Michael Mráka 2012-08-09 07:42:58 UTC
Fixed typo in spacewalk master
commit d0b5a97f0258ae020f5b0500ed406a1b4e8d9d62
    817484 - fixed typo

Comment 16 Michael Mráka 2012-08-09 08:06:58 UTC
Backported to SATELLITE-5.5
commit dabdb6fe940aa95c1e19c329908174e4d3b1c57b
    817484 - fixed typo

Comment 19 Clifford Perry 2012-09-21 09:33:38 UTC
This issue is resolved with the release of RHN Satellite 5.5. 

As of September 20th 2012, RHN Satellite 5.5 has been generally available. 

Release Notes and other 5.5 documentation can be found here:

 https://access.redhat.com/knowledge/docs/Red_Hat_Network_Satellite/

The associated Errata for the 5.5 release are:

5.5 Satellite GA Errata
 - http://rhn.redhat.com/errata/RHEA-2012-1296.html

5.5 Upgrade Errata
 - http://rhn.redhat.com/errata/RHEA-2012-1298.html

5.5 RHN Proxy GA Errata
 - http://rhn.redhat.com/errata/RHEA-2012-1297.html

5.5 RHN Tools GA Errata
 - http://rhn.redhat.com/errata/RHEA-2012-1299.html

Regards,
Clifford
- Engineering Manager, Satellite