Bug 484481 - [PATCH] fix for inconsistency in generation rule of cloned errata advisory names
[PATCH] fix for inconsistency in generation rule of cloned errata advisory names
Status: CLOSED CURRENTRELEASE
Product: Spacewalk
Classification: Community
Component: WebUI (Show other bugs)
0.5
All Linux
low Severity medium
: ---
: ---
Assigned To: Justin Sherrill
Clifford Perry
:
Depends On:
Blocks: space05
  Show dependency treegraph
 
Reported: 2009-02-06 22:58 EST by Clifford Perry
Modified: 2009-09-17 03:10 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 485020 (view as bug list)
Environment:
Last Closed: 2009-09-17 03:10:03 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
An experimental patch #1 (1.04 KB, patch)
2009-02-08 20:31 EST, Satoru SATOH
no flags Details | Diff
Yet another patch (#2) (1.12 KB, patch)
2009-02-08 20:44 EST, Satoru SATOH
no flags Details | Diff

  None (edit)
Description Clifford Perry 2009-02-06 22:58:27 EST
Description of problem:

-------- Original Message --------
Subject: [Spacewalk-devel] Re: [PATCH] Experimental fix for inconsistency in	generation rule of cloned errata advisory names
Date: Fri, 6 Feb 2009 17:14:33 +0900
From: Satoru SATOH <satoru.satoh@gmail.com>
Reply-To: spacewalk-devel@redhat.com
To: spacewalk-devel@redhat.com
References: <20081217094504.GA4196@localhost.localdomain>

Hi,

Sorry, my patch was completely broken. Here is a revised one.

I confirmed it works as expected with satellite-5.2.0 at least.  I'm not
sure about spacewalk but it should be the same, I guess.

Could you anyone please look at it?

- satoru

On Wed, Dec 17, 2008 at 06:45:04PM +0900, Satoru SATOH wrote:
> I and my associate came across an inconsistency in advisory name
> generation rule while trying to cloning errata in rhn-satellite. And I
> found that spacewalk also has this inconsistency between the following
> codes.
> 
>  a. ErrataFactory.createClone in
>     java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java
> 
>  b. PublishErrataHelper.cloneErrataFast in
>     java/code/src/com/redhat/rhn/frontend/action/channel/manage/PublishErrataHelper.java
> 
>  c. find_next_advisory in web/modules/rhn/RHN/DB/ErrataEditor.pm
> 
> The rule in a and b (both are in java) looks the same but c (perl) is
> completely different from them.
> 
>  a and b: CLSA-2008:0580 -> CLSA-2008:0580-1, CLSA-2008:0580-2, ... 
> 
>  c: CLSA-2008:0580 -> CMSA-2008:0580, CNSA-2008:0580, ...,
>     RISA-2008:0580, ... ZZSA-2008:0580, AAASA-2008:0580, ...
> 
> Here is an experimental fix for this issue to change c's rule, not
> tested in actual. (i'm not a perl monger so that it even might have
> errors and not work).


 web/modules/rhn/RHN/DB/ErrataEditor.pm |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/web/modules/rhn/RHN/DB/ErrataEditor.pm b/web/modules/rhn/RHN/DB/ErrataEditor.pm
index d19d2b0..75dc1d0 100644
--- a/web/modules/rhn/RHN/DB/ErrataEditor.pm
+++ b/web/modules/rhn/RHN/DB/ErrataEditor.pm
@@ -303,17 +303,24 @@ EOQ
 sub find_next_advisory {
   my $adv = shift || '';
   my $adv_name = shift || '';
+  my $suffix = '';
+  my $i = 1;
 
   substr($adv, 0, 2) = 'CL';
   substr($adv_name, 0, 2) = 'CL';
 
-  while (advisory_exists($adv)) {
-    substr($adv, 0, 2)++;
-  }
+  if (advisory_exists($adv) || advisory_name_exists($adv_name)) {
+    $suffix = sprintf("-%u", $i++);
+    $adv = $adv . $suffix;
+    $adv_name = $adv_name . $suffix;
 
-  while (advisory_name_exists($adv_name)) {
-    substr($adv_name, 0, 2)++;
+    while (advisory_exists($adv) || advisory_name_exists($adv_name)) {
+      substr($adv, -1, 1) = $i;
+      substr($adv_name, -1, 1) = $i;
+      $i++;
+    }
   }
+
   return ($adv, $adv_name);
 }
 

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel
Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:
Comment 1 Satoru SATOH 2009-02-08 20:31:16 EST
Created attachment 331265 [details]
An experimental patch #1

This is same as the patch I posted on spacewalk-devel list. This will make the perl version to behave likewise the jave codes do. That is,

  Original Errata:  RH?A-xxxxxx
  => Cloned Errata: CL?A-xxxxxx, CL?A-xxxxxx-1, CL?A-xxxxxx-2, ...
Comment 2 Satoru SATOH 2009-02-08 20:44:57 EST
Created attachment 331266 [details]
Yet another patch (#2)

This is similar to the previous patch but somewhat different.
I'm not sure which is the wanted behavior so that post it for the record.

I found that java code actually takes a character denotes the advisory type of the errata away.

Example:

  Original Errata:  RH?A-xxxxxx
  => Cloned Errata: CLA-xxxxxx, CLA-xxxxxx-1, CLA-xxxxxx-2, ...


This patch mimics that way.
Comment 3 Satoru SATOH 2009-02-08 21:08:32 EST
Steps to reproduce:

Clone RH Errata in different ways. (I do not try this in spacewalk actually.)

Java?: RH?A-xxxxxx -> CLA-xxxxx-1, CLA-xxxxx-2, ...

    [Channels] (top navigation) 
 -> [Manage Software Channels] (left navigation) 
 -> Select and click [Channel Name] (from channel name list)
 -> [Errata] (center top)
 -> [Add]
 

Perl?: RH?A-xxxxxx -> CLMA-xxxxxx -> CLNA-xxxxxxx, ...

    [Channels]
 -> [Manage Software Channels]
 -> Select and click [Channel Name] (from channel name list)
 -> [Errata] (center top)
 -> [Clone]
 -> [Action] ("Merge with ..." or "Clone as ...")
Comment 4 Justin Sherrill 2009-02-11 11:26:50 EST
Looks good to me:

commit	8d5550f29cf052958eb2291725878c59c2ba36eb
tree	4beafefb4ff884ccc9cccaa18cb129c46488d4f8	
parent	1d79674358481ebb0b71c54d3e17bf094f900e2e
Comment 5 Justin Sherrill 2009-02-11 12:25:39 EST
Oh, just now saw the 2nd patch.  Applied it and made a slight modification

  $adv = 'CL' . substr($adv, 2);
  $adv_name = 'CL' . substr($adv_name, 2);


commit	743fca7ef6ac09be2c1d2a1969482d5497d8ff5f
tree	a543ad84868482e353264aab716db24752edaca9
parent	27a209ec912b96aa3bb0757ceac2f23f6161d418
Comment 6 Brandon Perkins 2009-02-12 02:21:00 EST
Removing bug 484481 blocks bug 485020.
Comment 7 Jesus M. Rodriguez 2009-04-14 10:12:46 EDT
Spacewalk 0.5 released.
Comment 8 Miroslav Suchý 2009-09-17 03:10:03 EDT
Spacewalk 0.5 has been released for long time ago.

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