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

CVL Enhancement and Fixes #110

Merged
merged 3 commits into from
Jan 10, 2024

Conversation

faraazbrcm
Copy link
Contributor

CVL Infra Enhancments and Fixes

  1. Enhancement - Support TABLE keys modelled as container
  2. Enhancement - DBAL CountKeysPattern API
  3. Optimisation: removing libyang syntax checks for Full entry delete
  4. Enhancement - CVL support for SONiC YANG table with distinct YANG
    4.1 Enhancement - For multi-list tables correct Redis pattern and sep
    are matched and picked.
    4.2 Fix - The cvl code to build table expression based on YANG list name
    instead of table name.
    4.3 Fix - CVL maintains tableInfo using a LIST name, fixed the
    inconsistent
    4.4 Enhancement - code to lookup using list name instead of table name.
    4.5 Fix - recognition of table and fields if the table contains mutiple
    lists and if table name as prefix is not present in any of the list
    name
  5. Optimisation: removing extra checks in CVL for non existing fields
    for update operation
  6. Fixes: CVL does not honours "not equal" operator in must expression
    predicate
  7. Fixes: clear depDataCache along with semantic cache, when CVL
    validation completes for clen state.
    CVL maintains a separate cache to check if dependent data is already
to
    the semantic cache. If the entry is present in this cache, the
semantic
    cache is not updated.
    When we clear clear the semantic cache after every
ValidateEditConfig
    we also need to clear depDataCache.
  1. Fixes: clear Xpath engine cache.
   CVL maintains a seesion level cache for semantic validation, this
    cache generates entry for table each time they are operated on.
    As a result this cache contains duplicate entries for a table
    and in some cases it creates a stale entries for leaf, if they are
    deleted in the Latest request.

9 Fixes: stale entries in semantic documents

    CVL maintains a cache of semantic document at the session level.
    If Delete for an entry is successful, the cache
    still contains a deleted entry, this is resulting in must expression
    failure for count cases, the logic in count() considers this entry
in to
    consideration. Therefore cache is cleared for the deleted entry.

    - Also modified addYangDataForMustExp() to avoid using global cache
      and use CVL wrapper for DBAL.
    - Modified fetchTableDataToTmpCache() to use CVL wrapper for DBAL's
      pipeline.

10: Fixes: Incorrect match for depdata in checkDeleteInRequestCache

    For find in request key, case - T2*|K1. If the non-delete
configuration exists
    for dependent data in the Requestcache, its getting matched, and cvl
considers
    its already present in deleteCache and therefore ignores validation.
    modified the condition to match only if entry is deleted.

    Further enhanced the code for find in request hash-field case -
T2*|K2:{H1: K1}
    to match correcly for UPDATE cases. Also in case of leaflist.

11: Enhancement: Use DBAL's CVL wrapper for pipeline - All pipelines
were modified use CVL's DB wrapper.
12: Enhancement: Use CVL's DB wrapper in validateLeafref and fixes for
multi-key table instance
13: Fixes - handle incremental build and stale files removal - Fixed yin
generator

    Tool does not write if the file is not modified and writes only when
    yin modified or added as new.
    Also it removes any stale yin files (if present)
  1. Enhancement: min-elements support for leaf-list
  2. Enhancement - Advanced search functions in cvl DBAccess
  3. Go test enhancements
  4. Update the test YANGs with more complex cases.
  5. Enhancement: changes to the count and filter lua scripts to check
    both the db and candidate config data; modified the count and lookup
  6. Enhancement: Added Pipe query support for HGetAll, HGet, HMGet;
    NewValidationSession, cvlDBAccess changes, removing
    validatedDataQuery
  7. Fixes: Modify the session cache type from interface to
    map[string]interface in the custom validations, and used specific
    cache key name to access its own cache to avoid overwriting the same
    cache object by other module validation code
  8. Enhancement: Added DB access adapter like APIs for redis APIs in CVL
    layer to access the DB access methods from the CVL layer.
  9. Fixes: Added support for NULL field in the Keys, Exists API, fixed
    merging issue in HGetAll, HGet, HMGet in case of delete operation
    type
  10. Fixes: Made changes to handle the redis.Nil error returned by redis
    client API.
  11. Fixes: Leafref check should check for all DELETE and CREATE of
    referred configs in request cache.
  12. Fixes: Removed DB ping call in CVL whenever a new DB client is
    created.
  13. Enhacement: Debugging and log enhancement.
  14. Enhancement: CVL logs to appear in Rest-server logs.
  15. Improved CVL performance for bulk configs like ACL rules creation.
    For evaluation of leafref, When and Must expressions, CVL queries
    dependent data and merge with config data and prepares im-memory XML
to
    be evaluated by XPath engine. The 'addDependentData" call was adding
    same dependent data multiple whenever it has to evaluate leafref,
when
    or must expression. When multiple ACL Rules within same Acl-set are
    configured in single request, CVL was adding Acl-set multiple times
dues
    to which XML size becomes too huge and XPath engines takes long to
    evaluate. For 750 Acl rules creation there is 95% improvement in
    performance.
  1. Added support for multiple custom validation callbacks per node in
    CVL
  2. Fixes: or Replace operations, before performing semantic validation
    on Update request, delete fields from yang tree that are provided
    with Delete request.
  3. Enhancement: Added new extension to define dependency between
    tables.
    This new extension 'dependent-on <list-name>' has to be used when
