Bug 717718

Summary: rhts_post snipped for adding Distro repo has bugs
Product: [Retired] Beaker Reporter: Prudhvi Tella <prudhvi_tella>
Component: lab controllerAssignee: Bill Peck <bpeck>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: 0.6CC: bpeck, dcallagh, mcsontos, rmancy, stl
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-07-14 02:07:19 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Prudhvi Tella 2011-06-29 16:21:53 UTC
Description of problem:
If user passes tree_repos variable via Kickstart Metadata, repourl is not handled properly by rhts_post snippet. Following are the two problems:
1. Delimiter is ':'. This causes the url to be split after 'http'.
2. baseurl=http://$server/distros$repourl. If user passes tree_repos=http://example/RHEL/6/Server/x86_64/os/Server, baseurl prepends additional contents. This generates wrong baseurl.


Version-Release number of selected component (if applicable):
0.6.12-1

How reproducible:
Always

Steps to Reproduce:
1.Add tree_repos variable to Kickstart Metadata
2.Create a job with simple task
3.Look at contents in /etc/yum.repos.d/beaker-distro*
  
Actual results:
Two distro repos are created.
1. baseurl=http://<server>/distroshttp
2. baseurl=http://<server>/distro//RHEL/6/Server/x86_64/os/Server

Expected results:
One distro repo with baseurl=http://example/RHEL/6/Server/x86_64/os/Server

Additional info:
Replacing delimiter ':' with '|' similar to harnessrepos & customrepos fixes issue 1.
Replacing baseurl=http://$server/distros$repourl with baseurl=$repourl fixes issue 2. This is how harnessrepos and customrepos set baseurl.

Comment 1 Bill Peck 2011-06-29 17:35:36 UTC
I can't break our existing tree_repos so the following patch may work.

diff --git a/LabController/snippets/rhts_post b/LabController/snippets/rhts_post
index c361562..79d5de0 100644
--- a/LabController/snippets/rhts_post
+++ b/LabController/snippets/rhts_post
@@ -57,9 +57,17 @@ popd
 #end if
 
 # Add Distro Repos
-#if $getVar('tree_repos','') != ''
+#set $tree_repos = $getVar('tree_repos','')
+#if $tree_repos != ''
+#if $tree_repos.find("http://") != -1
+#set $split = "|"
+#set $base = ""
+#else
+#set $split = ":"
+#set $base = "http://$server/distros""
+#end if
 #set $i = 0
-#for $repo in $getVar('tree_repos','').split(':')
+#for $repo in $getVar('tree_repos','').split($split)
 #set $i = $i + 1
 #if $repo.find(",") != -1
 #set (reponame, repourl) = $repo.split(',',1)
@@ -70,7 +78,7 @@ popd
 cat << EOF > /etc/yum.repos.d/${reponame}.repo
 [$reponame]
 name=$reponame
-baseurl=http://$server/distros$repourl
+baseurl=$base$repourl
 enabled=1
 gpgcheck=0
 skip_if_unavailable=1


Posting to for feedback.  This has not been tested.

Comment 2 Prudhvi Tella 2011-06-29 19:10:14 UTC
This works for me. there is one small bug here:
+#set $base = "http://$server/distros""
double quotes at the end.

The above bug caused cobbler to not generate a proper kickstart file. Also, even though kickstart file was not generated, the job kept running instead of failing. Maybe another bug to file?

Comment 3 Bill Peck 2011-06-29 19:25:40 UTC
I'll fix the double quote mistake.  Thanks for testing it.

The job would have failed when the watchdog timed out ( should be 20 minutes I believe).  Unless beaker-watchdog was not running of course.

Comment 4 Prudhvi Tella 2011-06-29 19:35:28 UTC
I didn't wait for 20 minutes :)

Comment 5 Bill Peck 2011-07-01 21:05:48 UTC
pushed to gerrit for review