assemblyline-core 4.7.5.dev159__tar.gz → 4.7.5.dev163__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/PKG-INFO +1 -1
- assemblyline_core-4.7.5.dev163/assemblyline_core/VERSION +1 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/scaler/controllers/interface.py +10 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/scaler/controllers/kubernetes_ctl.py +55 -5
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/scaler/scaler_server.py +20 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core.egg-info/PKG-INFO +1 -1
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core.egg-info/SOURCES.txt +1 -0
- assemblyline_core-4.7.5.dev163/test/test_kubernetes_ctl.py +204 -0
- assemblyline_core-4.7.5.dev163/test/test_scaler.py +129 -0
- assemblyline_core-4.7.5.dev159/assemblyline_core/VERSION +0 -1
- assemblyline_core-4.7.5.dev159/test/test_scaler.py +0 -53
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/LICENCE.md +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/README.md +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/alerter/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/alerter/processing.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/alerter/run_alerter.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/archiver/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/archiver/run_archiver.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/badlist_client.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/dispatching/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/dispatching/client.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/dispatching/dispatcher.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/dispatching/schedules.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/expiry/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/expiry/run_expiry.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/ingester/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/ingester/constants.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/ingester/ingester.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/metrics/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/metrics/es_metrics.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/metrics/heartbeat_formatter.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/metrics/helper.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/metrics/metrics_server.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/metrics/run_heartbeat_manager.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/metrics/run_metrics_aggregator.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/metrics/run_statistics_aggregator.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/replay/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/replay/client.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/replay/creator/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/replay/creator/run.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/replay/creator/run_worker.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/replay/loader/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/replay/loader/run.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/replay/loader/run_worker.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/replay/replay.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/safelist_client.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/scaler/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/scaler/collection.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/scaler/controllers/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/scaler/controllers/docker_ctl.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/scaler/run_scaler.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/server_base.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/signature_client.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/submission_client.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/tasking_client.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/updater/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/updater/helper.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/updater/run_updater.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/vacuum/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/vacuum/crawler.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/vacuum/department_map.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/vacuum/safelist.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/vacuum/stream_map.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/vacuum/worker.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/workflow/__init__.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/workflow/run_workflow.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core.egg-info/dependency_links.txt +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core.egg-info/requires.txt +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core.egg-info/top_level.txt +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/pyproject.toml +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/setup.cfg +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_alerter.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_badlist_client.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_expiry.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_replay.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_safelist_client.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_scheduler.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_signature_client.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_tasking_client.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_updater_helper.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_vacuum.py +0 -0
- {assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_workflow.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4.7.5.dev163
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import math
|
|
2
4
|
from typing import TYPE_CHECKING, Optional
|
|
3
5
|
|
|
4
6
|
if TYPE_CHECKING:
|
|
@@ -32,6 +34,14 @@ class ControllerInterface:
|
|
|
32
34
|
"""Megabytes of RAM that has not been reserved."""
|
|
33
35
|
return self.memory_info()[0]
|
|
34
36
|
|
|
37
|
+
def pods_info(self) -> tuple[float, float]:
|
|
38
|
+
"""Return free and total pod slots in the system, unbounded where the orchestrator has no pod limit."""
|
|
39
|
+
return math.inf, math.inf
|
|
40
|
+
|
|
41
|
+
def free_pods(self) -> float:
|
|
42
|
+
"""Number of pod slots available for new containers."""
|
|
43
|
+
return self.pods_info()[0]
|
|
44
|
+
|
|
35
45
|
def get_target(self, service_name):
|
|
36
46
|
"""Get the target for running instances of a service."""
|
|
37
47
|
raise NotImplementedError()
|
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import base64
|
|
4
4
|
import functools
|
|
5
5
|
import json
|
|
6
|
+
import math
|
|
6
7
|
import os
|
|
7
8
|
import threading
|
|
8
9
|
import uuid
|
|
@@ -228,6 +229,30 @@ def get_resources(container) -> Tuple[float, float]:
|
|
|
228
229
|
return cpu_value, memory_value
|
|
229
230
|
|
|
230
231
|
|
|
232
|
+
def toleration_matches_taint(toleration: V1Toleration, taint: dict) -> bool:
|
|
233
|
+
"""Match a toleration against a raw node taint, following kube-scheduler's ToleratesTaint."""
|
|
234
|
+
if toleration.effect and toleration.effect != taint.get('effect'):
|
|
235
|
+
return False
|
|
236
|
+
if toleration.key and toleration.key != taint.get('key'):
|
|
237
|
+
return False
|
|
238
|
+
if toleration.operator == 'Exists':
|
|
239
|
+
return True
|
|
240
|
+
return (toleration.value or '') == (taint.get('value') or '')
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def node_is_schedulable(node: dict, tolerations: list[V1Toleration]) -> bool:
|
|
244
|
+
"""Check whether service pods with the given tolerations can be placed on a raw node object."""
|
|
245
|
+
spec = node.get('spec', {})
|
|
246
|
+
if spec.get('unschedulable'):
|
|
247
|
+
return False
|
|
248
|
+
for taint in spec.get('taints') or []:
|
|
249
|
+
if taint.get('effect') not in ('NoSchedule', 'NoExecute'):
|
|
250
|
+
continue
|
|
251
|
+
if not any(toleration_matches_taint(toleration, taint) for toleration in tolerations):
|
|
252
|
+
return False
|
|
253
|
+
return True
|
|
254
|
+
|
|
255
|
+
|
|
231
256
|
def create_docker_auth_config(image: str, username: str, password: str) -> str:
|
|
232
257
|
# Take the registry part of the image if set, use the default registry if no registry component is in the string
|
|
233
258
|
if '/' in image:
|
|
@@ -350,9 +375,10 @@ class KubernetesController(ControllerInterface):
|
|
|
350
375
|
quota_background = threading.Thread(target=self._loop_forever(self._monitor_quotas), daemon=True)
|
|
351
376
|
quota_background.start()
|
|
352
377
|
|
|
353
|
-
self.ready_nodes: dict[str, tuple[float, float]] = {}
|
|
378
|
+
self.ready_nodes: dict[str, tuple[float, float, float]] = {}
|
|
354
379
|
self._node_pool_max_ram: float = 0
|
|
355
380
|
self._node_pool_max_cpu: float = 0
|
|
381
|
+
self._node_pool_max_pods: float = 0
|
|
356
382
|
node_background = threading.Thread(target=self._loop_forever(self._monitor_node_pool), daemon=True)
|
|
357
383
|
node_background.start()
|
|
358
384
|
|
|
@@ -360,6 +386,7 @@ class KubernetesController(ControllerInterface):
|
|
|
360
386
|
self._pod_used_cpu: dict[str | None, float] = defaultdict(float)
|
|
361
387
|
self._pod_used_namespace_ram: dict[str | None, float] = defaultdict(float)
|
|
362
388
|
self._pod_used_namespace_cpu: dict[str | None, float] = defaultdict(float)
|
|
389
|
+
self._node_active_pods: dict[str | None, set[str]] = defaultdict(set)
|
|
363
390
|
self.node_count = 0
|
|
364
391
|
pod_background = threading.Thread(target=self._loop_forever(self._monitor_pods), daemon=True)
|
|
365
392
|
pod_background.start()
|
|
@@ -463,9 +490,10 @@ class KubernetesController(ControllerInterface):
|
|
|
463
490
|
def _monitor_node_pool(self) -> None:
|
|
464
491
|
self._node_pool_max_cpu = 0
|
|
465
492
|
self._node_pool_max_ram = 0
|
|
493
|
+
self._node_pool_max_pods = 0
|
|
466
494
|
self.node_count = 0
|
|
467
495
|
watch = Watch()
|
|
468
|
-
self.ready_nodes: dict[str, tuple[float, float]] = {}
|
|
496
|
+
self.ready_nodes: dict[str, tuple[float, float, float]] = {}
|
|
469
497
|
field_selector, label_selector = selector_to_list_filters(self.linux_node_selector)
|
|
470
498
|
|
|
471
499
|
for event in watch.stream(func=self.api.list_node, field_selector=field_selector,
|
|
@@ -485,10 +513,12 @@ class KubernetesController(ControllerInterface):
|
|
|
485
513
|
ready = condition['status'] == 'True'
|
|
486
514
|
break
|
|
487
515
|
|
|
488
|
-
if ready:
|
|
516
|
+
if ready and node_is_schedulable(event['raw_object'], self.default_service_tolerations):
|
|
489
517
|
cpu = parse_cpu(event['raw_object']['status']['allocatable']['cpu'])
|
|
490
518
|
ram = parse_memory(event['raw_object']['status']['allocatable']['memory'])
|
|
491
|
-
|
|
519
|
+
# A node that doesn't report a pod limit shouldn't stall scaling
|
|
520
|
+
pods = float(event['raw_object']['status']['allocatable'].get('pods', math.inf))
|
|
521
|
+
self.ready_nodes[name] = (cpu, ram, pods)
|
|
492
522
|
else:
|
|
493
523
|
self.ready_nodes.pop(name, None)
|
|
494
524
|
|
|
@@ -500,11 +530,14 @@ class KubernetesController(ControllerInterface):
|
|
|
500
530
|
self.node_count = len(self.ready_nodes)
|
|
501
531
|
max_cpu = 0.0
|
|
502
532
|
max_ram = 0.0
|
|
503
|
-
|
|
533
|
+
max_pods = 0.0
|
|
534
|
+
for cpu, ram, pods in self.ready_nodes.values():
|
|
504
535
|
max_cpu += cpu
|
|
505
536
|
max_ram += ram
|
|
537
|
+
max_pods += pods
|
|
506
538
|
self._node_pool_max_cpu = max_cpu
|
|
507
539
|
self._node_pool_max_ram = max_ram
|
|
540
|
+
self._node_pool_max_pods = max_pods
|
|
508
541
|
|
|
509
542
|
def _monitor_pods(self) -> None:
|
|
510
543
|
watch = Watch()
|
|
@@ -515,6 +548,7 @@ class KubernetesController(ControllerInterface):
|
|
|
515
548
|
self._pod_used_ram = defaultdict(float)
|
|
516
549
|
self._pod_used_namespace_cpu = defaultdict(float)
|
|
517
550
|
self._pod_used_namespace_ram = defaultdict(float)
|
|
551
|
+
self._node_active_pods = defaultdict(set)
|
|
518
552
|
|
|
519
553
|
kwargs = dict(WATCH_ARGS)
|
|
520
554
|
if self.cluster_pod_list:
|
|
@@ -543,6 +577,13 @@ class KubernetesController(ControllerInterface):
|
|
|
543
577
|
namespaced_containers = per_node_namespaced_containers[node]
|
|
544
578
|
|
|
545
579
|
if event['type'] in ['ADDED', 'MODIFIED']:
|
|
580
|
+
# Terminal pods stay listed until garbage collected but no longer hold a node's pod slot
|
|
581
|
+
if node is not None:
|
|
582
|
+
self._node_active_pods[None].discard(uid)
|
|
583
|
+
if event['raw_object']['status'].get('phase') in ('Succeeded', 'Failed'):
|
|
584
|
+
self._node_active_pods[node].discard(uid)
|
|
585
|
+
else:
|
|
586
|
+
self._node_active_pods[node].add(uid)
|
|
546
587
|
for container in event['raw_object']['spec']['containers']:
|
|
547
588
|
key = f"{uid}-{container['name']}"
|
|
548
589
|
|
|
@@ -568,6 +609,8 @@ class KubernetesController(ControllerInterface):
|
|
|
568
609
|
f"Last State: {lastState} "
|
|
569
610
|
f"with reason {detail.get('reason', 'UNKNOWN')}")
|
|
570
611
|
elif event['type'] == 'DELETED':
|
|
612
|
+
self._node_active_pods[node].discard(uid)
|
|
613
|
+
self._node_active_pods[None].discard(uid)
|
|
571
614
|
for container in event['raw_object']['spec']['containers']:
|
|
572
615
|
key = f"{uid}-{container['name']}"
|
|
573
616
|
containers.pop(key, None)
|
|
@@ -756,6 +799,13 @@ class KubernetesController(ControllerInterface):
|
|
|
756
799
|
return self._quota_mem_limit - self._get_pod_used_namespace_ram(), self._quota_mem_limit
|
|
757
800
|
return self._node_pool_max_ram - self._get_pod_used_ram(), self._node_pool_max_ram
|
|
758
801
|
|
|
802
|
+
def pods_info(self) -> tuple[float, float]:
|
|
803
|
+
# Without a cluster wide pod list, pods from other namespaces are invisible and the free count would be wrong
|
|
804
|
+
if not self.cluster_pod_list:
|
|
805
|
+
return math.inf, math.inf
|
|
806
|
+
used = sum(len(self._node_active_pods[name]) for name in self.ready_nodes.keys())
|
|
807
|
+
return self._node_pool_max_pods - used, self._node_pool_max_pods
|
|
808
|
+
|
|
759
809
|
def _create_containers(self, service_name: str, deployment_name: str, container_config, mounts, security_context,
|
|
760
810
|
core_container=False):
|
|
761
811
|
cores = container_config.cpu_cores
|
|
@@ -804,6 +804,7 @@ class ScalerServer(ThreadedCoreBase):
|
|
|
804
804
|
# Get the processed resource numbers
|
|
805
805
|
free_cpu, _ = self.get_cpu_info(overallocation=True)
|
|
806
806
|
free_memory, _ = self.get_memory_info(overallocation=True)
|
|
807
|
+
free_pods = self.get_free_pods()
|
|
807
808
|
|
|
808
809
|
# Make adjustments to the targets until everything is satisified
|
|
809
810
|
# or we don't have the resouces to make more adjustments
|
|
@@ -812,6 +813,10 @@ class ScalerServer(ThreadedCoreBase):
|
|
|
812
813
|
prof = [_p for _p in prof if _p.desired_instances > targets[_p.name]]
|
|
813
814
|
# only consider services where there is room for more pending containers
|
|
814
815
|
prof = [_p for _p in prof if _p.running_instances + self.max_pending > targets[_p.name]]
|
|
816
|
+
if free_pods < 1:
|
|
817
|
+
if prof:
|
|
818
|
+
self.log.debug("Can't make more because no pod slots are free %s", [_p.name for _p in prof])
|
|
819
|
+
return []
|
|
815
820
|
drop = [_p for _p in prof if _p.cpu > free_cpu or _p.ram > free_memory]
|
|
816
821
|
if drop:
|
|
817
822
|
summary = {_p.name: (_p.cpu, _p.ram) for _p in drop}
|
|
@@ -827,6 +832,7 @@ class ScalerServer(ThreadedCoreBase):
|
|
|
827
832
|
# Add one for the profile at the bottom
|
|
828
833
|
free_memory -= remaining_profiles[0].container_config.ram_mb
|
|
829
834
|
free_cpu -= remaining_profiles[0].container_config.cpu_cores
|
|
835
|
+
free_pods -= 1
|
|
830
836
|
targets[remaining_profiles[0].name] += 1
|
|
831
837
|
|
|
832
838
|
# Take out any services that should be happy now
|
|
@@ -866,6 +872,20 @@ class ScalerServer(ThreadedCoreBase):
|
|
|
866
872
|
|
|
867
873
|
return (free_cpu, total_cpu)
|
|
868
874
|
|
|
875
|
+
def get_free_pods(self) -> float:
|
|
876
|
+
# Overallocation relies on pending pods to drive a cluster autoscaler, which a pod slot cap would block
|
|
877
|
+
if self.get_cpu_overallocation() > 1 or self.get_memory_overallocation() > 1:
|
|
878
|
+
return math.inf
|
|
879
|
+
|
|
880
|
+
free_pods, _ = self.controller.pods_info()
|
|
881
|
+
|
|
882
|
+
# Include the service containers not counted in the raw numbers because they are pending
|
|
883
|
+
for name, pending in self.controller.get_unavailable().items():
|
|
884
|
+
if name in self.profiles and pending:
|
|
885
|
+
free_pods -= pending
|
|
886
|
+
|
|
887
|
+
return free_pods
|
|
888
|
+
|
|
869
889
|
def get_memory_info(self, overallocation: bool) -> tuple[float, float]:
|
|
870
890
|
# Get the raw used resource numbers
|
|
871
891
|
free_memory, total_memory = self.controller.memory_info()
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import math
|
|
2
|
+
from unittest.mock import Mock, patch
|
|
3
|
+
|
|
4
|
+
import pytest
|
|
5
|
+
from kubernetes.client import V1Toleration
|
|
6
|
+
|
|
7
|
+
from assemblyline.odm.models.config import Selector
|
|
8
|
+
from assemblyline_core.scaler.controllers.kubernetes_ctl import (
|
|
9
|
+
KubernetesController,
|
|
10
|
+
node_is_schedulable,
|
|
11
|
+
toleration_matches_taint,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def make_node(name='node-a', ready=True, unschedulable=False, taints=None, cpu='4', memory='8Gi', pods='110'):
|
|
16
|
+
spec = {}
|
|
17
|
+
if unschedulable:
|
|
18
|
+
spec['unschedulable'] = True
|
|
19
|
+
if taints is not None:
|
|
20
|
+
spec['taints'] = taints
|
|
21
|
+
return {
|
|
22
|
+
'metadata': {'name': name},
|
|
23
|
+
'spec': spec,
|
|
24
|
+
'status': {
|
|
25
|
+
'conditions': [{'type': 'Ready', 'status': 'True' if ready else 'False'}],
|
|
26
|
+
'allocatable': {'cpu': cpu, 'memory': memory, 'pods': pods},
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
CONTROL_PLANE = {'key': 'node-role.kubernetes.io/control-plane', 'effect': 'NoSchedule'}
|
|
32
|
+
DEDICATED = {'key': 'dedicated', 'value': 'system', 'effect': 'NoSchedule'}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest.mark.parametrize('toleration, taint, expected', [
|
|
36
|
+
(V1Toleration(key='dedicated', operator='Equal', value='system', effect='NoSchedule'), DEDICATED, True),
|
|
37
|
+
(V1Toleration(key='dedicated', value='system'), DEDICATED, True),
|
|
38
|
+
(V1Toleration(key='dedicated', operator='Equal', value='other'), DEDICATED, False),
|
|
39
|
+
(V1Toleration(key='dedicated', operator='Exists'), DEDICATED, True),
|
|
40
|
+
(V1Toleration(key='other', operator='Exists'), DEDICATED, False),
|
|
41
|
+
(V1Toleration(key='dedicated', operator='Exists', effect='NoExecute'), DEDICATED, False),
|
|
42
|
+
(V1Toleration(operator='Exists'), DEDICATED, True),
|
|
43
|
+
(V1Toleration(key='node-role.kubernetes.io/control-plane', operator='Exists'), CONTROL_PLANE, True),
|
|
44
|
+
(V1Toleration(key='node-role.kubernetes.io/control-plane', operator='Equal'), CONTROL_PLANE, True),
|
|
45
|
+
])
|
|
46
|
+
def test_toleration_matches_taint(toleration, taint, expected):
|
|
47
|
+
assert toleration_matches_taint(toleration, taint) is expected
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_node_is_schedulable():
|
|
51
|
+
assert node_is_schedulable(make_node(), [])
|
|
52
|
+
assert node_is_schedulable(make_node(taints=[]), [])
|
|
53
|
+
assert not node_is_schedulable(make_node(unschedulable=True), [])
|
|
54
|
+
assert not node_is_schedulable(make_node(unschedulable=True), [V1Toleration(operator='Exists')])
|
|
55
|
+
|
|
56
|
+
# Only hard taints keep service pods off a node
|
|
57
|
+
assert not node_is_schedulable(make_node(taints=[CONTROL_PLANE]), [])
|
|
58
|
+
assert not node_is_schedulable(make_node(taints=[{**DEDICATED, 'effect': 'NoExecute'}]), [])
|
|
59
|
+
assert node_is_schedulable(make_node(taints=[{**DEDICATED, 'effect': 'PreferNoSchedule'}]), [])
|
|
60
|
+
|
|
61
|
+
# Every hard taint must be tolerated
|
|
62
|
+
tolerate_dedicated = [V1Toleration(key='dedicated', operator='Exists')]
|
|
63
|
+
assert node_is_schedulable(make_node(taints=[DEDICATED]), tolerate_dedicated)
|
|
64
|
+
assert not node_is_schedulable(make_node(taints=[DEDICATED, CONTROL_PLANE]), tolerate_dedicated)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def monitor_node_pool(events, tolerations=()):
|
|
68
|
+
ctl = KubernetesController.__new__(KubernetesController)
|
|
69
|
+
ctl.running = True
|
|
70
|
+
ctl.api = Mock()
|
|
71
|
+
ctl.linux_node_selector = Selector({})
|
|
72
|
+
ctl.default_service_tolerations = list(tolerations)
|
|
73
|
+
|
|
74
|
+
watch = Mock()
|
|
75
|
+
watch.stream.return_value = [{'type': kind, 'raw_object': node} for kind, node in events]
|
|
76
|
+
with patch('assemblyline_core.scaler.controllers.kubernetes_ctl.Watch', return_value=watch):
|
|
77
|
+
ctl._monitor_node_pool()
|
|
78
|
+
return ctl
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_monitor_node_pool_counts_only_schedulable_nodes():
|
|
82
|
+
ctl = monitor_node_pool([
|
|
83
|
+
('ADDED', make_node('worker', cpu='4', memory='8Gi')),
|
|
84
|
+
('ADDED', make_node('control-plane', taints=[CONTROL_PLANE], cpu='2', memory='4Gi')),
|
|
85
|
+
('ADDED', make_node('cordoned', unschedulable=True, cpu='8', memory='16Gi')),
|
|
86
|
+
('ADDED', make_node('not-ready', ready=False, cpu='8', memory='16Gi')),
|
|
87
|
+
])
|
|
88
|
+
|
|
89
|
+
assert set(ctl.ready_nodes) == {'worker'}
|
|
90
|
+
assert ctl.node_count == 1
|
|
91
|
+
assert ctl._node_pool_max_cpu == 4
|
|
92
|
+
assert ctl._node_pool_max_ram == 8 * 1024
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def test_monitor_node_pool_includes_tolerated_nodes():
|
|
96
|
+
ctl = monitor_node_pool([
|
|
97
|
+
('ADDED', make_node('worker', cpu='4', memory='8Gi')),
|
|
98
|
+
('ADDED', make_node('system', taints=[DEDICATED], cpu='2', memory='4Gi')),
|
|
99
|
+
], tolerations=[V1Toleration(key='dedicated', operator='Equal', value='system', effect='NoSchedule')])
|
|
100
|
+
|
|
101
|
+
assert set(ctl.ready_nodes) == {'worker', 'system'}
|
|
102
|
+
assert ctl._node_pool_max_cpu == 6
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def test_monitor_node_pool_drops_node_when_cordoned():
|
|
106
|
+
ctl = monitor_node_pool([
|
|
107
|
+
('ADDED', make_node('worker-a')),
|
|
108
|
+
('ADDED', make_node('worker-b')),
|
|
109
|
+
('MODIFIED', make_node('worker-b', unschedulable=True)),
|
|
110
|
+
])
|
|
111
|
+
|
|
112
|
+
assert set(ctl.ready_nodes) == {'worker-a'}
|
|
113
|
+
assert ctl._node_pool_max_cpu == 4
|
|
114
|
+
|
|
115
|
+
ctl = monitor_node_pool([
|
|
116
|
+
('ADDED', make_node('worker-a', unschedulable=True)),
|
|
117
|
+
('MODIFIED', make_node('worker-a')),
|
|
118
|
+
])
|
|
119
|
+
|
|
120
|
+
assert set(ctl.ready_nodes) == {'worker-a'}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def test_monitor_node_pool_sums_pod_capacity():
|
|
124
|
+
ctl = monitor_node_pool([
|
|
125
|
+
('ADDED', make_node('worker-a', pods='110')),
|
|
126
|
+
('ADDED', make_node('worker-b', pods='30')),
|
|
127
|
+
('ADDED', make_node('control-plane', taints=[CONTROL_PLANE], pods='110')),
|
|
128
|
+
])
|
|
129
|
+
|
|
130
|
+
assert ctl._node_pool_max_pods == 140
|
|
131
|
+
|
|
132
|
+
node = make_node('virtual')
|
|
133
|
+
del node['status']['allocatable']['pods']
|
|
134
|
+
ctl = monitor_node_pool([('ADDED', make_node('worker-a')), ('ADDED', node)])
|
|
135
|
+
assert ctl._node_pool_max_pods == math.inf
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def make_pod(uid, node, phase='Running', namespace='al'):
|
|
139
|
+
return {
|
|
140
|
+
'metadata': {'name': f'pod-{uid}', 'uid': uid, 'namespace': namespace},
|
|
141
|
+
'spec': {
|
|
142
|
+
'nodeName': node,
|
|
143
|
+
'containers': [{'name': 'main', 'resources': {'requests': {'cpu': '100m', 'memory': '64Mi'}}}],
|
|
144
|
+
},
|
|
145
|
+
'status': {'phase': phase},
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def pod_controller(node_pods, cluster_pod_list=True):
|
|
150
|
+
ctl = KubernetesController.__new__(KubernetesController)
|
|
151
|
+
ctl.running = True
|
|
152
|
+
ctl.api = Mock()
|
|
153
|
+
ctl.logger = Mock()
|
|
154
|
+
ctl.namespace = 'al'
|
|
155
|
+
ctl.cluster_pod_list = cluster_pod_list
|
|
156
|
+
ctl.ready_nodes = {name: (4.0, 8192.0, pods) for name, pods in node_pods.items()}
|
|
157
|
+
ctl._node_pool_max_pods = sum(node_pods.values())
|
|
158
|
+
return ctl
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def monitor_pods(ctl, events):
|
|
162
|
+
watch = Mock()
|
|
163
|
+
watch.stream.return_value = [{'type': kind, 'raw_object': pod} for kind, pod in events]
|
|
164
|
+
with patch('assemblyline_core.scaler.controllers.kubernetes_ctl.Watch', return_value=watch):
|
|
165
|
+
ctl._monitor_pods()
|
|
166
|
+
return ctl
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def test_pods_info_counts_active_pods_on_schedulable_nodes():
|
|
170
|
+
ctl = monitor_pods(pod_controller({'worker-a': 10, 'worker-b': 5}), [
|
|
171
|
+
('ADDED', make_pod('1', 'worker-a')),
|
|
172
|
+
('ADDED', make_pod('2', 'worker-a', namespace='kube-system')),
|
|
173
|
+
('ADDED', make_pod('3', 'worker-b', phase='Pending')),
|
|
174
|
+
# Terminal pods don't occupy a slot
|
|
175
|
+
('ADDED', make_pod('4', 'worker-b', phase='Succeeded')),
|
|
176
|
+
('ADDED', make_pod('5', 'worker-b', phase='Failed')),
|
|
177
|
+
# Pods on nodes outside the pool, or not yet bound to a node, aren't counted
|
|
178
|
+
('ADDED', make_pod('6', 'control-plane')),
|
|
179
|
+
('ADDED', make_pod('7', None, phase='Pending')),
|
|
180
|
+
])
|
|
181
|
+
|
|
182
|
+
assert ctl.pods_info() == (12, 15)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def test_pods_info_tracks_pod_lifecycle():
|
|
186
|
+
ctl = monitor_pods(pod_controller({'worker-a': 10}), [
|
|
187
|
+
('ADDED', make_pod('1', None, phase='Pending')),
|
|
188
|
+
('MODIFIED', make_pod('1', 'worker-a', phase='Pending')),
|
|
189
|
+
('MODIFIED', make_pod('1', 'worker-a', phase='Running')),
|
|
190
|
+
('ADDED', make_pod('2', 'worker-a')),
|
|
191
|
+
('MODIFIED', make_pod('2', 'worker-a', phase='Succeeded')),
|
|
192
|
+
('ADDED', make_pod('3', 'worker-a')),
|
|
193
|
+
('DELETED', make_pod('3', 'worker-a')),
|
|
194
|
+
])
|
|
195
|
+
|
|
196
|
+
assert ctl.pods_info() == (9, 10)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def test_pods_info_unbounded_without_cluster_pod_list():
|
|
200
|
+
ctl = monitor_pods(pod_controller({'worker-a': 10}, cluster_pod_list=False), [
|
|
201
|
+
('ADDED', make_pod('1', 'worker-a')),
|
|
202
|
+
])
|
|
203
|
+
|
|
204
|
+
assert ctl.pods_info() == (math.inf, math.inf)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import threading
|
|
3
|
+
|
|
4
|
+
from assemblyline.odm.models.service import DockerConfig
|
|
5
|
+
from pytest import approx
|
|
6
|
+
from unittest.mock import Mock, patch
|
|
7
|
+
from assemblyline_core.scaler.collection import Collection
|
|
8
|
+
from assemblyline_core.scaler.controllers.interface import ControllerInterface
|
|
9
|
+
from assemblyline_core.scaler.scaler_server import ScalerServer, ServiceProfile
|
|
10
|
+
from assemblyline_core.server_base import ServiceStage
|
|
11
|
+
|
|
12
|
+
mock_time = Mock()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@patch('time.time', mock_time)
|
|
16
|
+
def test_collection():
|
|
17
|
+
mock_time.return_value = 0
|
|
18
|
+
collection = Collection(60, ttl=61)
|
|
19
|
+
|
|
20
|
+
# Insert some sample data
|
|
21
|
+
collection.update('service-a', 'host-a', 30, 1)
|
|
22
|
+
collection.update('service-b', 'host-a', 60, 1)
|
|
23
|
+
mock_time.return_value = 30
|
|
24
|
+
collection.update('service-a', 'host-b', 30, 1)
|
|
25
|
+
|
|
26
|
+
assert collection.read('service-c') is None
|
|
27
|
+
assert collection.read('service-a')['instances'] == 2
|
|
28
|
+
assert collection.read('service-a')['duty_cycle'] == approx(0.5)
|
|
29
|
+
|
|
30
|
+
assert collection.read('service-b')['instances'] == 1
|
|
31
|
+
assert collection.read('service-b')['duty_cycle'] == approx(1)
|
|
32
|
+
|
|
33
|
+
# Move forward enough that the first two messages expire, send another message from the second
|
|
34
|
+
# service, now both should have one active message/host
|
|
35
|
+
mock_time.return_value = 62
|
|
36
|
+
collection.update('service-b', 'host-a', 30, 1)
|
|
37
|
+
|
|
38
|
+
assert collection.read('service-a')['instances'] == 1
|
|
39
|
+
assert collection.read('service-a')['duty_cycle'] == approx(0.5)
|
|
40
|
+
|
|
41
|
+
assert collection.read('service-b')['instances'] == 1
|
|
42
|
+
assert collection.read('service-b')['duty_cycle'] == approx(0.5)
|
|
43
|
+
|
|
44
|
+
# Move forward that the last of the original group of messages expire, but the update for the second
|
|
45
|
+
# service is still in effect
|
|
46
|
+
mock_time.return_value = 100
|
|
47
|
+
|
|
48
|
+
assert collection.read('service-a') is None
|
|
49
|
+
assert collection.read('service-b')['instances'] == 1
|
|
50
|
+
assert collection.read('service-b')['duty_cycle'] == approx(0.5)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_default_bucket_rates():
|
|
54
|
+
service = ServiceProfile('service', DockerConfig(dict(image='redis')))
|
|
55
|
+
before = service.pressure
|
|
56
|
+
service.update(5, 1, 1, 1)
|
|
57
|
+
print(service.pressure, before)
|
|
58
|
+
assert service.pressure > before
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def make_profile(name, desired):
|
|
62
|
+
profile = ServiceProfile(name, DockerConfig(dict(image='redis', cpu_cores=1, ram_mb=1024)))
|
|
63
|
+
profile.desired_instances = desired
|
|
64
|
+
return profile
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def run_scaling_pass(profiles, pods, targets=None, unavailable=None, cpu_overallocation=1.0,
|
|
68
|
+
memory_overallocation=1.0, overallocation_node_limit=None, node_count=3):
|
|
69
|
+
"""Run one iteration of ScalerServer.update_scaling against a mocked controller with ample CPU/RAM."""
|
|
70
|
+
server = ScalerServer.__new__(ScalerServer)
|
|
71
|
+
server.log = Mock()
|
|
72
|
+
server.apm_client = None
|
|
73
|
+
server.max_pending = 50
|
|
74
|
+
server.profiles = {profile.name: profile for profile in profiles}
|
|
75
|
+
server.profiles_lock = threading.RLock()
|
|
76
|
+
server.get_service_stage = Mock(return_value=ServiceStage.Running)
|
|
77
|
+
server.sleep = Mock(side_effect=[True, False])
|
|
78
|
+
|
|
79
|
+
server.config = Mock()
|
|
80
|
+
server.config.core.scaler.cpu_overallocation = cpu_overallocation
|
|
81
|
+
server.config.core.scaler.memory_overallocation = memory_overallocation
|
|
82
|
+
server.config.core.scaler.overallocation_node_limit = overallocation_node_limit
|
|
83
|
+
|
|
84
|
+
server.controller = Mock()
|
|
85
|
+
server.controller.node_count = node_count
|
|
86
|
+
server.controller.get_targets.return_value = dict(targets or {})
|
|
87
|
+
server.controller.get_unavailable.return_value = dict(unavailable or {})
|
|
88
|
+
server.controller.cpu_info.return_value = (1000.0, 1000.0)
|
|
89
|
+
server.controller.memory_info.return_value = (1024.0 * 1000, 1024.0 * 1000)
|
|
90
|
+
server.controller.pods_info.return_value = pods
|
|
91
|
+
|
|
92
|
+
server.update_scaling()
|
|
93
|
+
return {profile.name: profile.target_instances for profile in profiles}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def test_controller_pods_info_defaults_to_unbounded():
|
|
97
|
+
assert ControllerInterface().pods_info() == (math.inf, math.inf)
|
|
98
|
+
assert ControllerInterface().free_pods() == math.inf
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def test_scaling_unbounded_by_default_pod_info():
|
|
102
|
+
targets = run_scaling_pass([make_profile('a', 10), make_profile('b', 10)], pods=(math.inf, math.inf))
|
|
103
|
+
assert targets == {'a': 10, 'b': 10}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def test_scaling_stops_when_pod_slots_run_out():
|
|
107
|
+
targets = run_scaling_pass([make_profile('a', 10), make_profile('b', 10)], pods=(5, 100))
|
|
108
|
+
assert sum(targets.values()) == 5
|
|
109
|
+
assert abs(targets['a'] - targets['b']) <= 1
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def test_scaling_reserves_pod_slots_for_pending_containers():
|
|
113
|
+
targets = run_scaling_pass([make_profile('a', 10)], pods=(5, 100), targets={'a': 2}, unavailable={'a': 2})
|
|
114
|
+
assert targets == {'a': 5}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def test_scaling_ignores_pod_slots_while_overallocating():
|
|
118
|
+
# Overallocation relies on pending pods to drive a cluster autoscaler, so pod slots can't cap it
|
|
119
|
+
targets = run_scaling_pass([make_profile('a', 10)], pods=(5, 100), cpu_overallocation=2.0)
|
|
120
|
+
assert targets == {'a': 10}
|
|
121
|
+
|
|
122
|
+
targets = run_scaling_pass([make_profile('a', 10)], pods=(5, 100), memory_overallocation=1.5)
|
|
123
|
+
assert targets == {'a': 10}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def test_scaling_respects_pod_slots_past_overallocation_node_limit():
|
|
127
|
+
targets = run_scaling_pass([make_profile('a', 10)], pods=(5, 100), cpu_overallocation=2.0,
|
|
128
|
+
overallocation_node_limit=3, node_count=3)
|
|
129
|
+
assert targets == {'a': 5}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4.7.5.dev159
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
from assemblyline.odm.models.service import DockerConfig
|
|
2
|
-
from pytest import approx
|
|
3
|
-
from unittest.mock import Mock, patch
|
|
4
|
-
from assemblyline_core.scaler.collection import Collection
|
|
5
|
-
from assemblyline_core.scaler.scaler_server import ServiceProfile
|
|
6
|
-
|
|
7
|
-
mock_time = Mock()
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@patch('time.time', mock_time)
|
|
11
|
-
def test_collection():
|
|
12
|
-
mock_time.return_value = 0
|
|
13
|
-
collection = Collection(60, ttl=61)
|
|
14
|
-
|
|
15
|
-
# Insert some sample data
|
|
16
|
-
collection.update('service-a', 'host-a', 30, 1)
|
|
17
|
-
collection.update('service-b', 'host-a', 60, 1)
|
|
18
|
-
mock_time.return_value = 30
|
|
19
|
-
collection.update('service-a', 'host-b', 30, 1)
|
|
20
|
-
|
|
21
|
-
assert collection.read('service-c') is None
|
|
22
|
-
assert collection.read('service-a')['instances'] == 2
|
|
23
|
-
assert collection.read('service-a')['duty_cycle'] == approx(0.5)
|
|
24
|
-
|
|
25
|
-
assert collection.read('service-b')['instances'] == 1
|
|
26
|
-
assert collection.read('service-b')['duty_cycle'] == approx(1)
|
|
27
|
-
|
|
28
|
-
# Move forward enough that the first two messages expire, send another message from the second
|
|
29
|
-
# service, now both should have one active message/host
|
|
30
|
-
mock_time.return_value = 62
|
|
31
|
-
collection.update('service-b', 'host-a', 30, 1)
|
|
32
|
-
|
|
33
|
-
assert collection.read('service-a')['instances'] == 1
|
|
34
|
-
assert collection.read('service-a')['duty_cycle'] == approx(0.5)
|
|
35
|
-
|
|
36
|
-
assert collection.read('service-b')['instances'] == 1
|
|
37
|
-
assert collection.read('service-b')['duty_cycle'] == approx(0.5)
|
|
38
|
-
|
|
39
|
-
# Move forward that the last of the original group of messages expire, but the update for the second
|
|
40
|
-
# service is still in effect
|
|
41
|
-
mock_time.return_value = 100
|
|
42
|
-
|
|
43
|
-
assert collection.read('service-a') is None
|
|
44
|
-
assert collection.read('service-b')['instances'] == 1
|
|
45
|
-
assert collection.read('service-b')['duty_cycle'] == approx(0.5)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def test_default_bucket_rates():
|
|
49
|
-
service = ServiceProfile('service', DockerConfig(dict(image='redis')))
|
|
50
|
-
before = service.pressure
|
|
51
|
-
service.update(5, 1, 1, 1)
|
|
52
|
-
print(service.pressure, before)
|
|
53
|
-
assert service.pressure > before
|
|
File without changes
|
|
File without changes
|
{assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/replay/client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/replay/replay.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/server_base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/assemblyline_core/vacuum/worker.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_badlist_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_safelist_client.py
RENAMED
|
File without changes
|
|
File without changes
|
{assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_signature_client.py
RENAMED
|
File without changes
|
{assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_tasking_client.py
RENAMED
|
File without changes
|
{assemblyline_core-4.7.5.dev159 → assemblyline_core-4.7.5.dev163}/test/test_updater_helper.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|