[katello-devel] Using id from Katello instead of from CP for identifying product

Tomas Strachota tstrachota at redhat.com
Wed Feb 1 14:00:45 UTC 2012


On 02/01/2012 02:11 PM, Ivan Nečas wrote:
> Hello,
>
> Bug [1] showed that using ID from candlepin is not the best way to
> identify a product. Everything is ok until there are more organizations
> with the same product. For example, importing manifest in two
> organizations leads to having one Candlepin product (let's say 69 - Red
> Hat Enterprise Server), but two products in Katello (which differ in
> assigned organization). Therefore cp_id itself is not good for using for
> referencing product.
>
> This facts is causing troubles in API
> A. in request paths (e.g. GET api/products/:id)
> B. in POST data (e.g. POST
>
> There are 2 approaches to solving this problem:
>
> 1. Keeping in using CP id for referencing product and transform API in
> this way:
>
> GET /products/:id -> GET /organizations/:organization_id/products/:id
>
> The problem B would be solved by using the organization context form the
> call (there is organization available almost at every call)
>
> 2. Using id from Katello products table to identify and reference
> products in API calls. This wouldn't require changing paths of the
> current API. Only id attribute in JSON of product would be changed from
> cp_id to id. In case somebody would still need to find product by cp_id,
> there is a call:
>
> GET /organizations/organization_id/products?cp_id=69
>
> I prefer the 2. solution, because it's easier to implement and there is
> lower chance in future that we will mistakenly use
> "Product.find_by_cp_id(params[:product_id]" and get a record for
> different organization - it doesn't cream at you unless testing with
> more organizations.
>
> I've checked calls from subscription-manager and it doesn't seem to use
> any of the paths that will be affected by this change.
>
> What do you think?

If there's no subscription-manager compatibility problem I vote for 
start using AR id. It will make things clearer. Id should be uniqe.

 From the CLI point of view it shouldn't mean any change. In api/model 
layer it's only replacing find_by_cp_id for find in controllers and fix 
spec tests, right?

>
> [1] - https://bugzilla.redhat.com/show_bug.cgi?id=768254
>
> _______________________________________________
> katello-devel mailing list
> katello-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/katello-devel




More information about the katello-devel mailing list