Bug 817484 - delete-old-systems-interactive does not work
delete-old-systems-interactive does not work
Status: CLOSED CURRENTRELEASE
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Other (Show other bugs)
541
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Michael Mráka
Dimitar Yordanov
:
Depends On:
Blocks: sat550-lowbug
  Show dependency treegraph
 
Reported: 2012-04-30 04:50 EDT by Dimitar Yordanov
Modified: 2012-09-21 05:33 EDT (History)
3 users (show)

See Also:
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 05:33:38 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Script with all the fixes. (4.70 KB, application/octet-stream)
2012-05-02 07:44 EDT, Dimitar Yordanov
no flags Details
Fixed Script Final. (4.92 KB, application/octet-stream)
2012-06-21 16:08 EDT, Dimitar Yordanov
no flags Details

  None (edit)
Comment 1 Tomas Lestach 2012-05-02 05:00:02 EDT
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 07:43:25 EDT
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 07:44:51 EDT
Created attachment 581590 [details]
Script with all the fixes.
Comment 4 Tomas Lestach 2012-05-28 08:33:36 EDT
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 08:21:15 EDT
Fixed in spacewalk master by
commit babadbfbc3036036a389788f311eaf38d8baf9ee
    system.list_user_systems() now returns localtime
Comment 7 Michael Mráka 2012-06-14 08:26:52 EDT
Backported to SATELLITE-5.5 as
commit 9e9d4315b3e243d84c75552b3d446165479d852d
    system.list_user_systems() now returns localtime
Comment 9 Dimitar Yordanov 2012-06-21 16:08:16 EDT
Created attachment 593574 [details]
Fixed Script Final.
Comment 10 Michael Mráka 2012-08-06 05:34:33 EDT
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 05:35:18 EDT
Backported to SATELLITE-5.5 as
commit fabff987e299bb98c1816c15df171ff42f67e0ab
    817484 - strip non-number chars from date format
Comment 14 Jan Pazdziora 2012-08-06 14:03:47 EDT
(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 03:42:58 EDT
Fixed typo in spacewalk master
commit d0b5a97f0258ae020f5b0500ed406a1b4e8d9d62
    817484 - fixed typo
Comment 16 Michael Mráka 2012-08-09 04:06:58 EDT
Backported to SATELLITE-5.5
commit dabdb6fe940aa95c1e19c329908174e4d3b1c57b
    817484 - fixed typo
Comment 19 Clifford Perry 2012-09-21 05:33:38 EDT
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

Note You need to log in before you can comment on or make changes to this bug.