OSC / ood_core

Open OnDemand core library
https://osc.github.io/ood_core/
MIT License
10 stars 28 forks source link

Dashboard: Add validation of cluster configs during application load and as a separate Rake task #611

Closed sync-by-unito[bot] closed 2 years ago

sync-by-unito[bot] commented 2 years ago

We have a rake task that is helpful for testing the configuration: https://osc.github.io/ood-documentation/master/installation/resource-manager/test.html (https://github.com/OSC/ood-dashboard/blob/master/lib/tasks/test.rake)

We should probably add a similar rake tasks validate.rake to validate the cluster config run via rake: validate:clusters. The test:jobs rake task could be updated to depend on the validate:clusters task, so the documentation will not have to change, but more helpful information could display.

Also, the new rake task could accept an optional argument that could be a path to a single cluster config file or a path to a directory of cluster config files (i.e. rake validate:clusters[/path/to/file/or/dir]).

The validation could be done by converting the YAML to JSON and then validating the JSON using http://json-schema.org/. Here is a Ruby implementation: https://github.com/davishmcclurg/json_schemer

If we did this it would be important to add system tests to have the dashboard's automated tests invoke this validation Rake task (or execute the same code that the Rake task does) so that we can keep the schema up to date.

This validation could also be run when the cluster configs are first parsed, and if a problem occurs, hopefully more helpful error messages could be created.

The goal would be to help admins properly format their cluster config files and avoid painful but easy to produce mistakes like https://github.com/OSC/ood-dashboard/issues/395#issuecomment-423666437 (note - this has happened several times already so it is important to fix).

┆Issue is synchronized with this Asana task by Unito

sync-by-unito[bot] commented 2 years ago

➤ Eric Franz commented:

treydock just curious if you have any thoughts on the proposed implementation since you deal with managing these in Puppet

sync-by-unito[bot] commented 2 years ago

➤ Eric Franz commented:

AriettaZ I wonder if instead of "validate:clusers" it should be "test:cluster_config"? Even though it is a misnomer, when you do a rake -T you will see test:jobs and test:cluster_config side by side I think.

sync-by-unito[bot] commented 2 years ago

➤ Eric Franz commented:

The validation should do these two things:

sync-by-unito[bot] commented 2 years ago

➤ treydock commented:

I wouldn't use validation directly in Puppet but define the valid configuration in Puppet. Also having dealt with YAML validation in Hiera I can say that simply trying to load the YAML file should return useful information about where the invalid portion exists. I've used this: https://github.com/voxpupuli/puppet-syntax/blob/master/lib/puppet-syntax/tasks/puppet-syntax.rb#L89

https://github.com/voxpupuli/puppet-syntax/blob/master/lib/puppet-syntax/hiera.rb#L78