project-pegaprox icon indicating copy to clipboard operation
project-pegaprox copied to clipboard

Automated Jobs and Schedules don't work.

Open nikcomp opened this issue 9 months ago • 1 comments

Doesn't work for me. I had to "vibe' code it to isolate what could be wrong. THe following was my summary and fix. We hit crashes/exceptions because get_client_ip() accessed flask.request unconditionally. When called from background threads (scheduler/metrics/etc.), there is no Flask request context, so request.headers / request.remote_addr can raise and take down that code path.

Issue 1 pegaprox_multi_cluster.py issues Minimal fix: make get_client_ip() return "system" when there is no Flask request context, while preserving the original header precedence when there is a request context.

Environment / Location (Bad File) Container prompt: root@pegaprox:/opt/PegaProx# File: /opt/PegaProx/pegaprox_multi_cluster.py Function around line: ~15227

Original behavior (problem)

get_client_ip() did: request.headers.get('X-Forwarded-For') → first IP else request.headers.get('X-Real-IP') else request.remote_addr …but did so without checking request context, so background-thread callers could throw.

Code change cd /opt/PegaProx

backup

cp -a pegaprox_multi_cluster.py pegaprox_multi_cluster.py.bak.$(date +%F_%H%M%S)

patch get_client_ip() to not require a Flask request context

perl -0777 -i -pe 's/def get_client_ip():\n\s+"""Get client IP address from request"""\n\s+if request.headers.get(\x27X-Forwarded-For\x27):\n\s+return request.headers.get(\x27X-Forwarded-For\x27).split(\x27,\x27)[0].strip()\n\s+elif request.headers.get(\x27X-Real-IP\x27):\n\s+return request.headers.get(\x27X-Real-IP\x27)\n\s+else:\n\s+return request.remote_addr/def get_client_ip():\n """Get client IP address from request (if available).\n\n Background threads (scheduler/metrics/etc.) run without a Flask request context.\n """\n try:\n from flask import has_request_context\n if not has_request_context():\n return "system"\n\n if request.headers.get("X-Forwarded-For"):\n return request.headers.get("X-Forwarded-For").split(",")[0].strip()\n elif request.headers.get("X-Real-IP"):\n return request.headers.get("X-Real-IP")\n else:\n return request.remote_addr\n except Exception:\n return "system"/s' pegaprox_multi_cluster.py

verify changed region

nl -ba pegaprox_multi_cluster.py | sed -n '15220,15275p'

Restart After restarting pegaprox I was able to schedule a job, see it complete and it worked.

Time Issue Pegaprox doesn't appear to have a place to set the time (region you are in) I needed to go into shell and set the time.
I coudld see in database when scheduling it was 5 hours offset (off)

nikcomp avatar Feb 27 '26 02:02 nikcomp

Hi,

please update PegaProx to the newest version.

Regards, Marcus

mkellermann97 avatar Feb 27 '26 10:02 mkellermann97