Bug 1114044

Summary: creating kickstart distribution with same label across two different orgs results in ISE during download
Product: Red Hat Satellite 5 Reporter: Shannon Hughes <shughes>
Component: WebUIAssignee: Stephen Herr <sherr>
Status: CLOSED CURRENTRELEASE QA Contact: Pavel Studeník <pstudeni>
Severity: medium Docs Contact:
Priority: medium    
Version: 560CC: cperry, lhellebr, pstudeni, xdmoon
Target Milestone: ---Keywords: Patch
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-01-22 09:10:54 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: 1127215    
Attachments:
Description Flags
patch to fix media_path for custom kickstart distributions none

Description Shannon Hughes 2014-06-27 14:25:53 UTC
Description of problem:

Creating a custom kickstart distribution using the same label for two different orgs results in an ISE during the download of the kicsktart tree files. 

org.hibernate.NonUniqueResultException: query did not return a unique result: 2
	at org.hibernate.impl.AbstractQueryImpl.uniqueElement(AbstractQueryImpl.java:844)
	at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:835)
	at com.redhat.rhn.domain.kickstart.KickstartFactory.lookupKickstartTreeByLabel(KickstartFactory.java:645)
	at com.redhat.rhn.frontend.action.common.DownloadFile.handleKickstartDownload(DownloadFile.java:269)
	at com.redhat.rhn.frontend.action.common.DownloadFile.execute(DownloadFile.java:125)
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
	... 40 more

It appears we are using a hiberate query to select by label only and not by label/org_id

currently investigating and plan on proposing a patch.

Comment 2 Shannon Hughes 2014-06-27 20:39:49 UTC
Created attachment 912958 [details]
patch to fix media_path for custom kickstart distributions

Comment 4 Stephen Herr 2014-07-15 20:30:45 UTC
Committing to Spacewalk master:
cd0a7132d6fe8a1b24f6078bd079e9757db1f2bc

Note that this will fix Kickstart Distributions that are created / modified in the future, but not currently existing Distributions.

Comment 5 Stephen Herr 2014-07-15 23:11:59 UTC
And Checkstyle fix:
789f173e74eacc279b9b3ece5506cdb4a3996055

Comment 7 Pavel Studeník 2014-09-23 12:31:14 UTC
Reproducer:

1. create first organization A
 a) download image to server and create distribution "Fedora-21" in A org
 b) create new kickstart with this distribution in org B

2. create second organization B
 a) create new distribution "Fedora-21" in B org
 b) create new kickstart with this distribution in org B

3) Try to provision system with this kickstart or go to web page
 a) /ks/dist/Fedora-21 (ISE 500)
 b) /ks/dist/org/2/Fedora-21 (ISE 500)
 c) /ks/dist/org/1/Fedora-21 (ok)

Comment 10 Lukáš Hellebrandt 2015-01-21 13:02:29 UTC
Re-verified
spacewalk-java-2.3.8-96

Used reproducer from comment 7. Do not use its last a,b,c) part as this part of the reproducer is wrong.

Kickstart file now contains "url --url http://<fqdn>/ks/dist/org/<org_id>/<ks_label>" instead of http://<fqdn>/ks/dist/<ks_label>