mirror of
https://github.com/PegaProx/project-pegaprox.git
synced 2026-04-25 18:15:50 +03:00
[GH-ISSUE #87] Automated Jobs and Schedules don't work. #66
Labels
No labels
Approved
Q2-3 2026 Development
bug
documentation
enhancement
help wanted
invalid
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/project-pegaprox-PegaProx#66
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @nikcomp on GitHub (Feb 27, 2026).
Original GitHub issue: https://github.com/PegaProx/project-pegaprox/issues/87
Originally assigned to: @mkellermann97 on GitHub.
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)
@mkellermann97 commented on GitHub (Feb 27, 2026):
Hi,
please update PegaProx to the newest version.
Regards,
Marcus