datastore upgrade bugs

This commit is contained in:
Olof hagsand 2020-02-12 17:37:23 +01:00
parent cdd22bc33d
commit fa257ebb88
4 changed files with 24 additions and 12 deletions

View file

@ -71,11 +71,15 @@ static int _reset = 0;
*/ */
static int _state = 0; static int _state = 0;
/*! Variable to control upgrade callbacks. /*! Variable to control module-specific upgrade callbacks.
* If set, call test-case for upgrading ietf-interfaces, otherwise call * If set, call test-case for upgrading ietf-interfaces, otherwise call
* auto-upgrade * auto-upgrade
*/ */
static int _upgrade = 0; static int _module_upgrade = 0;
/*! Variable to control general-purpose upgrade callbacks.
*/
static int _general_upgrade = 0;
/*! Variable to control transaction logging (for debug) /*! Variable to control transaction logging (for debug)
* If set, call syslog for every transaction callback * If set, call syslog for every transaction callback
@ -456,9 +460,11 @@ example_upgrade(clicon_handle h,
int i; int i;
const char **pp; const char **pp;
if (_general_upgrade == 0)
goto ok;
if (strcmp(db, "startup") != 0) /* skip other than startup datastore */ if (strcmp(db, "startup") != 0) /* skip other than startup datastore */
goto ok; goto ok;
if (msd->md_status) /* skip if there is proper module-state in datastore */ if (msd && msd->md_status) /* skip if there is proper module-state in datastore */
goto ok; goto ok;
yspec = clicon_dbspec_yang(h); /* Get all yangs */ yspec = clicon_dbspec_yang(h); /* Get all yangs */
/* Get canonical namespaces for using "normalized" prefixes */ /* Get canonical namespaces for using "normalized" prefixes */
@ -793,7 +799,7 @@ static clixon_plugin_api api = {
.ca_trans_revert=main_revert, /* trans revert */ .ca_trans_revert=main_revert, /* trans revert */
.ca_trans_end=main_end, /* trans end */ .ca_trans_end=main_end, /* trans end */
.ca_trans_abort=main_abort, /* trans abort */ .ca_trans_abort=main_abort, /* trans abort */
.ca_datastore_upgrade=example_upgrade /* gneral-purpose upgrade. */ .ca_datastore_upgrade=example_upgrade /* general-purpose upgrade. */
}; };
/*! Backend plugin initialization /*! Backend plugin initialization
@ -818,7 +824,7 @@ clixon_plugin_init(clicon_handle h)
goto done; goto done;
opterr = 0; opterr = 0;
optind = 1; optind = 1;
while ((c = getopt(argc, argv, "rsut:")) != -1) while ((c = getopt(argc, argv, "rsuUt:")) != -1)
switch (c) { switch (c) {
case 'r': case 'r':
_reset = 1; _reset = 1;
@ -826,8 +832,11 @@ clixon_plugin_init(clicon_handle h)
case 's': case 's':
_state = 1; _state = 1;
break; break;
case 'u': case 'u': /* module-specific upgrade */
_upgrade = 1; _module_upgrade = 1;
break;
case 'U': /* general-purpose upgrade */
_general_upgrade = 1;
break; break;
case 't': /* transaction log */ case 't': /* transaction log */
_transaction_log = 1; _transaction_log = 1;
@ -885,7 +894,7 @@ clixon_plugin_init(clicon_handle h)
/* Upgrade callback: if you start the backend with -- -u you will get the /* Upgrade callback: if you start the backend with -- -u you will get the
* test interface example. Otherwise the auto-upgrade feature is enabled. * test interface example. Otherwise the auto-upgrade feature is enabled.
*/ */
if (_upgrade){ if (_module_upgrade == 1){
if (upgrade_callback_register(h, upgrade_2016, "urn:example:interfaces", 20140508, 20160101, NULL) < 0) if (upgrade_callback_register(h, upgrade_2016, "urn:example:interfaces", 20140508, 20160101, NULL) < 0)
goto done; goto done;
if (upgrade_callback_register(h, upgrade_2018, "urn:example:interfaces", 20160101, 20180220, NULL) < 0) if (upgrade_callback_register(h, upgrade_2018, "urn:example:interfaces", 20160101, 20180220, NULL) < 0)

View file

@ -265,7 +265,6 @@ text_read_modstate(clicon_handle h,
goto done; goto done;
} }
} }
continue; /* ignore other tags, such as module-set-id */
if (strcmp(xml_name(xm), "module")) if (strcmp(xml_name(xm), "module"))
continue; /* ignore other tags, such as module-set-id */ continue; /* ignore other tags, such as module-set-id */
if ((name = xml_find_body(xm, "name")) == NULL) if ((name = xml_find_body(xm, "name")) == NULL)

View file

@ -373,6 +373,10 @@ xp_eval_step(xp_ctx *xc0,
if (cxvec_append(x, &xc->xc_nodeset, &xc->xc_size) < 0) if (cxvec_append(x, &xc->xc_nodeset, &xc->xc_size) < 0)
goto done; goto done;
} }
if (vec){
free(vec);
vec = NULL;
}
break; break;
case A_DESCENDANT: case A_DESCENDANT:
for (i=0; i<xc->xc_size; i++){ for (i=0; i<xc->xc_size; i++){

View file

@ -81,7 +81,7 @@ EOF
) )
testrun(){ testrun(){
new "test params: -f $cfg" new "test params: -f $cfg -- -U"
# Bring your own backend # Bring your own backend
if [ $BE -ne 0 ]; then if [ $BE -ne 0 ]; then
# kill old backend (if any) # kill old backend (if any)
@ -90,8 +90,8 @@ testrun(){
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err err
fi fi
new "start backend -s startup -f $cfg" new "start backend -s startup -f $cfg -- -U"
start_backend -s startup -f $cfg start_backend -s startup -f $cfg -- -U
new "waiting" new "waiting"
wait_backend wait_backend