Skip to content

Docker: Add missing package to Python venv #2917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ RUN apt-get -qqy update \
&& apt-get upgrade -yq \
&& apt-get -qqy --no-install-recommends install \
python3 python3-pip python3-venv \
&& python3 -m pip install --upgrade setuptools virtualenv requests --break-system-packages \
&& python3 -m pip install --upgrade setuptools virtualenv --break-system-packages \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
&& echo "source $VENV_PATH/bin/activate" >> /etc/bash.bashrc

Expand Down Expand Up @@ -187,7 +187,7 @@ RUN ARCH=$(if [ "$(dpkg --print-architecture)" = "amd64" ]; then echo "x86_64";
USER ${SEL_UID}:${SEL_GID}

RUN python3 -m venv $VENV_PATH \
&& $VENV_PATH/bin/python3 -m pip install --upgrade pip setuptools virtualenv psutil \
&& $VENV_PATH/bin/python3 -m pip install --upgrade pip setuptools virtualenv psutil requests \
&& wget -q https://github.com/Supervisor/supervisor/archive/refs/heads/main.zip -O /tmp/supervisor.zip \
&& unzip /tmp/supervisor.zip -d /tmp \
&& cd /tmp/supervisor-main \
Expand Down
23 changes: 12 additions & 11 deletions Video/validate_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
import sys
import os
import base64
import json
from datetime import datetime
from datetime import timezone
from urllib.parse import urlparse
import requests
from requests.adapters import HTTPAdapter


def get_timestamp():
Expand Down Expand Up @@ -49,14 +46,15 @@ def get_basic_auth():
return {}


def validate_endpoint(endpoint, graphql_endpoint=False, max_time=1):
def validate_endpoint(endpoint, graphql_endpoint=False, connection_timeout=5, read_timeout=5):
"""
Validate an endpoint by making HTTP request and checking status code.

Args:
endpoint (str): The endpoint URL to validate
graphql_endpoint (bool): Whether this is a GraphQL endpoint
max_time (int): Maximum time for request in seconds
connection_timeout (int): Connection timeout in seconds
read_timeout (int): Read timeout in seconds
"""
process_name = "endpoint.checks"
session = create_session()
Expand All @@ -75,22 +73,23 @@ def validate_endpoint(endpoint, graphql_endpoint=False, max_time=1):
endpoint,
headers=headers,
json=data,
timeout=max_time,
timeout=(connection_timeout, read_timeout),
verify=False # Equivalent to curl's -k flag
)
else:
# Regular endpoint check
response = session.get(
endpoint,
headers=headers,
timeout=max_time,
timeout=(connection_timeout, read_timeout),
verify=False # Equivalent to curl's -k flag
)

status_code = response.status_code

except requests.exceptions.Timeout:
print(f"{get_timestamp()} [{process_name}] - Endpoint {endpoint} timed out after {max_time} seconds")
print(
f"{get_timestamp()} [{process_name}] - Endpoint {endpoint} timed out (connection: {connection_timeout}s, read: {read_timeout}s)")
return False
except requests.exceptions.ConnectionError:
print(f"{get_timestamp()} [{process_name}] - Failed to connect to endpoint {endpoint}")
Expand All @@ -104,12 +103,14 @@ def validate_endpoint(endpoint, graphql_endpoint=False, max_time=1):
print(f"{get_timestamp()} [{process_name}] - Endpoint {endpoint} is not found - status code: {status_code}")
return False
elif status_code == 401:
print(f"{get_timestamp()} [{process_name}] - Endpoint {endpoint} requires authentication - status code: {status_code}. Please provide valid credentials via SE_ROUTER_USERNAME and SE_ROUTER_PASSWORD environment variables.")
print(
f"{get_timestamp()} [{process_name}] - Endpoint {endpoint} requires authentication - status code: {status_code}. Please provide valid credentials via SE_ROUTER_USERNAME and SE_ROUTER_PASSWORD environment variables.")
return False
elif status_code != 200:
print(f"{get_timestamp()} [{process_name}] - Endpoint {endpoint} is not available - status code: {status_code}")
return False

print(f"{get_timestamp()} [{process_name}] - Endpoint {endpoint} is reachable - status code: {status_code}")
return True


Expand All @@ -123,10 +124,10 @@ def main():

endpoint = sys.argv[1]
graphql_endpoint = len(sys.argv) > 2 and sys.argv[2].lower() == 'true'
max_time = int(os.environ.get('SE_ENDPOINT_CHECK_TIMEOUT', 1))
max_time = int(os.environ.get('SE_ENDPOINT_CHECK_TIMEOUT', 5))

# Validate the endpoint
success = validate_endpoint(endpoint, graphql_endpoint, max_time)
success = validate_endpoint(endpoint, graphql_endpoint, max_time, max_time)

# Exit with appropriate code
sys.exit(0 if success else 1)
Expand Down
Loading