cbrain icon indicating copy to clipboard operation
cbrain copied to clipboard

Add new consistency check at boot time: Userfile and CbrainTask classes verification

Open prioux opened this issue 4 years ago • 4 comments

Add a new boot-time validation method to check that all the 'type' columns of our single table inheritance models represent ruby classes that are properly loaded.

For tasks, that would be:

not_loaded = CbrainTask.group(:type).pluck(:type).select do |name|
    (name.constantize rescue nil) ? nil : name
end

prioux avatar Jul 23 '20 15:07 prioux

Data-providers should be included too?

@prioux Actually there is a benefit in not having that feature. When one works on several features/PR in the same time, and some of them involve new tasks or userfiles, it is not necessary to wipe up to database after branch switch. Maybe not the case with you, but Natacha, most likely, integrates or tests few new tools in the same time.

Well, if still needed, please confirm

MontrealSergiy avatar Jan 29 '24 17:01 MontrealSergiy

I want that check at boot time, it is an important piece of information. In developement, maybe print a warning about the classes; in production, stop the boot process entirely.

Since not all CbrainTask classes are deplpyed on the Bourreaux, the check for the types for the cbrain_tasks table should be restricted to those rows which have an ID matching the current app.

For userfiles and data providers, it must be a fatal error always.

prioux avatar Jan 29 '24 17:01 prioux

@prioux can you clarify

"ID matching the current app rows which have an ID matching the current app"

Do you suggest restrict by bourreau_id == current_bourreau.id ?

Since not all CbrainTask classes are deplpyed on the Bourreaux, the check for the types for the cbrain_tasks table should be restricted to those rows which have an ID matching the current app.

MontrealSergiy avatar Feb 02 '24 17:02 MontrealSergiy

Yes exactly.

prioux avatar Feb 02 '24 17:02 prioux