k8s.pods_monitor_pool module

class k8s.pods_monitor_pool.PodsMonitorPool(krkn_lib: KrknKubernetes)

Bases: object

This class has the purpose to manage pools of pod status monitoring threads for the Krkn Scenarios having multiple killing sessions at the same time (eg. Plugin scenarios) the methods reflects the behaviour of the underlying KrknKubernetes Primitives but each call to select_and_monitor_* method pushes a new thread that is managed by the pool. The join method joins all the threads in the pool simultaneously and merges the results on a single PodsStatus structure.

__init__(krkn_lib: KrknKubernetes)
cancel()

cancels all the threads in the pool and makes return the join() call immediately

events: list[Event]
join() PodsStatus

waits all the threads pushed into the pool to finish

Returns:

a PodsStatus structure that is the merge between all the PodsStatus structures returned by every thread pushed into the pool.

select_and_monitor_by_label(label_selector: str, max_timeout: int)

Pushes into the pool a monitoring thread for all the pods identified by a label selector and collects infos about the pods recovery after a kill scenario while the scenario is running.

Parameters:
  • label_selector – the label selector used to filter the pods to monitor (must be the same used in select_pods_by_label)

  • max_timeout – the expected time the pods should take to recover. If the killed pods are replaced in this time frame, but they didn’t reach the Ready State, they will be marked as unrecovered. If during the time frame the pods are not replaced at all the error field of the PodsStatus structure will be valorized with an exception.

select_and_monitor_by_name_pattern_and_namespace_pattern(pod_name_pattern: str, namespace_pattern: str, max_timeout: int)

Pushes into the pool a monitoring thread for all the pods identified by a pod name regex pattern and a namespace regex pattern, that collects infos about the pods recovery after a kill scenario while the scenario is running.

Parameters:
  • pod_name_pattern – a regex representing the pod name pattern used to filter the pods to be monitored (must be the same used in select_pods_by_name_pattern_and_namespace_pattern)

  • namespace_pattern – a regex representing the namespace pattern used to filter the pods to be monitored (must be the same used in select_pods_by_name_pattern_and_namespace_pattern)

  • max_timeout – the expected time the pods should take to recover. If the killed pods are replaced in this time frame, but they didn’t reach the Ready State, they will be marked as unrecovered. If during the time frame the pods are not replaced at all the error field of the PodsStatus structure will be valorized with an exception.

select_and_monitor_by_namespace_pattern_and_label(namespace_pattern: str, label_selector: str, max_timeout=30)

Pushes into the pool a monitoring thread for all the pods identified by a namespace regex pattern and a pod label selector, that collects infos about the pods recovery after a kill scenario while the scenario is running.

Parameters:
  • label_selector – the label selector used to filter the pods to monitor (must be the same used in select_pods_by_label)

  • namespace_pattern – a regex representing the namespace pattern used to filter the pods to be monitored (must be the same used in select_pods_by_name_pattern_and_namespace_pattern)

  • max_timeout – the expected time the pods should take to recover. If the killed pods are replaced in this time frame, but they didn’t reach the Ready State, they will be marked as unrecovered. If during the time frame the pods are not replaced at all the error field of the PodsStatus structure will be valorized with an exception.