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 _.
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?
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).
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.
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/,"_")
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
Yes
This has been validated.
getting rid of 6.0.0 version since that doesn't exist