|
12 | 12 | from functools import partial
|
13 | 13 | from queue import Queue
|
14 | 14 | from typing import Any, Dict, List, Optional
|
15 |
| -from krkn_lib.version import __version__ |
16 | 15 |
|
17 | 16 | import arcaflow_lib_kubernetes
|
18 |
| -import deprecation |
19 | 17 | import kubernetes
|
20 | 18 | import urllib3
|
21 | 19 | import yaml
|
|
31 | 29 | PVC,
|
32 | 30 | AffectedPod,
|
33 | 31 | ApiRequestException,
|
34 |
| - ChaosEngine, |
35 |
| - ChaosResult, |
36 | 32 | Container,
|
37 |
| - LitmusChaosObject, |
38 | 33 | Pod,
|
39 | 34 | PodsMonitorThread,
|
40 | 35 | PodsStatus,
|
@@ -1575,82 +1570,6 @@ def get_pod_info(self, name: str, namespace: str = "default") -> Pod:
|
1575 | 1570 | )
|
1576 | 1571 | return None
|
1577 | 1572 |
|
1578 |
| - @deprecation.deprecated( |
1579 |
| - deprecated_in="3.1.0", |
1580 |
| - removed_in="3.2.0", |
1581 |
| - current_version=__version__, |
1582 |
| - details="litmus support dropped from krkn", |
1583 |
| - ) |
1584 |
| - def get_litmus_chaos_object( |
1585 |
| - self, kind: str, name: str, namespace: str = "default" |
1586 |
| - ) -> LitmusChaosObject: |
1587 |
| - """ |
1588 |
| - Retrieves Litmus Chaos CRDs |
1589 |
| -
|
1590 |
| - :param kind: the custom resource type |
1591 |
| - :param name: the object name |
1592 |
| - :param namespace: the namespace (optional default `default`) |
1593 |
| - :return: data class object of a subclass of LitmusChaosObject |
1594 |
| - """ |
1595 |
| - |
1596 |
| - group = "litmuschaos.io" |
1597 |
| - version = "v1alpha1" |
1598 |
| - |
1599 |
| - if kind.lower() == "chaosengine": |
1600 |
| - plural = "chaosengines" |
1601 |
| - response = self.custom_object_client.get_namespaced_custom_object( |
1602 |
| - group=group, |
1603 |
| - plural=plural, |
1604 |
| - version=version, |
1605 |
| - namespace=namespace, |
1606 |
| - name=name, |
1607 |
| - ) |
1608 |
| - try: |
1609 |
| - engine_status = response["status"]["engineStatus"] |
1610 |
| - exp_status = response["status"]["experiments"][0]["status"] |
1611 |
| - except Exception: |
1612 |
| - engine_status = "Not Initialized" |
1613 |
| - exp_status = "Not Initialized" |
1614 |
| - custom_object = ChaosEngine( |
1615 |
| - kind="ChaosEngine", |
1616 |
| - group=group, |
1617 |
| - namespace=namespace, |
1618 |
| - name=name, |
1619 |
| - plural=plural, |
1620 |
| - version=version, |
1621 |
| - engineStatus=engine_status, |
1622 |
| - expStatus=exp_status, |
1623 |
| - ) |
1624 |
| - elif kind.lower() == "chaosresult": |
1625 |
| - plural = "chaosresults" |
1626 |
| - response = self.custom_object_client.get_namespaced_custom_object( |
1627 |
| - group=group, |
1628 |
| - plural=plural, |
1629 |
| - version=version, |
1630 |
| - namespace=namespace, |
1631 |
| - name=name, |
1632 |
| - ) |
1633 |
| - try: |
1634 |
| - verdict = response["status"]["experimentStatus"]["verdict"] |
1635 |
| - fail_step = response["status"]["experimentStatus"]["failStep"] |
1636 |
| - except Exception: |
1637 |
| - verdict = "N/A" |
1638 |
| - fail_step = "N/A" |
1639 |
| - custom_object = ChaosResult( |
1640 |
| - kind="ChaosResult", |
1641 |
| - group=group, |
1642 |
| - namespace=namespace, |
1643 |
| - name=name, |
1644 |
| - plural=plural, |
1645 |
| - version=version, |
1646 |
| - verdict=verdict, |
1647 |
| - failStep=fail_step, |
1648 |
| - ) |
1649 |
| - else: |
1650 |
| - logging.error("Invalid litmus chaos custom resource name") |
1651 |
| - custom_object = None |
1652 |
| - return custom_object |
1653 |
| - |
1654 | 1573 | def check_if_namespace_exists(self, name: str) -> bool:
|
1655 | 1574 | """
|
1656 | 1575 | Check if a namespace exists by parsing through
|
@@ -2596,89 +2515,6 @@ def collect_and_parse_cluster_events(
|
2596 | 2515 |
|
2597 | 2516 | return events
|
2598 | 2517 |
|
2599 |
| - @deprecation.deprecated( |
2600 |
| - deprecated_in="3.1.0", |
2601 |
| - removed_in="3.2.0", |
2602 |
| - current_version=__version__, |
2603 |
| - details="replaced by `collect_and_parse_cluster_events`", |
2604 |
| - ) |
2605 |
| - def collect_cluster_events( |
2606 |
| - self, |
2607 |
| - start_timestamp: int, |
2608 |
| - end_timestamp: int, |
2609 |
| - local_timezone: str, |
2610 |
| - cluster_timezone: str = "UTC", |
2611 |
| - limit: int = 500, |
2612 |
| - namespace: str = None, |
2613 |
| - ) -> Optional[str]: |
2614 |
| - """ |
2615 |
| - Collects cluster events querying `/api/v1/events` |
2616 |
| - filtered in a given time interval and writes them in |
2617 |
| - a temporary file in json format. |
2618 |
| -
|
2619 |
| - :param start_timestamp: timestamp of the minimum date |
2620 |
| - after that the event is relevant |
2621 |
| - :param end_timestamp: timestamp of the maximum date |
2622 |
| - before that the event is relevant |
2623 |
| - :param local_timezone: timezone of the local system |
2624 |
| - :param cluster_timezone: timezone of the remote cluster |
2625 |
| - :param limit: limit of the number of events to be fetched |
2626 |
| - from the cluster |
2627 |
| - :param namespace: Namespace from which the events must be |
2628 |
| - collected, if None all-namespaces will be selected |
2629 |
| -
|
2630 |
| - """ |
2631 |
| - |
2632 |
| - try: |
2633 |
| - path_params: Dict[str, str] = {} |
2634 |
| - query_params = {"limit": limit} |
2635 |
| - header_params: Dict[str, str] = {} |
2636 |
| - auth_settings = ["BearerToken"] |
2637 |
| - header_params["Accept"] = self.api_client.select_header_accept( |
2638 |
| - ["application/json"] |
2639 |
| - ) |
2640 |
| - |
2641 |
| - path = "/api/v1/events" |
2642 |
| - if namespace: |
2643 |
| - path = f"/api/v1/namespaces/{namespace}/events" |
2644 |
| - |
2645 |
| - (data) = self.api_client.call_api( |
2646 |
| - path, |
2647 |
| - "GET", |
2648 |
| - path_params, |
2649 |
| - query_params, |
2650 |
| - header_params, |
2651 |
| - response_type="str", |
2652 |
| - auth_settings=auth_settings, |
2653 |
| - ) |
2654 |
| - events = [] |
2655 |
| - json_obj = ast.literal_eval(data[0]) |
2656 |
| - events_list = reversed(json_obj["items"]) |
2657 |
| - for obj in events_list: |
2658 |
| - filtered_obj = filter_dictionary( |
2659 |
| - obj, |
2660 |
| - "firstTimestamp", |
2661 |
| - start_timestamp, |
2662 |
| - end_timestamp, |
2663 |
| - cluster_timezone, |
2664 |
| - local_timezone, |
2665 |
| - ) |
2666 |
| - if filtered_obj: |
2667 |
| - events.append(filtered_obj) |
2668 |
| - |
2669 |
| - if len(events) > 0: |
2670 |
| - file_content = json.dumps(events, indent=2) |
2671 |
| - with tempfile.NamedTemporaryFile( |
2672 |
| - delete=False, mode="w" |
2673 |
| - ) as file: |
2674 |
| - file.write(file_content) |
2675 |
| - file.flush() |
2676 |
| - return file.name |
2677 |
| - return None |
2678 |
| - except Exception as e: |
2679 |
| - logging.error(str(e)) |
2680 |
| - return None |
2681 |
| - |
2682 | 2518 | def parse_events_from_file(
|
2683 | 2519 | self, events_filename: str
|
2684 | 2520 | ) -> Optional[list[ClusterEvent]]:
|
|
0 commit comments