openshift-python-scale-utilities
Pypi: openshift-python-scale-utilities
Utilities to assist in scaling openshift-python-wrapper resources
ocp_scale_utilities.threaded
Utilizes ThreadPoolExecutor to operate on many resources in parallel across multiple threads.
Usage
from ocp_resources.virtual_machine import VirtualMachine
from ocp_scale_utilities.threaded.utils import (
threaded_deploy_resources,
threaded_delete_resources,
threaded_wait_deleted_resources,
)
from ocp_scale_utilities.threaded.scale import ThreadedScaleResources
# Create iterable of VirtualMachine python objects to deploy
# Be sure to use deepcopy() when passing dicts to objects to avoid collisions
vms = [VirtualMachine(..., body=deepcopy(body))]
# Option A:
def funcA():
threaded_deploy_resources(resources=vms)
yield vms
threaded_delete_resources(resources=vms)
threaded_wait_deleted_resources(resources=vms)
# Option B:
def funcB():
with ThreadedScaleResources(resources=vms, wait_for_status=VirtualMachine.Status.RUNNING):
yield vms
ocp_scale_utilities.monitoring
MonitorResourceAPIServerRequests provides a way to monitor a specific resource to determine if it is being actively used.
This allows the ability to wait for resources to settle after a major scale action,
improving reliability, and increasing readability in prometheus data.
Usage
from ocp_resources.virtual_machine import VirtualMachine
from ocp_scale_utilities.monitoring import MonitorResourceAPIServerRequests
from ocp_scale_utilities.threaded.scale import ThreadedScaleResources
from ocp_utilities.monitoring import Prometheus
monitor_api_requests = MonitorResourceAPIServerRequests(
prometheus=Prometheus(...),
resource_class=VirtualMachine,
idle_requests_value=float(...), # Based on apiserver_request_total metric
)
monitor_api_requests.wait_for_idle()
with ThreadedScaleResources(resources=vms):
monitor_api_requests.wait_for_idle()
yield vms
monitor_api_requests.wait_for_idle()
ocp_scale_utilities.logger
Logging at scale requires utilizing logging.QueueHandlers to avoid logging to closed streams.
root QueueHandler ┐ ┌> StreamHandler
├> Queue -> QueueListener ┤
basic QueueHandler ┘ └> FileHandler
Usage
main.py
import logging
from ocp_scale_utilities.logger import setup_logging
from module import func
LOGGER = None
def main():
LOGGER.warning("main logged warning message")
func()
if __name__ == "__main__":
log_listener = setup_logging(log_level=logging.WARNING, log_file="/tmp/example.log")
LOGGER = logging.getLogger(__name__)
main()
log_listener.stop()
module.py
import logging
LOGGER = logging.getLogger(__name__)
def func():
LOGGER.warning("func logged warning message")
Contributing
Please use pre-commit to check the code before commiting
pre-commit install
Metadata
Release files for openshift-python-scale-utilities 0.1.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openshift_python_scale_utilities-0.1.1.7.tar.gz | 160.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openshift_python_scale_utilities-0.1.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 172.4 kB
Release files / openshift_python_scale_utilities-0.1.1.7.tar.gz
| Download URL | openshift_python_scale_utilities-0.1.1.7.tar.gz |
|---|---|
| Size | 160.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
384db2a35a1ef63a04fd50ada50722cdbcb20d3bee2f6c9f4f7a23c5b940afd9
|
|
BLAKE2b-256 checksum How to use checksums |
57a89f06ae11c2438e9b28113ddb6de0eb8486773270e2674f3d08b628132a47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / openshift_python_scale_utilities-0.1.1.7-py3-none-any.whl
| Download URL | openshift_python_scale_utilities-0.1.1.7-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a03cc0046c21eb90a242e58d5b5e82aa45df429204088011decf1b222246259
|
|
BLAKE2b-256 checksum How to use checksums |
2897787003a783cf7cf2ef5df5aae39f67d9871a9fddf25906666ed9e54ece8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|