27 lines
997 B
Python
27 lines
997 B
Python
from typing import Dict
|
|
import logging
|
|
from redis import Redis
|
|
import requests
|
|
from config import Config
|
|
|
|
from urllib.parse import urljoin
|
|
|
|
|
|
def run(redis_client: Redis, site_url_map: Dict[str, str]):
|
|
# Get weather report
|
|
# get {http://example.com/report/}{site} The first part supplied
|
|
logging.debug("Getting performance reports...")
|
|
r = requests.get(urljoin(Config.COLLECTOR_URL, "site"), timeout=10)
|
|
r.raise_for_status()
|
|
|
|
# TODO:
|
|
# - set the default scheduling site
|
|
# - Check if scheduling is required: any derivatives are above 0 for an extended period
|
|
# - if yes, then decide where to schedule
|
|
# - any sites with 0 derivative?
|
|
# - Check the k8s api before scheduling to see if the pod is running
|
|
# - check if there are any pod running where 0 units scheduled for extended time
|
|
# - delete that pod
|
|
# - write some log, so we can draw nice graphs
|
|
# Optional: check if a higher priority pod have free capacity, and move lower ones up
|