backend: Handle RPC errors
Use the new RPC error reporting interface to report RPC errors from plugins. Signed-off-by: Corey Minyard <minyard@acm.org>
This commit is contained in:
parent
9bdacc8671
commit
25f7c56c0a
3 changed files with 10 additions and 16 deletions
|
|
@ -723,7 +723,7 @@ from_client_edit_config(clixon_handle h,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((ret = candidate_commit(h, NULL, "candidate", myid, 0, cbret)) < 0){ /* Assume validation fail, nofatal */
|
if ((ret = candidate_commit(h, NULL, "candidate", myid, 0, cbret)) < 0){ /* Assume validation fail, nofatal */
|
||||||
if (netconf_operation_failed(cbret, "application", clixon_err_reason())< 0)
|
if (clixon_plugin_report_err(h, cbret) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
xmldb_copy(h, "running", "candidate");
|
xmldb_copy(h, "running", "candidate");
|
||||||
goto ok;
|
goto ok;
|
||||||
|
|
|
||||||
|
|
@ -637,7 +637,7 @@ candidate_validate(clixon_handle h,
|
||||||
* TODO: -1 return should be fatal error, not failed validation
|
* TODO: -1 return should be fatal error, not failed validation
|
||||||
*/
|
*/
|
||||||
if (!cbuf_len(cbret) &&
|
if (!cbuf_len(cbret) &&
|
||||||
netconf_operation_failed(cbret, "application", clixon_err_reason())< 0)
|
clixon_plugin_report_err(h, cbret) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
@ -857,7 +857,7 @@ from_client_commit(clixon_handle h,
|
||||||
if ((ret = candidate_commit(h, xe, "candidate", myid, 0, cbret)) < 0){ /* Assume validation fail, nofatal */
|
if ((ret = candidate_commit(h, xe, "candidate", myid, 0, cbret)) < 0){ /* Assume validation fail, nofatal */
|
||||||
clixon_debug(CLIXON_DBG_BACKEND, "Commit candidate failed");
|
clixon_debug(CLIXON_DBG_BACKEND, "Commit candidate failed");
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
if (netconf_operation_failed(cbret, "application", clixon_err_reason())< 0)
|
if (clixon_plugin_report_err(h, cbret) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,7 @@ clixon_plugin_statedata_one(clixon_plugin_t *cp,
|
||||||
if (fn(h, nsc, xpath, x) < 0){
|
if (fn(h, nsc, xpath, x) < 0){
|
||||||
if (clixon_resource_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
if (clixon_resource_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (clixon_err_category() < 0)
|
if (clixon_err_category() < 0 && !clixon_plugin_rpc_err_set(h))
|
||||||
clixon_log(h, LOG_WARNING, "%s: Internal error: State callback in plugin: %s returned -1 but did not make a clixon_err call",
|
clixon_log(h, LOG_WARNING, "%s: Internal error: State callback in plugin: %s returned -1 but did not make a clixon_err call",
|
||||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||||
goto fail; /* Dont quit here on user callbacks */
|
goto fail; /* Dont quit here on user callbacks */
|
||||||
|
|
@ -342,7 +342,6 @@ clixon_plugin_statedata_all(clixon_handle h,
|
||||||
int ret;
|
int ret;
|
||||||
cxobj *x = NULL;
|
cxobj *x = NULL;
|
||||||
clixon_plugin_t *cp = NULL;
|
clixon_plugin_t *cp = NULL;
|
||||||
cbuf *cberr = NULL;
|
|
||||||
cxobj *xerr = NULL;
|
cxobj *xerr = NULL;
|
||||||
|
|
||||||
clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
|
clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
|
||||||
|
|
@ -350,14 +349,10 @@ clixon_plugin_statedata_all(clixon_handle h,
|
||||||
if ((ret = clixon_plugin_statedata_one(cp, h, nsc, xpath, &x)) < 0)
|
if ((ret = clixon_plugin_statedata_one(cp, h, nsc, xpath, &x)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 0){
|
if (ret == 0){
|
||||||
if ((cberr = cbuf_new()) == NULL){
|
|
||||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
/* error reason should be in clixon_err_reason */
|
/* error reason should be in clixon_err_reason */
|
||||||
cprintf(cberr, "Internal error, state callback in plugin %s returned invalid XML: %s",
|
if (clixon_plugin_report_err_xml(h, &xerr,
|
||||||
clixon_plugin_name_get(cp), clixon_err_reason());
|
"Internal error, state callback in plugin %s returned invalid XML: %s",
|
||||||
if (netconf_operation_failed_xml(&xerr, "application", cbuf_get(cberr)) < 0)
|
clixon_plugin_name_get(cp), clixon_err_reason()) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
xml_free(*xret);
|
xml_free(*xret);
|
||||||
*xret = xerr;
|
*xret = xerr;
|
||||||
|
|
@ -406,8 +401,6 @@ clixon_plugin_statedata_all(clixon_handle h,
|
||||||
done:
|
done:
|
||||||
if (xerr)
|
if (xerr)
|
||||||
xml_free(xerr);
|
xml_free(xerr);
|
||||||
if (cberr)
|
|
||||||
cbuf_free(cberr);
|
|
||||||
if (x)
|
if (x)
|
||||||
xml_free(x);
|
xml_free(x);
|
||||||
return retval;
|
return retval;
|
||||||
|
|
@ -611,8 +604,9 @@ plugin_transaction_call_one(clixon_handle h,
|
||||||
if (clixon_resource_check(h, &wh, clixon_plugin_name_get(cp), fnname) < 0)
|
if (clixon_resource_check(h, &wh, clixon_plugin_name_get(cp), fnname) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
if (!clixon_err_category()) /* sanity: log if clixon_err() is not called ! */
|
if (!clixon_plugin_rpc_err_set(h) && !clixon_err_category())
|
||||||
clixon_log(h, LOG_NOTICE, "%s: Plugin '%s' callback does not make clixon_err call on error",
|
/* sanity: log if err is not called ! */
|
||||||
|
clixon_log(h, LOG_NOTICE, "%s: Plugin '%s' callback does not make clixon_err or clixon_plugin_rpc_err call on error",
|
||||||
fnname, clixon_plugin_name_get(cp));
|
fnname, clixon_plugin_name_get(cp));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue