diff --git a/azext_edge/edge/providers/support/orc.py b/azext_edge/edge/providers/support/orc.py index 1d6777a19..26c6c8e3a 100644 --- a/azext_edge/edge/providers/support/orc.py +++ b/azext_edge/edge/providers/support/orc.py @@ -22,7 +22,7 @@ logger = get_logger(__name__) -ORC_APP_LABEL = "app in (aio-orc-api, cert-manager, cainjector, webhook)" +ORC_APP_LABEL = "app in (aio-orc-api)" ORC_CONTROLLER_LABEL = "control-plane in (aio-plat-controller-manager)" ORC_DIRECTORY_PATH = ORC_API_V1.moniker diff --git a/azext_edge/edge/providers/support/otel.py b/azext_edge/edge/providers/support/otel.py deleted file mode 100644 index c9087f98c..000000000 --- a/azext_edge/edge/providers/support/otel.py +++ /dev/null @@ -1,56 +0,0 @@ -# coding=utf-8 -# ---------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License file in the project root for license information. -# ---------------------------------------------------------------------------------------------- - -from functools import partial - -from knack.log import get_logger - -from .base import DAY_IN_SECONDS, process_v1_pods, process_deployments, process_services, process_replicasets -from .common import NAME_LABEL_FORMAT -from ..edge_api import EdgeResourceApi - -logger = get_logger(__name__) - -OTEL_EXTENSION_LABEL = "aio-opentelemetry-collector" -OTEL_NAME_LABEL = NAME_LABEL_FORMAT.format(label=OTEL_EXTENSION_LABEL) - -# Defined here as this is not an IoT Operations API -OTEL_API = EdgeResourceApi(group="otel", version="v1", moniker="otel") -OTEL_DIRECTORY_PATH = OTEL_API.moniker - - -def fetch_otel_pods(since_seconds: int = DAY_IN_SECONDS): - return process_v1_pods( - directory_path=OTEL_DIRECTORY_PATH, label_selector=OTEL_NAME_LABEL, since_seconds=since_seconds - ) - - -def fetch_otel_deployments(): - return process_deployments(directory_path=OTEL_DIRECTORY_PATH, label_selector=OTEL_NAME_LABEL) - - -def fetch_otel_replicasets(): - return process_replicasets(directory_path=OTEL_DIRECTORY_PATH, label_selector=OTEL_NAME_LABEL) - - -def fetch_otel_services(): - return process_services(directory_path=OTEL_DIRECTORY_PATH, label_selector=OTEL_NAME_LABEL) - - -support_runtime_elements = { - "deployments": fetch_otel_deployments, - "replicasets": fetch_otel_replicasets, - "services": fetch_otel_services, -} - - -def prepare_bundle(log_age_seconds: int = DAY_IN_SECONDS) -> dict: - shared_to_run = {} - - shared_to_run["pods"] = partial(fetch_otel_pods, since_seconds=log_age_seconds) - shared_to_run.update(support_runtime_elements) - - return shared_to_run diff --git a/azext_edge/edge/providers/support_bundle.py b/azext_edge/edge/providers/support_bundle.py index 8fdc48c8e..617768426 100644 --- a/azext_edge/edge/providers/support_bundle.py +++ b/azext_edge/edge/providers/support_bundle.py @@ -56,7 +56,6 @@ def build_bundle( from .support.deviceregistry import prepare_bundle as prepare_deviceregistry_bundle from .support.shared import prepare_bundle as prepare_shared_bundle from .support.akri import prepare_bundle as prepare_akri_bundle - from .support.otel import prepare_bundle as prepare_otel_bundle from .support.arcagents import prepare_bundle as prepare_arcagents_bundle from .support.meta import prepare_bundle as prepare_meta_bundle @@ -107,10 +106,6 @@ def build_bundle( pending_work[service_moniker].update(bundle) - if ops_service == OpsServiceType.auto.value: - # Only attempt to collect otel resources if any AIO service is deployed AND auto is used. - pending_work["otel"] = prepare_otel_bundle() - # arc agent resources pending_work["arcagents"] = prepare_arcagents_bundle(log_age_seconds) diff --git a/azext_edge/tests/edge/support/create_bundle_int/test_auto_int.py b/azext_edge/tests/edge/support/create_bundle_int/test_auto_int.py index 0af5a9623..b6a285b6d 100644 --- a/azext_edge/tests/edge/support/create_bundle_int/test_auto_int.py +++ b/azext_edge/tests/edge/support/create_bundle_int/test_auto_int.py @@ -12,11 +12,9 @@ from azext_edge.edge.providers.support.arcagents import ARC_AGENTS from .helpers import ( assert_file_names, - check_workload_resource_files, - get_file_map, process_top_levels, run_bundle_command, - BASE_ZIP_PATH + BASE_ZIP_PATH, ) from ....helpers import find_extra_or_missing_names @@ -46,8 +44,7 @@ def test_create_bundle(init_setup, bundle_dir, mq_traces, ops_service, tracked_f # generate second bundle as close as possible if ops_service != OpsServiceType.auto.value: auto_walk_result, _ = run_bundle_command( - command=command.format(OpsServiceType.auto.value), - tracked_files=tracked_files + command=command.format(OpsServiceType.auto.value), tracked_files=tracked_files ) # Level 0 - top @@ -82,7 +79,7 @@ def test_create_bundle(init_setup, bundle_dir, mq_traces, ops_service, tracked_f if ops_service != OpsServiceType.auto.value: expected_folders = [[]] if mq_traces and ops_service == OpsServiceType.mq.value: - expected_folders.append(['traces']) + expected_folders.append(["traces"]) for directory in walk_result: assert auto_walk_result[directory]["folders"] in expected_folders # make things easier if there is a different file @@ -93,42 +90,25 @@ def test_create_bundle(init_setup, bundle_dir, mq_traces, ops_service, tracked_f result_names=auto_files, expected_names=ser_files, ignore_extras=True, - ignore_missing=True + ignore_missing=True, ) -def test_create_bundle_otel(init_setup, tracked_files): - """Test for ensuring file names and content. ONLY CHECKS otel.""" - # dir for unpacked files - ops_service = OpsServiceType.auto.value - command = f"az iot ops support create-bundle --ops-service {ops_service}" - walk_result, bundle_path = run_bundle_command(command=command, tracked_files=tracked_files) - file_map = get_file_map(walk_result, "otel")["aio"] - - expected_workload_types = ["deployment", "pod", "replicaset", "service"] - assert set(file_map.keys()).issubset(set(expected_workload_types)) - check_workload_resource_files( - file_objs=file_map, - expected_workload_types=expected_workload_types, - prefixes="aio-otel", - bundle_path=bundle_path - ) - - def _get_expected_services( - walk_result: Dict[str, Dict[str, List[str]]], ops_service: str , namespace: str + walk_result: Dict[str, Dict[str, List[str]]], ops_service: str, namespace: str ) -> List[str]: expected_services = [ops_service] if ops_service == OpsServiceType.auto.value: # these should always be generated expected_services = OpsServiceType.list() expected_services.remove(OpsServiceType.auto.value) - expected_services.append("otel") expected_services.sort() # device registry folder will not be created if there are no device registry resources - if not walk_result.get(path.join(BASE_ZIP_PATH, namespace, OpsServiceType.deviceregistry.value))\ - and OpsServiceType.deviceregistry.value in expected_services: + if ( + not walk_result.get(path.join(BASE_ZIP_PATH, namespace, OpsServiceType.deviceregistry.value)) + and OpsServiceType.deviceregistry.value in expected_services + ): expected_services.remove(OpsServiceType.deviceregistry.value) expected_services.append("meta") return expected_services diff --git a/azext_edge/tests/edge/support/create_bundle_int/test_orc_int.py b/azext_edge/tests/edge/support/create_bundle_int/test_orc_int.py index 33c6acc54..8b6e39526 100644 --- a/azext_edge/tests/edge/support/create_bundle_int/test_orc_int.py +++ b/azext_edge/tests/edge/support/create_bundle_int/test_orc_int.py @@ -36,6 +36,6 @@ def test_create_bundle_orc(init_setup, tracked_files): check_workload_resource_files( file_objs=file_map, expected_workload_types=expected_workload_types, - prefixes=["aio-cert", "aio-orc"], + prefixes=["aio-orc"], bundle_path=bundle_path ) diff --git a/azext_edge/tests/edge/support/test_support_unit.py b/azext_edge/tests/edge/support/test_support_unit.py index a2c04373d..3ead3dd98 100644 --- a/azext_edge/tests/edge/support/test_support_unit.py +++ b/azext_edge/tests/edge/support/test_support_unit.py @@ -58,7 +58,6 @@ ORC_APP_LABEL, ORC_CONTROLLER_LABEL, ) -from azext_edge.edge.providers.support.otel import OTEL_API, OTEL_NAME_LABEL from azext_edge.edge.providers.support.common import ( COMPONENT_LABEL_FORMAT, NAME_LABEL_FORMAT, @@ -489,9 +488,6 @@ def test_create_bundle( since_seconds=since_seconds, ) - if expected_resources: - assert_otel_kpis(mocked_client, mocked_zipfile, mocked_list_pods) - # assert shared KPIs regardless of service assert_shared_kpis(mocked_client, mocked_zipfile) # assert meta KPIs @@ -830,24 +826,6 @@ def assert_meta_kpis(mocked_client, mocked_zipfile, mocked_list_pods): assert_func(**kwargs) -def assert_otel_kpis( - mocked_client, - mocked_zipfile, - mocked_list_pods, -): - for assert_func in [assert_list_pods, assert_list_deployments, assert_list_services, assert_list_replica_sets]: - kwargs = { - "mocked_client": mocked_client, - "mocked_zipfile": mocked_zipfile, - "label_selector": OTEL_NAME_LABEL, - "directory_path": OTEL_API.moniker, - } - if assert_func == assert_list_pods: - kwargs["mocked_list_pods"] = mocked_list_pods - - assert_func(**kwargs) - - def assert_shared_kpis(mocked_client, mocked_zipfile): mocked_client.CoreV1Api().list_node.assert_called_once() assert_zipfile_write(mocked_zipfile, zinfo="nodes.yaml", data="items:\n- metadata:\n name: mock_node\n")