Validate only kubernetes objects using JSON schema
Issue: Add a background DB migration to populate the w... (#538360 - closed)
What does this MR do and why?
After merging Add files from RemoteDevelopment module for mig... (!199244 - merged) • Ashvin Sharma • 18.3 and dry running the migration, we found out multiple workspaces that do not pass our validations. I have written about them in detail here.
TL;DR of above link is that our validations did not cover all the cases of a desired_config
. And this MR fixes that. Below is the summary of the changes.
Validate only kubernetes objects using JSON schema
Unlike previously, when the sequence in the array was also validated. This is done because JSON schema cannot handle validate an array for relative ordering of elements when there are arbitrary amount of items present. In other words, unless we do not know the exact amount of items order of the items in an array cannot be validated.
References
- Add files from RemoteDevelopment module for mig... (!199244 - merged) • Ashvin Sharma • 18.3
- #538360 (comment 2669955776)
Screenshots or screen recordings
This is not a UI change.
How to set up and validate locally
-
In rails console
json_str="<copy/paste the contents of any of the below file> desired_config = RemoteDevelopment::WorkspaceOperations::DesiredConfig.new(desired_config_array: Gitlab::Json.parse(json_str)) desired_config.valid?
-
All of these files should return
true
dc-without-network-policy.json
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.