dependencies between tables can't
    be defined using leafref.
    This has to be added under list.
    It should not be used under container or leaf/leaf-list nodes.
    Only one list-name can be added to this extension.
  1. Fixes: When mandatory node is getting deleted during cascade-delete,
    entire entry to be deleted. So find dependent entries in this entry
    and mark them too for delete.
  2. Fixed memory leak observed in CVL CGo code that uses libyang third
    party library for Syntax validation.

Co-authored-by: Mohammed Faraaz C [email protected]
Co-authored-by: Sachin Holla [email protected]
Co-authored-by: Balachandar Mani [email protected]
Co-authored-by: Mayank Maheshwari [email protected]
Co-authored-by: Shyam Mohan [email protected]

@faraazbrcm faraazbrcm force-pushed the master branch 3 times, most recently from 96d0727 to 95ce88c Compare October 12, 2023 10:40
cvl/cvl_test.go Outdated
func init() {
configDb, _ = db.NewDB(db.Options{
DBNo: db.ConfigDB,
InitIndicator: "CONFIG_DB_INITIALIZED",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this "InitIndicator" option to fix pipeline test errors. It would be a fresh installation of redis on the build VM and CONFIG_DB_INITIALIZED would not have been set.
Also, do not ignore error returned by db.NewDB(). Add a panic.

@faraazbrcm faraazbrcm force-pushed the master branch 5 times, most recently from ebba16e to 45fc6e3 Compare October 13, 2023 04:25
@faraazbrcm faraazbrcm force-pushed the master branch 4 times, most recently from f047993 to 0f7679d Compare October 25, 2023 05:57
@faraazbrcm faraazbrcm force-pushed the master branch 3 times, most recently from 84d225c to 4d27cec Compare November 16, 2023 07:33
@kwangsuk
Copy link
Contributor

After initial clone and make, I notice a format-check error.

internal/util/util.go

1 files have formatting errors; listed in /home/kkim/github/community/sonic-mgmt-common/build/cvl/formatcheck.log
Execute 'format-check.sh -fix <FILES>' to fix issues.
Makefile:98: recipe for target '/home/kkim/github/community/sonic-mgmt-common/build/cvl/.formatcheck' failed
make[1]: *** [/home/kkim/github/community/sonic-mgmt-common/build/cvl/.formatcheck] Error 1
make[1]: Leaving directory '/home/kkim/github/community/sonic-mgmt-common/cvl'
Makefile:50: recipe for target 'cvl' failed
make: *** [cvl] Error 2

@faraazbrcm
Copy link
Contributor Author

After initial clone and make, I notice a format-check error.

internal/util/util.go

1 files have formatting errors; listed in /home/kkim/github/community/sonic-mgmt-common/build/cvl/formatcheck.log
Execute 'format-check.sh -fix <FILES>' to fix issues.
Makefile:98: recipe for target '/home/kkim/github/community/sonic-mgmt-common/build/cvl/.formatcheck' failed
make[1]: *** [/home/kkim/github/community/sonic-mgmt-common/build/cvl/.formatcheck] Error 1
make[1]: Leaving directory '/home/kkim/github/community/sonic-mgmt-common/cvl'
Makefile:50: recipe for target 'cvl' failed
make: *** [cvl] Error 2

I dont. see any issue. just cloned using below steps and applied PR content on top of it. I see build went through. please provide the steps you followed when u clone and compiled. Go version needs to be go1.15.15. This is what community uses. please check your go version.

git clone https://github.com/sonic-net/sonic-mgmt-common.git
cd sonic-mgmt-common
git checkout master
git fetch origin pull/110/head:pr-110
git checkout pr-110
git checkout master
git merge pr-110
make

My Environment

$ git branch
* master
  pr-110
$ go version
go version go1.15.15 linux/arm64

My build log

$ pwd
/home/parallels/work/community/temp/sonic-mgmt-common
$ make
/usr/local/go1.15.15/bin/go mod vendor
patches/apply.sh vendor
+ copy github.com/openconfig/ygot v0.7.1 ygen genutil generator
+ for FILE in "${@:3}"
+ rsync -r --chmod=u+w --exclude=testdata '--exclude=*_test.go' /tmp/go1.15.15/pkg/mod/github.com/openconfig/[email protected]/ygen vendor/github.com/openconfig/ygot/
+ for FILE in "${@:3}"
+ rsync -r --chmod=u+w --exclude=testdata '--exclude=*_test.go' /tmp/go1.15.15/pkg/mod/github.com/openconfig/[email protected]/genutil vendor/github.com/openconfig/ygot/
+ for FILE in "${@:3}"
+ rsync -r --chmod=u+w --exclude=testdata '--exclude=*_test.go' /tmp/go1.15.15/pkg/mod/github.com/openconfig/[email protected]/generator vendor/github.com/openconfig/ygot/
+ copy github.com/openconfig/goyang v0.0.0-20200309174518-a00bece872fc .
+ for FILE in "${@:3}"
+ rsync -r --chmod=u+w --exclude=testdata '--exclude=*_test.go' /tmp/go1.15.15/pkg/mod/github.com/openconfig/[email protected]/. vendor/github.com/openconfig/goyang/
+ copy github.com/openconfig/gnmi v0.0.0-20200617225440-d2b4e6a45802 .
+ for FILE in "${@:3}"
+ rsync -r --chmod=u+w --exclude=testdata '--exclude=*_test.go' /tmp/go1.15.15/pkg/mod/github.com/openconfig/[email protected]/. vendor/github.com/openconfig/gnmi/
+ patch -d vendor/github.com/openconfig/ygot -p1
patching file generator/generator.go
patching file genutil/common.go
patching file util/debug.go
patching file util/path.go
patching file util/reflect.go
patching file ygen/codegen.go
patching file ygen/genstate.go
patching file ygen/schemaparse.go
patching file ygot/render.go
patching file ygot/struct_validation_map.go
patching file ytypes/container.go
patching file ytypes/leaf.go
patching file ytypes/list.go
patching file ytypes/node.go
patching file ytypes/string_type.go
patching file ytypes/unmarshal.go
patching file ytypes/validate.go
+ patch -d vendor/github.com/openconfig/goyang -p1
patching file annotate.go
patching file pkg/yang/ast.go
patching file pkg/yang/entry.go
patching file pkg/yang/types.go
patching file README.md
patching file yang.go
+ patch -d vendor/github.com/antchfx/jsonquery -p1
patching file node.go
patching file query.go
+ patch -d vendor/github.com/antchfx/xmlquery -p1
patching file node.go
patching file query.go
+ patch -d vendor/github.com/antchfx/xpath -p1
patching file build.go
patching file func.go
patching file operator.go
patching file query.go
patching file xpath.go
+ patch -d vendor/github.com/golang/glog -p1
patching file glog.go
touch  vendor/.done
make -C models/yang
make[1]: Entering directory '/home/parallels/work/community/temp/sonic-mgmt-common/models/yang'
SONICYANG_IMPORT_DIR =
mkdir -p ../../build/yang/.
rsync -oavh --include='*/' --include='*.yang' --exclude='*' *.yang common  ../../build/yang
sending incremental file list
ietf-yang-library.yang
openconfig-acl.yang
openconfig-if-ethernet.yang
openconfig-if-ip.yang
openconfig-interfaces.yang
openconfig-lldp.yang
openconfig-platform.yang
openconfig-sampling-sflow.yang
openconfig-system.yang
common/
common/iana-if-type.yang
common/ietf-inet-types.yang
common/ietf-interfaces.yang
common/ietf-yang-types.yang
common/openconfig-aaa-radius.yang
common/openconfig-aaa-tacacs.yang
common/openconfig-aaa-types.yang
common/openconfig-aaa.yang
common/openconfig-alarm-types.yang
common/openconfig-alarms.yang
common/openconfig-extensions.yang
common/openconfig-if-aggregate.yang
common/openconfig-if-ethernet-ext.yang
common/openconfig-if-ip-ext.yang
common/openconfig-if-poe.yang
common/openconfig-if-tunnel.yang
common/openconfig-if-types.yang
common/openconfig-inet-types.yang
common/openconfig-lldp-types.yang
common/openconfig-messages.yang
common/openconfig-packet-match-types.yang
common/openconfig-packet-match.yang
common/openconfig-platform-types.yang
common/openconfig-procmon.yang
common/openconfig-system-logging.yang
common/openconfig-system-management.yang
common/openconfig-system-terminal.yang
common/openconfig-types.yang
common/openconfig-vlan-types.yang
common/openconfig-vlan.yang
common/openconfig-yang-types.yang

sent 462.27K bytes  received 788 bytes  926.11K bytes/sec
total size is 459.27K  speedup is 0.99
touch ../../build/yang/.sync_std_yangs
rsync -oavh --include='*/' --include='*.yang' --exclude='*' extensions ../../build/yang
sending incremental file list
extensions/
extensions/openconfig-sampling-sflow-deviation.yang

sent 1.86K bytes  received 39 bytes  3.80K bytes/sec
total size is 1.67K  speedup is 0.88
touch ../../build/yang/.sync_ext_yangs
rsync -oavh annotations/*.yang  ../../build/yang/annotations
sending incremental file list
created directory ../../build/yang/annotations
openconfig-acl-annot.yang
openconfig-sampling-sflow-annot.yang
sonic-extensions.yang
sonic-showtech-annot.yang

sent 12.24K bytes  received 143 bytes  24.76K bytes/sec
total size is 11.88K  speedup is 0.96
touch ../../build/yang/.sync_annot_yangs
mkdir -p ../../build/yang/sonic/common/.
# Nothing to import, blindly copy all local sonic yangs
rsync -oavh --include='*/' --include='*.yang' --exclude='*' sonic ../../build/yang
sending incremental file list
sonic/
sonic/sonic-acl.yang
sonic/sonic-interface.yang
sonic/sonic-port.yang
sonic/sonic-show-techsupport.yang
sonic/common/
sonic/common/sonic-common.yang
sonic/common/sonic-extension.yang

sent 10.37K bytes  received 146 bytes  21.04K bytes/sec
total size is 9.80K  speedup is 0.93
touch ../../build/yang/.sync_sonic_yangs
pyang \
	-f tree \
	-o allyangs.tree \
	-p ../../build/yang/common:../../build/yang \
	../../build/yang/*.yang $(find ../../build/yang/extensions -name '*.yang')
../../build/yang/openconfig-if-ethernet.yang:427: warning: node "openconfig-interfaces::state" is config false and is not part of the accessible tree
+++++ Generation of  YANG tree for Yang modules completed +++++
pyang \
	-f jstree \
	-o allyangs_tree.html \
	-p ../../build/yang/common:../../build/yang \
	../../build/yang/*.yang $(find ../../build/yang/extensions -name '*.yang')
../../build/yang/openconfig-if-ethernet.yang:427: warning: node "openconfig-interfaces::state" is config false and is not part of the accessible tree
+++++ Generation of  HTML tree for Yang modules completed +++++
pyang \
	-f tree \
	-o sonic_allyangs.tree \
	-p ../../build/yang/sonic/common:../../build/yang/sonic:../../build/yang/common \
	../../build/yang/sonic/*.yang
+++++ Generation of  YANG tree for Sonic Yang modules completed +++++
pyang \
	-f jstree \
	-o sonic_allyangs_tree.html \
	-p ../../build/yang/sonic/common:../../build/yang/sonic:../../build/yang/common \
	../../build/yang/sonic/*.yang
+++++ Generation of  HTML tree for Sonic Yang modules completed +++++
make[1]: Leaving directory '/home/parallels/work/community/temp/sonic-mgmt-common/models/yang'
make -C ./cvl
make[1]: Entering directory '/home/parallels/work/community/temp/sonic-mgmt-common/cvl'
mkdir -p /home/parallels/work/community/temp/sonic-mgmt-common/build/cvl/schema/.
tools/generate_yin.py \
	--path=/home/parallels/work/community/temp/sonic-mgmt-common/build/yang/sonic \
	--path=../models/yang/common \
	--out-dir=/home/parallels/work/community/temp/sonic-mgmt-common/build/cvl/schema
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/cvl/schema/sonic-common.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/cvl/schema/sonic-interface.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/cvl/schema/sonic-acl.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/cvl/schema/sonic-port.yin
touch /home/parallels/work/community/temp/sonic-mgmt-common/build/cvl/schema/.done
/home/parallels/work/community/temp/sonic-mgmt-common/tools/test/format-check.sh \
	--log=/home/parallels/work/community/temp/sonic-mgmt-common/build/cvl/formatcheck.log \
	internal/yparser/yparser.go internal/yparser/ly_path.go internal/util/luascript_util.go internal/util/util.go cvl_hint.go cvl.go custom_validation/common.go custom_validation/test_validations.go cvl_api.go cvl_luascript.go common/db_access.go common/cvl_types.go common/db_utils.go cvl_cache.go cvl_semantics.go cvl_syntax.go cvl_error_test.go cvl_hint_test.go cvl_leaflist_test.go cvl_leafref_test.go cvl_must_test.go cvl_optimisation_test.go cvl_test.go cvl_when_test.go jsondata_test.go
touch /home/parallels/work/community/temp/sonic-mgmt-common/build/cvl/.formatcheck
mkdir -p /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/.
cp -r testdata/*.json /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata
/usr/local/go1.15.15/bin/go test -mod=vendor -tags=test -cover -coverpkg=../cvl,../cvl/internal/util,../cvl/internal/yparser -c ../cvl -o /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/cvl.test
mkdir -p /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/.
tools/generate_yin.py \
	--path=testdata/schema \
	--path=../models/yang/common \
	--path=../models/yang/sonic/common \
	--out-dir=/home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema
====> Transforming container /sonic-mgmt_vrf:sonic-mgmt_vrf/sonic-mgmt_vrf:MGMT_VRF_CONFIG/sonic-mgmt_vrf:vrf_global to list
====> Transforming container /sonic-telemetry:sonic-telemetry/sonic-telemetry:TELEMETRY/sonic-telemetry:certs to list
====> Transforming container /sonic-telemetry:sonic-telemetry/sonic-telemetry:TELEMETRY/sonic-telemetry:gnmi to list
====> Transforming container /sonic-test-xfmr:sonic-test-xfmr/sonic-test-xfmr:TEST_SENSOR_GLOBAL/sonic-test-xfmr:global_sensor to list
====> Transforming container /sonic-sflow:sonic-sflow/sonic-sflow:SFLOW/sonic-sflow:global to list
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-buffer-pool.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-igmp-snooping.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-pfc-priority-queue-map.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-device-metadata.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-pf-limits.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-mgmt_vrf.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-tc-queue-map.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-dscp-tc-map.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-bgp-global.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-tc-priority-group-map.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-buffer-pg.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-scheduler.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-cablelength.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-loopback-interface.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-mgmt_port.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-telemetry.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-tam.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-types.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-device-neighbor.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-port-qos-map.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-portchannel.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-vlan-interface.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-ifa.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-vrf.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-leaflist-test.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-test-xfmr.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-sflow.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-vlan.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-interface.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-acl.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-spanning-tree.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-port.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-portchannel-interface.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-wred-profile.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-buffer-profile.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-mirror-session.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-queue.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-static-route.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-vxlan.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-common.yin
Writing /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/sonic-extension.yin
touch /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/cvl/testdata/schema/.done
make[1]: Leaving directory '/home/parallels/work/community/temp/sonic-mgmt-common/cvl'
make -C ./translib
make[1]: Entering directory '/home/parallels/work/community/temp/sonic-mgmt-common/translib'
rm -f ocbinds/ocbinds.go
/usr/local/go1.15.15/bin/go run \
	--mod=vendor \
	/home/parallels/work/community/temp/sonic-mgmt-common/vendor/github.com/openconfig/ygot/generator/generator.go \
	--logtostderr \
	--output_file=ocbinds/ocbinds.go \
	--package_name=ocbinds \
	--generate_fakeroot \
	--fakeroot_name=device \
	--compress_paths=false \
	--path=../build/yang \
	--exclude_modules=ietf-interfaces,sonic-types,sonic-common, \
	../build/yang/openconfig-if-ethernet.yang ../build/yang/openconfig-interfaces.yang ../build/yang/openconfig-platform.yang ../build/yang/openconfig-system.yang ../build/yang/sonic/sonic-show-techsupport.yang ../build/yang/sonic/common/sonic-common.yang ../build/yang/sonic/common/sonic-extension.yang ../build/yang/sonic/sonic-interface.yang ../build/yang/sonic/sonic-acl.yang ../build/yang/sonic/sonic-port.yang ../build/yang/openconfig-lldp.yang ../build/yang/ietf-yang-library.yang ../build/yang/openconfig-sampling-sflow.yang ../build/yang/extensions/openconfig-sampling-sflow-deviation.yang ../build/yang/openconfig-if-ip.yang ../build/yang/openconfig-acl.yang ../build/yang/common/openconfig-procmon.yang ../build/yang/common/openconfig-alarm-types.yang ../build/yang/common/openconfig-aaa-types.yang ../build/yang/common/openconfig-aaa.yang ../build/yang/common/openconfig-system-terminal.yang ../build/yang/common/iana-if-type.yang ../build/yang/common/openconfig-types.yang ../build/yang/common/ietf-yang-types.yang ../build/yang/common/openconfig-vlan-types.yang ../build/yang/common/openconfig-if-types.yang ../build/yang/common/openconfig-extensions.yang ../build/yang/common/openconfig-lldp-types.yang ../build/yang/common/openconfig-packet-match-types.yang ../build/yang/common/openconfig-aaa-radius.yang ../build/yang/common/openconfig-messages.yang ../build/yang/common/openconfig-system-logging.yang ../build/yang/common/openconfig-platform-types.yang ../build/yang/common/ietf-inet-types.yang ../build/yang/common/openconfig-vlan.yang ../build/yang/common/openconfig-alarms.yang ../build/yang/common/openconfig-if-ip-ext.yang ../build/yang/common/openconfig-if-ethernet-ext.yang ../build/yang/common/openconfig-packet-match.yang ../build/yang/common/ietf-interfaces.yang ../build/yang/common/openconfig-yang-types.yang ../build/yang/common/openconfig-if-aggregate.yang ../build/yang/common/openconfig-aaa-tacacs.yang ../build/yang/common/openconfig-if-tunnel.yang ../build/yang/common/openconfig-system-management.yang ../build/yang/common/openconfig-if-poe.yang ../build/yang/common/openconfig-inet-types.yang
mkdir -p /home/parallels/work/community/temp/sonic-mgmt-common/build/transformer
rm -f /home/parallels/work/community/temp/sonic-mgmt-common/build/transformer/models_list /home/parallels/work/community/temp/sonic-mgmt-common/build/transformer/extra_models
printf -- "-%s\n" sonic-common.yang sonic-extension.yang > /home/parallels/work/community/temp/sonic-mgmt-common/build/transformer/extra_models
cat /home/parallels/work/community/temp/sonic-mgmt-common/config/transformer/models_list /home/parallels/work/community/temp/sonic-mgmt-common/build/transformer/extra_models > /home/parallels/work/community/temp/sonic-mgmt-common/build/transformer/models_list
mkdir -p /home/parallels/work/community/temp/sonic-mgmt-common/build/translib/.
/home/parallels/work/community/temp/sonic-mgmt-common/tools/test/format-check.sh \
	--log=/home/parallels/work/community/temp/sonic-mgmt-common/build/translib/formatcheck.log \
	tlerr/tlerr.go tlerr/app_errors.go common_app.go sys_app.go lldp_app.go intf_app.go internal/apis/db_diff.go internal/apis/notify.go translib.go subscribe_app_interface.go authorize.go subscribe_app_utils.go db/db_cursor.go db/db_redis_opts.go db/cvl_db_access.go db/db_table.go db/db_get.go db/map.go db/db_cache.go db/db_config.go db/db_key.go db/db_value.go db/db_stats.go db/db_onchangecache.go db/db_keys_pattern.go db/db_map.go db/db_signal.go db/db_table_pattern.go db/db_get_config.go db/subscribe.go db/db.go pfm_app.go transformer/xconst.go transformer/xlate.go transformer/xlate_prune.go transformer/xlate_datastructs.go transformer/xlate_from_db.go transformer/xlate_to_db.go transformer/xfmr_showtech.go transformer/xfmr_interface.go transformer/xfmr_dbtbl_cbk_interface.go transformer/xlate_cascade_del.go transformer/xlate_del_to_db.go transformer/transformer.go transformer/xlate_utils.go transformer/xfmr_sflow.go transformer/host_comm.go transformer/subscribe_resp_xlate.go transformer/xfmr_testxfmr_callbacks.go transformer/xlate_tbl_info.go transformer/xlate_xfmr_handler.go transformer/xfmr_path_utils.go transformer/xspec.go transformer/xlate_prune_stats.go transformer/subscribe_req_xlate.go subscribe_notify.go app_interface.go acl_app.go api_tests_app.go request_binder.go subscribe_utils.go yanglib_app.go version.go utils/utils.go utils/bits.go path_utils.go subscribe.go app_utils.go path/path.go path/path_validator.go ocbinds/schema.go path_utils_test.go internal/apis/db_diff_test.go request_binder_test.go pfm_app_test.go db/db_table_pattern_test.go db/db_get_test.go db/db_opts_to_test.go db/db_get_config_test.go db/db_test.go db/db_key_test.go db/db_cursor_test.go db/db_value_test.go db/db_redis_opts_test.go db/db_redis_pipe_test.go db/db_onchangecache_test.go db/db_keys_pattern_test.go transformer/xlate_prune_radius_test.go transformer/xlate_prune_acl_test.go transformer/transformer_test.go transformer/xlate_prune_test.go transformer/sflow_openconfig_test.go transformer/xlate_prune_interfaces_test.go transformer/testxfmryang_test.go transformer/sflow_sonic_test.go transformer/xlate_prune_ospf_test.go transformer/utils_test.go version_test.go yanglib_app_test.go intf_app_test.go subscribe_test.go app_utils_test.go translib_test.go acl_app_test.go path/path_test.go path/path_validator_test.go
touch /home/parallels/work/community/temp/sonic-mgmt-common/build/translib/.formatcheck
/usr/local/go1.15.15/bin/go test -mod=vendor -tags test -cover -coverpkg=../translib,../translib/tlerr -c ../translib -o /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/translib/translib.test
/usr/local/go1.15.15/bin/go test -mod=vendor -cover -c ../translib/db -o /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/translib/db.test
/usr/local/go1.15.15/bin/go test -mod=vendor -tags testapp -c -vet=off -cover -coverpkg=../translib/transformer ../translib/transformer -o /home/parallels/work/community/temp/sonic-mgmt-common/build/tests/translib/testapp.test
make[1]: Leaving directory '/home/parallels/work/community/temp/sonic-mgmt-common/translib'
$

faraazbrcm and others added 2 commits January 10, 2024 09:36
1. Enhancement - Support TABLE keys modelled as container
2. Enhancement - DBAL CountKeysPattern API
3. Optimisation: removing libyang syntax checks for Full entry delete
4. Enhancement - CVL support for SONiC YANG table with distinct YANG
4.1 Enhancement - For multi-list tables correct Redis pattern and sep
  are matched and picked.
4.2 Fix - The cvl code to build table expression based on YANG list name
  instead of table name.
4.3 Fix - CVL maintains tableInfo using a LIST name, fixed the
  inconsistent
4.4 Enhancement - code to lookup using list name instead of table name.
4.5 Fix - recognition of table and fields if the table contains mutiple
  lists and if table name as prefix is not present in any of the list
name
5. Optimisation: removing extra checks in CVL for non existing fields
   for update operation
6. Fixes: CVL does not honours "not equal" operator in must expression
   predicate
7. Fixes: clear depDataCache along with semantic cache, when CVL
   validation completes for clen state.
```text
    CVL maintains a separate cache to check if dependent data is already
to
    the semantic cache. If the entry is present in this cache, the
semantic
    cache is not updated.
    When we clear clear the semantic cache after every
ValidateEditConfig
    we also need to clear depDataCache.
```
8. Fixes: clear Xpath engine cache.
```text
   CVL maintains a seesion level cache for semantic validation, this
    cache generates entry for table each time they are operated on.
    As a result this cache contains duplicate entries for a table
    and in some cases it creates a stale entries for leaf, if they are
    deleted in the Latest request.
```
9 Fixes: stale entries in semantic documents
```text
    CVL maintains a cache of semantic document at the session level.
    If Delete for an entry is successful, the cache
    still contains a deleted entry, this is resulting in must expression
    failure for count cases, the logic in count() considers this entry
in to
    consideration. Therefore cache is cleared for the deleted entry.

    - Also modified addYangDataForMustExp() to avoid using global cache
      and use CVL wrapper for DBAL.
    - Modified fetchTableDataToTmpCache() to use CVL wrapper for DBAL's
      pipeline.
```
10: Fixes: Incorrect match for depdata in checkDeleteInRequestCache
```text
    For find in request key, case - T2*|K1. If the non-delete
configuration exists
    for dependent data in the Requestcache, its getting matched, and cvl
considers
    its already present in deleteCache and therefore ignores validation.
    modified the condition to match only if entry is deleted.

    Further enhanced the code for find in request hash-field case -
T2*|K2:{H1: K1}
    to match correcly for UPDATE cases. Also in case of leaflist.
```
11: Enhancement: Use DBAL's CVL wrapper for pipeline - All pipelines
    were modified use CVL's DB wrapper.
12: Enhancement: Use CVL's DB wrapper in validateLeafref and fixes for
    multi-key table instance
13: Fixes - handle incremental build and stale files removal - Fixed yin
    generator
```text
    Tool does not write if the file is not modified and writes only when
    yin modified or added as new.
    Also it removes any stale yin files (if present)
```
14. Enhancement: min-elements support for leaf-list
15. Enhancement - Advanced search functions in cvl DBAccess
16. Go test enhancements
17. Update the test YANGs with more complex cases.
18. Enhancement: changes to the count and filter lua scripts to check
    both the db and candidate config data; modified the count and lookup
19. Enhancement: Added Pipe query support for HGetAll, HGet, HMGet;
    NewValidationSession, cvlDBAccess changes, removing
validatedDataQuery
20. Fixes: Modify the session cache type from interface to
    map[string]interface in the custom validations, and used specific
cache key name to access its own cache to avoid overwriting the same
cache object by other module validation code
21. Enhancement: Added DB access adapter like APIs for redis APIs in CVL
    layer to access the DB access methods from the CVL layer.
22. Fixes: Added support for NULL field in the Keys, Exists API, fixed
    merging issue in HGetAll, HGet, HMGet in case of delete operation
type
23. Fixes: Made changes to handle the redis.Nil error returned by redis
    client API.
24. Fixes: Leafref check should check for all DELETE and CREATE of
    referred configs in request cache.
25. Fixes: Removed DB ping call in CVL whenever a new DB client is
    created.
26. Enhacement: Debugging and log enhancement.
27. Enhancement: CVL logs to appear in Rest-server logs.
28. Improved CVL performance for bulk configs like ACL rules creation.
```text
    For evaluation of leafref, When and Must expressions, CVL queries
    dependent data and merge with config data and prepares im-memory XML
to
    be evaluated by XPath engine. The 'addDependentData" call was adding
    same dependent data multiple whenever it has to evaluate leafref,
when
    or must expression. When multiple ACL Rules within same Acl-set are
    configured in single request, CVL was adding Acl-set multiple times
dues
    to which XML size becomes too huge and XPath engines takes long to
    evaluate. For 750 Acl rules creation there is 95% improvement in
    performance.
```
29. Added support for multiple custom validation callbacks per node in
    CVL
30. Fixes: or Replace operations, before performing semantic validation
    on Update request, delete fields from yang tree that are provided
with Delete request.
31. Enhancement: Added new extension to define dependency between
    tables.
```text
    This new extension 'dependent-on <list-name>' has to be used when
dependencies between tables can't
    be defined using leafref.
    This has to be added under list.
    It should not be used under container or leaf/leaf-list nodes.
    Only one list-name can be added to this extension.
```
32. Fixes: When mandatory node is getting deleted during cascade-delete,
    entire entry to be deleted. So find dependent entries in this entry
and mark them too for delete.
33. Fixed memory leak observed in CVL CGo code that uses libyang third
    party library for Syntax validation.

Co-authored-by: Mohammed Faraaz C <[email protected]>
Co-authored-by: Sachin Holla <[email protected]>
Co-authored-by: Balachandar Mani <[email protected]>
Co-authored-by: Mayank Maheshwari <[email protected]>
Co-authored-by: Shyam Mohan <[email protected]>
1. Enhancement - Support TABLE keys modelled as container
2. Enhancement - DBAL CountKeysPattern API
3. Optimisation: removing libyang syntax checks for Full entry delete
4. Enhancement - CVL support for SONiC YANG table with distinct YANG
4.1 Enhancement - For multi-list tables correct Redis pattern and sep
  are matched and picked.
4.2 Fix - The cvl code to build table expression based on YANG list name
  instead of table name.
4.3 Fix - CVL maintains tableInfo using a LIST name, fixed the
  inconsistent
4.4 Enhancement - code to lookup using list name instead of table name.
4.5 Fix - recognition of table and fields if the table contains mutiple
  lists and if table name as prefix is not present in any of the list
name
5. Optimisation: removing extra checks in CVL for non existing fields
   for update operation
6. Fixes: CVL does not honours "not equal" operator in must expression
   predicate
7. Fixes: clear depDataCache along with semantic cache, when CVL
   validation completes for clen state.
```text
    CVL maintains a separate cache to check if dependent data is already
to
    the semantic cache. If the entry is present in this cache, the
semantic
    cache is not updated.
    When we clear clear the semantic cache after every
ValidateEditConfig
    we also need to clear depDataCache.
```
8. Fixes: clear Xpath engine cache.
```text
   CVL maintains a seesion level cache for semantic validation, this
    cache generates entry for table each time they are operated on.
    As a result this cache contains duplicate entries for a table
    and in some cases it creates a stale entries for leaf, if they are
    deleted in the Latest request.
```
9 Fixes: stale entries in semantic documents
```text
    CVL maintains a cache of semantic document at the session level.
    If Delete for an entry is successful, the cache
    still contains a deleted entry, this is resulting in must expression
    failure for count cases, the logic in count() considers this entry
in to
    consideration. Therefore cache is cleared for the deleted entry.

    - Also modified addYangDataForMustExp() to avoid using global cache
      and use CVL wrapper for DBAL.
    - Modified fetchTableDataToTmpCache() to use CVL wrapper for DBAL's
      pipeline.
```
10: Fixes: Incorrect match for depdata in checkDeleteInRequestCache
```text
    For find in request key, case - T2*|K1. If the non-delete
configuration exists
    for dependent data in the Requestcache, its getting matched, and cvl
considers
    its already present in deleteCache and therefore ignores validation.
    modified the condition to match only if entry is deleted.

    Further enhanced the code for find in request hash-field case -
T2*|K2:{H1: K1}
    to match correcly for UPDATE cases. Also in case of leaflist.
```
11: Enhancement: Use DBAL's CVL wrapper for pipeline - All pipelines
    were modified use CVL's DB wrapper.
12: Enhancement: Use CVL's DB wrapper in validateLeafref and fixes for
    multi-key table instance
13: Fixes - handle incremental build and stale files removal - Fixed yin
    generator
```text
    Tool does not write if the file is not modified and writes only when
    yin modified or added as new.
    Also it removes any stale yin files (if present)
```
14. Enhancement: min-elements support for leaf-list
15. Enhancement - Advanced search functions in cvl DBAccess
16. Go test enhancements
17. Update the test YANGs with more complex cases.
18. Enhancement: changes to the count and filter lua scripts to check
    both the db and candidate config data; modified the count and lookup
19. Enhancement: Added Pipe query support for HGetAll, HGet, HMGet;
    NewValidationSession, cvlDBAccess changes, removing
validatedDataQuery
20. Fixes: Modify the session cache type from interface to
    map[string]interface in the custom validations, and used specific
cache key name to access its own cache to avoid overwriting the same
cache object by other module validation code
21. Enhancement: Added DB access adapter like APIs for redis APIs in CVL
    layer to access the DB access methods from the CVL layer.
22. Fixes: Added support for NULL field in the Keys, Exists API, fixed
    merging issue in HGetAll, HGet, HMGet in case of delete operation
type
23. Fixes: Made changes to handle the redis.Nil error returned by redis
    client API.
24. Fixes: Leafref check should check for all DELETE and CREATE of
    referred configs in request cache.
25. Fixes: Removed DB ping call in CVL whenever a new DB client is
    created.
26. Enhacement: Debugging and log enhancement.
27. Enhancement: CVL logs to appear in Rest-server logs.
28. Improved CVL performance for bulk configs like ACL rules creation.
```text
    For evaluation of leafref, When and Must expressions, CVL queries
    dependent data and merge with config data and prepares im-memory XML
to
    be evaluated by XPath engine. The 'addDependentData" call was adding
    same dependent data multiple whenever it has to evaluate leafref,
when
    or must expression. When multiple ACL Rules within same Acl-set are
    configured in single request, CVL was adding Acl-set multiple times
dues
    to which XML size becomes too huge and XPath engines takes long to
    evaluate. For 750 Acl rules creation there is 95% improvement in
    performance.
```
29. Added support for multiple custom validation callbacks per node in
    CVL
30. Fixes: or Replace operations, before performing semantic validation
    on Update request, delete fields from yang tree that are provided
with Delete request.
31. Enhancement: Added new extension to define dependency between
    tables.
```text
    This new extension 'dependent-on <list-name>' has to be used when
dependencies between tables can't
    be defined using leafref.
    This has to be added under list.
    It should not be used under container or leaf/leaf-list nodes.
    Only one list-name can be added to this extension.
```
32. Fixes: When mandatory node is getting deleted during cascade-delete,
    entire entry to be deleted. So find dependent entries in this entry
and mark them too for delete.
33. Fixed memory leak observed in CVL CGo code that uses libyang third
    party library for Syntax validation.

Co-authored-by: Mohammed Faraaz C <[email protected]>
Co-authored-by: Sachin Holla <[email protected]>
Co-authored-by: Balachandar Mani <[email protected]>
Co-authored-by: Mayank Maheshwari <[email protected]>
Co-authored-by: Shyam Mohan <[email protected]>
@faraazbrcm faraazbrcm force-pushed the master branch 2 times, most recently from f44754f to 43242e2 Compare January 10, 2024 04:56
1. sortDepTables
2. GetOrderedDepTables
3. GetOrderedTables
Also fixed following issues in the above APIs
1. Missing Nodes(toposort) when Table has multiple lists.
2. Inconsistent comparison (few places list names where compared with
   table name)
3. Inconsistent I/O. These functions were designed to work on Lists but
   it accepted table names and due to which inconsistent results were
   observed. Fixed the behavior the I/O is always TABLE NAME but
   internally it gets converted to LIST and processed. It is done
   because there is a possibility of having an dependency between TABLE
   LIST.
4. Optimise the code.

Co-authored-by: Mohammed Faraaz C <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants