TT#57012 Force 'ngcpcfg check'->pkwalify to use 'YAML::XS' only

NGCP uses 'YAML::XS' as only the library to work with YAML files.

Meanwhile pkwalify has a long fallback list:
> @try_order = ('YAML::XS', 'YAML::Syck', 'YAML', 'JSON::XS', 'JSON');

It may hide some issues in validation schema (used by 'ngcpcfg check')
and bypass the testing on Gerrit reviews, but failed to 'ngcpcfg apply'
on the customer's system.

Example:

1) cfg_schema.git had a bug in validation schema committed long time ago
in mr6.1+ , commit b9d69e0b33d316c04d8b70536f1e166fec9a67ac.
The commit passed review and all internal testing:
> https://gerrit.mgm.sipwise.com/#/c/17825/  ->
> https://repoapi.mgm.sipwise.com/job/cfg-schema-ce-validation-docker/849/console.txt
> ...
> + ngcpcfg --validate check
> 2017-12-20 14:34:37: yml configs were validated successfully

The bug was simple, the space was missing in schema:

> "rtcp_logging_facility":{ type: str, required: yes }

The library 'YAML::XS' was not able to load the YAML file.
Meanwhile the library 'YAML' was able to load it and pkwalify happily reported us
"yml configs were validated successfully".

2) Later another developer has noticed the problem with YAML schema here
and fixed it in trunk, commit 4636eadb78e5e91dd6d93378a42a8df2ed84838a.

> - "rtcp_logging_facility":{ type: str, required: yes }
> + "rtcp_logging_facility": { type: str, required: yes }

Unfortunately the fix has been applied in trunk only.

3) Later the third developer committed new code which was valid
for 'YAML::XS' but invalid for 'YAML' library (which is fine, as NGCP uses 'YAML::XS').
Since in trunk pkwalify used 'YAML::XS' the changes passed all the testing:
> commit a79e54fb9fbdf0db61b4dfb9c52e572795e854af
> https://gerrit.mgm.sipwise.com/#/c/28486/ ->
> https://repoapi.mgm.sipwise.com/job/cfg-schema-ce-validation-docker/1987/console.txt
> ...
> 2019-04-05 17:20:08 06828d6f31f5: yml configs were validated successfully

4) Later the third developer backported the commit a79e54fb9fbdf0db
to the previous release mr6.5 (where commit 4636eadb78e was missing).
And nightly upgrade tests has failed on mr6.4->mr6.5 upgrade saying:
> 2019-04-09 04:06:27 sp1: Error: Invalid schema detected for /etc/ngcp-config/config.yml
> Cannot parse </usr/share/ngcp-cfg-schema/validate/config.yml>. Cumulated errors:
> YAML::XS::Load Error: The problem:
>   did not find expected key

It happens because pkwalify was not able to load config.yml with any libraries it support.
We have to force pkwalify to use only the library NGCP is using 'YAML::XS'.
This is a commit about it.

Hopefully all the necessary changes have been done by Guillem 2 years ago,
and were uploaded upstream (and even available in default Debian buster):
> https://github.com/eserte/p5-Kwalify/pull/6

Thanks to Guillem Jover for the library fix here and for the help with tracing this issue.

Change-Id: Idbd46b4048a03b5b01a0280a6dcd50406b4222dc
changes/35/28935/1
Alexander Lutay 7 years ago
parent 7d5a1053a2
commit eff2d91d82

@ -160,9 +160,9 @@ validate_config() {
continue
fi
if ! pkwalify -s -f "${schema}" "${f}" >/dev/null 2>&1 ; then
if ! pkwalify -s -m 'YAML::XS' -f "${schema}" "${f}" >/dev/null 2>&1 ; then
log_error "Invalid schema detected for ${f}"
pkwalify -f "${schema}" "${f}" >&2 || true
pkwalify -m 'YAML::XS' -f "${schema}" "${f}" >&2 || true
rc=1
fi
fi

Loading…
Cancel
Save