Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Upgrading to State Conductor 1.0.0

Tyler Replogle edited this page Jan 11, 2021 · 22 revisions

The update from State conductor 0.x.x to 1.0.0 is a major change because the code, files and vernacular has been changed to align more fulling to amazon state language. Here is a list of the changes that are needed in order to upgrade to 1.0.0

  1. Change the mlBundle to 1.0.0 in the dependencies section of the build.gradle file dependencies { mlBundle "com.marklogic:marklogic-state-conductor:1.0.0" }

errors that happen when going to 1.0.0

Task :state-conductor-dhf5-example:mlDeployApp FAILED Logging HTTP response body to assist with debugging: {"errorResponse":{"statusCode":"500", "status":"Internal Server Error", "messageCode":"CMA-ERRORCONFIG", "message":"CMA-ERRORCONFIG (err:FOER0000): MANAGE-CONFLICTINGCONFIGerr:FOER00001.0-mlA conflict has been detected:MANAGE-CONFLICTINGCONFIG: (err:FOER0000) A conflict has been detected: roles differ.false roles differ./MarkLogic/manage/models/security-model.xqy39056umod:check-same-strings((), "state-conductor-execute-role", "roles")str1()str2"state-conductor-execute-role"desc"roles"diff1()diff2"state-conductor-execute-role"1.0-ml/MarkLogic/manage/models/security-model.xqy38694umod:check-same-roles((), <role xmlns="http://marklogic.com/manage/lib/security-util\">......)names"state-conductor-state-machine"roles"/state-conductor-state-machine/"rnames"uri"1.0-ml/MarkLogic/manage/models/security-model.xqy4787umod:check-privilege-update-idempotent("state-conductor-state-machine", "/state-conductor-state-machine/", "uri", ())priv-name"state-conductor-state-machine"action"/state-conductor-state-machine/"kind"uri"role-names()prividxs:unsignedLong("7338941581871077300")priv<privilege xmlns="http://marklogic.com/manage/lib/security-util\">...1.0-ml/MarkLogic/manage/models/security-model.xqy461512smod:create-privilege("uri", "state-conductor-state-machine", "/state-conductor-state-machine/", ())kind"uri"priv-name"state-conductor-state-machine"action"/state-conductor-state-machine/"roles()()checkid"state-conductor-state-machine"action"/state-conductor-state-machine/"1.0-ml/MarkLogic/manage/endpoints/security/privileges.xqy3645xdmp:function(fn:QName("http://marklogic.com/manage/endpoints/security/privileges\",\"create-privilege\"))(\"v2\")version\"v2\"bodytext{\"{&quot;kind&quot;:&quot;uri", "action":"/state..."}xml<privilege-properties xmlns="http://marklogic.com/manage/privilege/properties\">...prop<privilege-properties xmlns="http://marklogic.com/manage/privilege/properties\">...()kind"uri"priv-name"state-conductor-state-machine"action"/state-conductor-state-machine/"roles()1.0-ml/MarkLogic/manage/endpoints/resource.xqy66614res:set-resource-properties("privilege", text{"{"kind":"uri", "action":"/state..."}, "privilege-list", map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>))paramsxs:unsignedLong("0")()()funcmap:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>)1.0-ml/MarkLogic/manage/manage-impl.xqy15921function() as item()()xs:unsignedLong("0")()_()paramsmap:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>)1.0-ml/xdmp:invoke(function() as item(), <options xmlns="xdmp:eval">0.......)1.0-ml/MarkLogic/appservices/utils/higher-order.xqy1902hof:apply-in(xs:unsignedLong("4650768058491397800"), 0, function() as item(), "auto")databasexs:unsignedLong("4650768058491397800")modulesxs:unsignedLong("0")ffunction() as item()mode"auto"1.0-ml/MarkLogic/appservices/utils/higher-order.xqy1542hof:apply-in(xs:unsignedLong("4650768058491397800"), function() as item())1.0-ml/MarkLogic/manage/manage-impl.xqy1330impl:set-properties("privilege", text{"{"kind":"uri", "action":"/state..."}, "json", map:map())1.0-ml/MarkLogic/manage/manage.xqy58611manage:resource-create("privilege", text{"{"kind":"uri", "action":"/state..."}, "json", map:map())1.0-ml/MarkLogic/manage/manage.xqy5744manage:resource-create("privilege", text{"{"kind":"uri", "action":"/state..."}, "json")1.0-ml/MarkLogic/manage/manage.xqy4964manage:privilege-create(text{"{"kind":"uri", "action":"/state..."}, "json")1.0-ml/MarkLogic/manage/manage.xqy120525function() as item()()priv-exists()1.0-ml/MarkLogic/manage/manage.xqy121020function(item(), item()) as item()((), function() as item())result()ifunction() as item()1.0-ml/MarkLogic/manage/manage.xqy120711manage:apply-config-json(object-node{"privilege":array-node{object-node{"kind":text{"execute"}, "action":text{"..."}, ...}, ...}}, "json", map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>))configurationobject-node{"privilege":array-node{object-node{"kind":text{"execute"}, "action":text{"..."}, ...}, ...}}format"json"paramsmap:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>)update-resource"true"delete-resource()configobject-node{"privilege":array-node{object-node{"kind":text{"execute"}, "action":text{"..."}, ...}, ...}}op()forest-funcs()database-funcs()server-funcs()group-funcs()host-funcs()user-funcs()role-funcs()protected-path-funcs()query-roleset-funcs()amp-funcs()priv-funcs(function() as item(), function() as item(), function() as item(), ...)1.0-ml/MarkLogic/manage/cma-impl.xqy25531cimpl:apply-config(json:object(<json:object xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>), map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>), (), "json")configjson:object(<json:object xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>)config-optionsmap:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>)params()format"json"config-optionsmap:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>)configjson:object(<json:object xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>)params()seqjson:object(<json:object xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>)cjson:object(<json:object xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>)cobject-node{"privilege":array-node{object-node{"kind":text{"execute"}, "action":text{"..."}, ...}, ...}}1.0-ml/MarkLogic/cma.xqy1164cma:apply-config(json:object(<json:object xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>), map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>), (), "json")configmc:get-manage-apply-config#1config-options11.0-ml/MarkLogic/manage/models/config-model.xqy4616confmod:apply-config(map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" .../>), text{"{ "config" : [ { "privilege..."}, "json")contextmc:get-manage-apply-config#1config11.0-ml/MarkLogic/manage/endpoints/config/config.xqy13910mc:get-manage-apply-config#1("")versionmc:get-manage-apply-config#1config11.0-ml/MarkLogic/manage/endpoints/resource.xqy49512res:mux(mc:get-manage-apply-config#1, xs:untypedAtomic("1"))fnmc:get-manage-apply-config#1arity11.0-ml/MarkLogic/manage/endpoints/resource.xqy45722res:process-request("manage-config", "POST", fn:true())request-id"manage-config"method"POST"cachefn:true()func<func id="manage-config" path="^/manage/v3/?$">http://marklogic......f-nsxs:untypedAtomic("http://marklogic.com/manage/endpoints/manage-config")f-namexs:untypedAtomic("get-manage-apply-config")arityxs:untypedAtomic("1")_xs:unsignedLong("17")_xs:unsignedLong("1")fnmc:get-manage-apply-config#1statusfunction(item()*) as item()*convert()gzip()1.0-mlmanage/resource-rewriter.xqy2581.0-ml"}} Error occurred while sending POST request to /manage/v3; logging request body to assist with debugging: { "config" : [ { "privilege" : [ { "privilege-name" : "state-conductor-execute", "action" : "http://marklogic.com/state-conductor/privilege/execute", "kind" : "execute" }, { "privilege-name" : "state-conductor-state-machine", "action" : "/state-conductor-state-machine/", "kind" : "uri" }, { "privilege-name" : "dhf-internal-data-hub", "action" : "/data-hub/", "kind" : "uri" }, { "privilege-name" : "dhf-internal-entities", "action" : "/entities/", "kind" : "uri" }, { "privilege-name" : "dhf-internal-mappings", "action" : "/mappings/", "kind" : "uri" }, { "privilege-name" : "dhf-internal-trace-ui", "action" : "/trace-ui/", "kind" : "uri" } ] } ] }

Error occurred while sending POST request to /manage/v3; logging request body to assist with debugging: { "config" : [ { "privilege" : [ { "privilege-name" : "state-conductor-execute", "action" : "http://marklogic.com/state-conductor/privilege/execute", "kind" : "execute" }, { "privilege-name" : "state-conductor-state-machine", "action" : "/state-conductor-state-machine/", "kind" : "uri" } ] }, { "role" : [ { "role-name" : "state-conductor-reader-role", "description" : "Permits reading stateMachine documents and knowing stateMachine status" }, { "role-name" : "state-conductor-execution-writer-role", "description" : "Permits reading stateMachine documents and knowing stateMachine status", "role" : [ "state-conductor-reader-role" ], "privilege" : [ { "privilege-name" : "state-conductor-execute", "action" : "http://marklogic.com/state-conductor/privilege/execute", "kind" : "execute" }, { "privilege-name" : "state-conductor-execution", "action" : "/state-conductor/", "kind" : "uri" } ] }, { "role-name" : "state-conductor-operator", "description" : "Permits operating a state conductor, such as running stateMachines and viewing execution data.", "role" : [ "rest-extension-user", "rest-reader", "state-conductor-execution-writer-role" ], "privilege" : [ { "privilege-name" : "any-uri", "action" : "http://marklogic.com/xdmp/privileges/any-uri", "kind" : "execute" }, { "privilege-name" : "xdmp:eval", "action" : "http://marklogic.com/xdmp/privileges/xdmp-eval", "kind" : "execute" }, { "privilege-name" : "xdmp:eval-in", "action" : "http://marklogic.com/xdmp/privileges/xdmp-eval-in", "kind" : "execute" }, { "privilege-name" : "xdmp:document-load", "action" : "http://marklogic.com/xdmp/privileges/xdmp-document-load", "kind" : "execute" }, { "privilege-name" : "rest-writer", "action" : "http://marklogic.com/xdmp/privileges/rest-writer", "kind" : "execute" } ] }, { "role-name" : "state-conductor-execute-role", "description" : "Permits reading stateMachine documents and knowing stateMachine status", "role" : [ "state-conductor-execution-writer-role" ], "privilege" : [ { "privilege-name" : "state-conductor-state-machine", "action" : "/state-conductor-state-machine/", "kind" : "uri" } ] }, { "role-name" : "state-conductor-developer", "description" : "Permits developing and operating Marklogic State onductor", "role" : [ "state-conductor-execute-role", "rest-reader", "rest-extension-user" ], "privilege" : [ { "privilege-name" : "any-uri", "action" : "http://marklogic.com/xdmp/privileges/any-uri", "kind" : "execute" }, { "privilege-name" : "xdmp:eval", "action" : "http://marklogic.com/xdmp/privileges/xdmp-eval", "kind" : "execute" }, { "privilege-name" : "xdmp:eval-in", "action" : "http://marklogic.com/xdmp/privileges/xdmp-eval-in", "kind" : "execute" }, { "privilege-name" : "xdmp:document-load", "action" : "http://marklogic.com/xdmp/privileges/xdmp-document-load", "kind" : "execute" }, { "privilege-name" : "rest-writer", "action" : "http://marklogic.com/xdmp/privileges/rest-writer", "kind" : "execute" } ] } ] } ] }

Query to run before deploying to remove old roles

// removed all state conductor roles

run this query

'use strict';
// execute this against the security database
declareUpdate();
if (xdmp.databaseName(xdmp.database()) !== "Security"){
  "Your database is not set as Security change you database to Security"
} else {


const sec = require('/MarkLogic/security.xqy');

//removes all state-conductor privileges
xdmp.privileges().toArray().map(function(item){
  return { name: xdmp.privilegeName(item),
           kind: xdmp.privilegeKind(item),
           id: item
         }
}).filter(item => item.name.startsWith("state-conductor")).map(function(item){
  let doc = fn.head(cts.search(cts.andQuery([cts.elementValueQuery(fn.QName("http://marklogic.com/xdmp/security","privilege-id"), item.id.toString()),cts.collectionQuery("http://marklogic.com/xdmp/privileges")])))
  item.action = doc.xpath("sec:privilege/sec:action/text()", {"sec":"http://marklogic.com/xdmp/security"}).toString()
  return sec.removePrivilege(item.action, item.kind)
})

//removes all state-conductor roles
  sec.getRoleNames().toArray().map(item => item.xpath('text()').toString()).filter(item => item.startsWith("state-conductor")).forEach(function(item){
  //call it this way to not get conflicing updates
  let uri = cts.uris(null,null,cts.andQuery([cts.elementValueQuery(fn.QName("http://marklogic.com/xdmp/security","role-name"), item),cts.collectionQuery("http://marklogic.com/xdmp/roles")]))
  sec.removeRoleFromUsers(item);
  sec.removeRoleFromAmps(item);
  xdmp.documentDelete(uri);
})

}

Things you should do to clean up

  • remove old jobs database (its been moved to executions)
  • Change flow files to fit State machine
  • Use 1.0.0 version of the State Conductor Driver