FOUR-30789: Fix Nayra REST host resolution for multitenant script execution#8824
FOUR-30789: Fix Nayra REST host resolution for multitenant script execution#8824eiresendez wants to merge 5 commits into
Conversation
|
QA server K8S was successfully deployed https://tenant-1.ci-87f9422be1.engk8s.processmaker.net |
|
Thanks, Nolan, for generating the QA CI server: After running the same test performed on my local using the route above, the fix is still not correct and the issue is reproducible in QA. The following endpoint is returning HTTP 500 errors:
I think I may need the exact configuration from a real multitenant production environment in order to validate and provide an accurate fix. I will try to get that again. |
|
QA server K8S was successfully deployed https://tenant-1.ci-87f9422be1.engk8s.processmaker.net |
|
QA server K8S was successfully deployed https://tenant-1.ci-87f9422be1.engk8s.processmaker.net |
|
QA server K8S was successfully deployed https://tenant-1.ci-87f9422be1.engk8s.processmaker.net |
Resolve the Nayra endpoint using the Docker-reported container IP when PHPUnit runs inside a local Docker network such as pm4-tools_default, while preserving remote Docker and published-port behavior.\n\nAdd warning-level runtime diagnostics so the multitenant CI/CD 500 can be debugged with the server's LOG_LEVEL=warning configuration.
|
|
QA server K8S was successfully deployed https://tenant-1.ci-87f9422be1.engk8s.processmaker.net |
|
Closing this PR. This PR went further into the multitenant fallback path without |






Issue & Reproduction Steps
FOUR-30789 tracks a multitenant server error while creating a new report from an Expense Report process generated from a Guide Template.
The failing flow triggers synchronous
php-nayrascript execution from the task edit/report flow. In QA, the endpoint still returned HTTP 500 after the first fix:POST /api/1.0/scripts/execute/42?task_id=3746Root Cause
The original fix assumed real multitenant environments would provide
NAYRA_REST_API_HOST, so the php-nayra runner could always prioritize that configured REST endpoint.After comparing the local
.envwith a real production-like multitenant pod env, that assumption was wrong. The real config does not defineNAYRA_REST_API_HOST. Instead, it uses remote Docker:MULTITENANCY=truePROCESSMAKER_SCRIPTS_DOCKER_HOST=tcp://qa-remotedocker:2375NAYRA_REST_API_HOSTIn that configuration, the old fallback still tried to resolve or start a tenant-specific Nayra container using the tenant-mutated
app.instance, for exampleprocessmaker_3_nayra, then use Docker bridge/container IPs such as172.x.x.xas the REST base URL.That is not reliable for real multitenant deployments because the web app must call a reachable HTTP endpoint, not an internal Docker bridge IP. It also should not create a separate Nayra REST service per tenant when the request already carries script code, data, config, environment variables, and timeout.
Solution
NAYRA_REST_API_HOSTas the highest-priority explicit override when configured.NAYRA_REST_API_HOST, resolve Nayra to a reachable endpoint:http://127.0.0.1:<nayra_port>PROCESSMAKER_SCRIPTS_DOCKER_HOST, for examplehttp://qa-remotedocker:8080NAYRA_PORTvalues to8080so Docker does not publish Nayra on a random port.app.instancesuffix.nayra_endpointand invalidate it if the health check fails.NAYRA_REST_API_HOSTbehavior backward compatible.ScriptExecutorexplicit throughgetScriptExecutor()so static analysis no longer depends on an implicit private property fromBase.How to Test
Automated:
php -l ProcessMaker/Models/ScriptDockerNayraTrait.phpphp -l ProcessMaker/ScriptRunners/Base.phpphp -l tests/unit/ProcessMaker/Models/ScriptDockerNayraTraitTest.php./vendor/bin/phpunit tests/unit/ProcessMaker/Models/ScriptDockerNayraTraitTest.phpResult:
OK (9 tests, 21 assertions)Manual multitenant verification:
PROCESSMAKER_SCRIPTS_DOCKER_HOSTis set andNAYRA_REST_API_HOSTis not set.POST /api/1.0/scripts/execute/...returns200.ScriptDockerNayraTrait.phptimeout while resolving container bridge IPs.Related Ticket
ci:deploy
ci:multitenancy
ci:k8s-branch:fix-multitenancy