-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating entrypoint scripts to pre-create directories in /var/lib/pulp/ Adding skopeo dependency for content signing script Adding readyz.py and wait_on_postgres.py scripts for galaxy-operator healthchecks
- Loading branch information
Showing
5 changed files
with
102 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
import requests | ||
|
||
from requests.packages.urllib3.util.connection import HAS_IPV6 | ||
|
||
|
||
def is_api_healthy(path): | ||
""" | ||
Checks if API is healthy | ||
""" | ||
address = "[::1]" if HAS_IPV6 else "127.0.0.1" | ||
url = f"http://{address}:8000{path}" | ||
print(f"Readiness probe: checking {url}") | ||
response = requests.get(url, allow_redirects=True) | ||
data = response.json() | ||
|
||
if not data["database_connection"]["connected"]: | ||
print("Readiness probe: database issue") | ||
sys.exit(3) | ||
|
||
if os.getenv("REDIS_SERVICE_HOST") and not data["redis_connection"]["connected"]: | ||
print("Readiness probe: cache issue") | ||
sys.exit(4) | ||
|
||
print("Readiness probe: ready!") | ||
sys.exit(0) | ||
|
||
|
||
def is_content_healthy(path): | ||
""" | ||
Checks if Content is healthy | ||
""" | ||
address = "[::1]" if HAS_IPV6 else "127.0.0.1" | ||
url = f"http://{address}:24816{path}" | ||
print(f"Readiness probe checking {url}") | ||
response = requests.head(url) | ||
response.raise_for_status() | ||
|
||
print("Readiness probe: ready!") | ||
sys.exit(0) | ||
|
||
|
||
""" | ||
PID 1 value (/proc/1/cmdline) may vary based on the gunicorn install method (RPM vs pip) | ||
The cmdline value for this PID looks like: | ||
``` | ||
# pip installation | ||
gunicorn: master \[pulp-{content,api}\] | ||
``` | ||
OR | ||
``` | ||
# RPM installation | ||
/usr/bin/python3.9/usr/bin/gunicorn--bind[::]:2481{6,7}pulpcore.app.wsgi:application--namepulp-{api,content}--timeout90--workers2 | ||
``` | ||
""" | ||
with open("/proc/1/cmdline", "r") as f: | ||
cmdline = f.readline() | ||
|
||
if "pulp-api" in cmdline: | ||
is_api_healthy(sys.argv[1]) | ||
|
||
elif "pulp-content" in cmdline: | ||
is_content_healthy(sys.argv[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import time | ||
from django.db import connection, utils | ||
|
||
if __name__ == "__main__": | ||
|
||
print("Waiting on postgresql to start...") | ||
for dummy in range(100): | ||
try: | ||
connection.ensure_connection() | ||
break | ||
except utils.OperationalError: | ||
time.sleep(3) | ||
|
||
else: | ||
print("Unable to reach postgres.") | ||
sys.exit(1) | ||
|
||
print("Postgres started.") | ||
sys.exit(0) |