Bug 769954 - Repo name provided by the Web UI is used fo the name and label in Candlepin
Summary: Repo name provided by the Web UI is used fo the name and label in Candlepin
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: 6.0.1
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Ivan Necas
QA Contact: Og Maciel
URL:
Whiteboard:
Depends On:
Blocks: katello-blockers
TreeView+ depends on / blocked
 
Reported: 2011-12-22 20:06 UTC by Bryan Kearney
Modified: 2019-09-26 15:56 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-08-22 18:16:10 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Bryan Kearney 2011-12-22 20:06:37 UTC
The label needs to be unique. So, using the second repo named "latest" will cause the following error in candlepin:

Dec 22 19:20:37 [http-8443-1] ERROR org.hibernate.util.JDBCExceptionReporter - Batch entry 0 insert into cp_content (created, updated, contentUrl, gpgUrl, label, metadataExpire, name, requiredTags, type, vendor, id) values ('2011-12-22 19:20:37.671000 -05:00:00', '2011-12-22 19:20:37.671000 -05:00:00', '/custom/systemengine/latest', '', 'latest', NULL, 'latest', NULL, 'yum', 'Custom', '1324599637671') was aborted.  Call getNextException to see the cause.
Dec 22 19:20:37 [http-8443-1] WARN  org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 23505
Dec 22 19:20:37 [http-8443-1] ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: duplicate key value violates unique constraint "cp_content_label_key"
Dec 22 19:20:37 [http-8443-1] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)


I would suggest makeing the label be productName + " " + repo name replacing all spaces with _.

Comment 1 Ivan Necas 2012-01-09 17:21:12 UTC
In candlepin-0.5.8-1 only label must be unique.

It was solved by prefixing the repo name with product id in Katello. It's not ideal, but it works.

productName + " " + repoName is not sufficient because there might be two products with the same name in two organizations. We could add orgName to prefix to be unique, but I'm not sure the lenght is ideal?

Comment 3 Ivan Necas 2012-01-27 11:43:45 UTC
Modified in commit 0c75d7d54772b73d251d74ea0b064acf2689a7ff:

    Changing form of generated label from {product.id}-{repo.name} to
    {org.name}_{product.name}_{repo.name}. The reason is that this label is shown
    in redhat.repo and therefore it should be more user friendly.

The length is not an issue (255 chars should be enough for the whole part).

Comment 4 Lukas Zapletal 2012-02-02 15:00:08 UTC
I am changing it back, but in slightly different order. So instead

{org.name}_{product.name}_{repo.name}

we get

{repo.name}_{self.id}

This is because repo binding/unbinding. We would need to do another query into Candlepin to get a label. Such a service would need to be created first. This format makes it easier.

Comment 5 Lukas Zapletal 2012-02-06 10:10:49 UTC
Ok I am NOT changing the format to "#{repo.name}-#{self.id}".gsub(/\s/,"_").

Keeping Ivan's implementation:

"#{self.organization.name} #{self.name} #{repo.name}".gsub(/\s/,"_")

Comment 6 Og Maciel 2012-02-13 19:41:19 UTC
Ivan/Lukáš, does this validate the issue?

katelloschema=> select distinct cp_label from repositories;
ACME_Corporation_Verne_i386
ACME_Corporation_Brew_Katello
NYDataCenter_Katello_Puddle
 .
 .
 .
 .
rhel-5-server-supplementary-debuginfo
rhel-6-desktop-supplementary-isos
rhel-6-desktop-optional-rpms

Comment 7 Ivan Necas 2012-02-14 07:32:11 UTC
Yes

Comment 8 Og Maciel 2012-02-23 14:45:04 UTC
This has been validated.

Comment 10 Mike McCune 2013-08-16 17:57:22 UTC
getting rid of 6.0.0 version since that doesn't exist


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