Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MANOPD-81794 JSON schema implementation #302

Merged
merged 26 commits into from
Jan 19, 2023
Merged

MANOPD-81794 JSON schema implementation #302

merged 26 commits into from
Jan 19, 2023

Conversation

ilia1243
Copy link
Contributor

@ilia1243 ilia1243 commented Dec 5, 2022

Description

  • Inventory files lack of validation especially if variables / sections are specified in unexpected places.

Fixes #304

Solution

  • Added new dependency on jsonschema and JSON schemas to validate inventory file of cluster and of each Kubemarine procedure.
    The JSON schemas are used during KubeMarine run and can be used in IDEs that support YAML validation, i. e. PyCharm, Visual Studio Code.
  • Implemented extended heuristics to show most suitable errors.
  • Added new values section to hold custom variables to be used in Jinja2 templates.
  • Added option --ignore-schema-errors that continues work of Kubemarine even if validation is failed. The option is to be removed in next release.
  • Added "default" and "description" annotations to the JSON schemas.
  • Fixes in list merging strategy related to merging of the procedure inventory and the cluster inventory.
  • Packages enrichment is split into different enrichment procedures to support more robust merging of upgrade procedure inventory and the cluster inventory.
  • Partially revert of [Hot fix]Build and check binary files #305 to fix build with new 3rd-party. Now binary build is again created using custom Dockerfile instead of GitHub action.
  • Different changes in documentation.
  • Fix to make node.name parameter optional.

How to apply

It is necessary to verify inventory file:

  • If it contains artifacts from old KubeMarine versions which are no longer processed by KubeMarine, such section should be adopted to the new version, or removed.
  • If there are custom variables which are dynamically used in Jinja2 templates, such variables should be moved to the new dedicated values section. Usages of the variables should be adopted correspondingly. See Limitations

Test Cases

TestCase 1

Test Configuration:

  • Hardware: Any
  • OS: Any
  • Inventory: Any

Steps:

  1. Make cluster.yaml contain sections or variables that are not known to KubeMarine.
  2. Run any procedure.

Results:

Before After
successful failed with validation error

TestCase 2

Test Configuration:

  • Hardware: Any
  • OS: Any
  • Inventory: Any

Steps:

  1. Make inventory file for any procedure contain sections or variables that are not known to KubeMarine.
  2. Run this procedure.

Results:

Before After
successful failed with validation error

TestCase 3

Test Configuration:

  • Hardware: Any
  • OS: Any
  • Inventory: Any

Steps:

  1. Make cluster.yaml or inventory file for any procedure contain sections or variables that are not known to KubeMarine.
  2. Run the procedure with --ignore-schema-errors option.

Results:

Before After
successful successful with warnings

Regression Testing

  • Need to test all procedures with different parameters for regression.
  • Re-test KubeMarine binary delivery.

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Integration CI passed
  • Unit tests. If Yes list of new/changed tests with brief description
  • There is no merge conflicts

Unit tests

  1. test_upgrade.py - refactoring, fixed and added tests for the changed packages enrichment flow.
  2. test_schema.py:
    • checks that finalized inventory is valid against the schema.
    • checks that examples are actual
    • extended schema validation errors heuristics
  3. test_coredns.py - added tests for some not obvious configmap generation features.
  4. test_inventory.py - allow to omit node names
  5. test_manage_pss.py - manage_pss procedure enrichment and finalization.
  6. test_packages.py - refactoring only

@ilia1243 ilia1243 marked this pull request as draft December 5, 2022 12:38
@ilia1243 ilia1243 force-pushed the feature/yaml_schema branch from 33d9d9b to 652ad36 Compare December 5, 2022 12:52
@koryaga koryaga self-assigned this Dec 6, 2022
@ilia1243 ilia1243 force-pushed the feature/yaml_schema branch 7 times, most recently from 858cf42 to 8cddf31 Compare December 7, 2022 15:27
@ilia1243 ilia1243 force-pushed the feature/yaml_schema branch 13 times, most recently from 4a7345d to 34b8dba Compare December 13, 2022 16:19
@ilia1243 ilia1243 added feature bug Something isn't working documentation Improvements or additions to documentation labels Dec 14, 2022
@ilia1243 ilia1243 force-pushed the feature/yaml_schema branch from 6db87e3 to e952039 Compare January 19, 2023 09:06
@koryaga koryaga merged commit e2a8c0c into main Jan 19, 2023
@koryaga koryaga deleted the feature/yaml_schema branch January 19, 2023 09:59
@ilia1243 ilia1243 mentioned this pull request Jan 19, 2023
5 tasks
dmyar21 pushed a commit that referenced this pull request Jan 19, 2023
* Inventory JSON schema implementation

* Auto-update license header

* Build Binary via Docker

* Custom variables and ignore errors

* Added forgotten additional parameters to remove_node.json

* Add description for the variables and sections

* Fix coredns schema to allow to turn any setting off

* Add forgotten Kubemarine custom params for coredns.

* Add unit tests, fix examples and minor bugs

* Auto-update license header

* Update Installation.md

* Update Maintenance.md

* Update add_node.json

* Update backup.json

* Update cert_renew.json

* Update cluster.json

* Fixed error messages

* Update add_node.json

* Update cluster.json

* Minor fixes in schemas and validation

* Unify getting of Kubemarine version

* Minor outdated validation fix

* Upload binary artifact during build

* Fix schema for calico BGP asNumber

* Fix unit tests verifying examples

* Fix CI extended config

Co-authored-by: ilia1243 <[email protected]>
Co-authored-by: shmo1218 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write unit tests for list merging strategies
4 participants