[katello-devel] Pre-save and post-save queues in glue layer

Ivan Nečas inecas at redhat.com
Thu Jan 26 09:18:44 UTC 2012


On 01/26/2012 10:14 AM, Tomas Strachota wrote:
> On 01/26/2012 09:56 AM, Ivan Nečas wrote:
>> Hi,
>>
>> After GPG keys orchestration, I'm working on another task where we need
>> to do some action after saving a record to our database: we create
>> environment in Katello and then in Candlepin (we are sending there our
>> environment_id.
>>
>> Like it was pointed out before, in current state all the orchestration
>> happens before the record is saved:
>>
>> def on_save
>> process queue
>> yield if block_given?
>> @orchestration_for = nil
>> end
>>
>> I suggest to rename our current queue to pre_queue (which means to
>> happen before saving) and post_queue (after saving). So the on_save
>> around filter would look like this:
>>
>> def on_save
>> process pre_queue
>> yield if block_given?
>> process post_queue
>> @orchestration_for = nil
>> end
>>
>> I've already tested it in my branch, and it looks it serves our
>> purposes. We don't have to worry about record being created before some
>> orchestrations fails: on_save runs whole in transaction and when
>> something is wrong, it rolls back the insertion. From my sql log after
>> simulating an error after saving:
>>
>> SQL (6.7ms) INSERT INTO "providers" ("created_at", "updated_at",
>> "organization_id", "provider_type", "repository_url", "name",
>> "description") VALUES ('2012-01-26 08:52:44.664467', '2012-01-26
>> 08:52:44.664467', 1, 'Custom', NULL, 'katello', NULL) RETURNING "id"
>> SQL (0.1ms) ROLLBACK
>>
>>
>> I would like to get some team ACK before actually implementing the whole
>> change, incluiding renaming the original queue. Any suggestions on
>> better naming etc. welcomed.
>>
>> -- Ivan
>>
>
> I like the idea of having two queues.
> But one question: If the post_queue fails, are actions from pre_queue 
> rollbacked as well?
>
Good point - I will have it in mind. Maybe post_queue must be aware of 
what it is, and when roll-backing itself, it should also invoke rollback 
on the pre_queue

-- Ivan
> Tomas


-- 
Regards,

  Ivan Necas
  Red Hat Czech s.r.o. Brno




More information about the katello-devel mailing list