-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add openservice mesh resources in support bundle (#471)
- Loading branch information
1 parent
cc68a59
commit 81ae30f
Showing
10 changed files
with
293 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# 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 .base import EdgeResourceApi | ||
|
||
|
||
OPENSERVICEMESH_CONFIG_API_V1 = EdgeResourceApi( | ||
group="config.openservicemesh.io", | ||
version="v1alpha2", | ||
moniker="openservicemesh", | ||
) | ||
|
||
OPENSERVICEMESH_POLICY_API_V1 = EdgeResourceApi( | ||
group="policy.openservicemesh.io", | ||
version="v1alpha1", | ||
moniker="openservicemesh", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# 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 typing import Iterable, Optional | ||
|
||
from knack.log import get_logger | ||
|
||
from ..edge_api import OPENSERVICEMESH_CONFIG_API_V1, EdgeResourceApi | ||
from .base import ( | ||
DAY_IN_SECONDS, | ||
assemble_crd_work, | ||
process_config_maps, | ||
process_deployments, | ||
process_replicasets, | ||
process_services, | ||
process_v1_pods, | ||
) | ||
|
||
logger = get_logger(__name__) | ||
|
||
OSM_DIRECTORY_PATH = OPENSERVICEMESH_CONFIG_API_V1.moniker | ||
OSM_NAMESPACE = "arc-osm-system" | ||
|
||
|
||
def fetch_deployments(): | ||
return process_deployments( | ||
directory_path=OSM_DIRECTORY_PATH, | ||
namespace=OSM_NAMESPACE, | ||
) | ||
|
||
|
||
def fetch_replicasets(): | ||
return process_replicasets( | ||
directory_path=OSM_DIRECTORY_PATH, | ||
namespace=OSM_NAMESPACE, | ||
) | ||
|
||
|
||
def fetch_pods(since_seconds: int = DAY_IN_SECONDS): | ||
return process_v1_pods( | ||
directory_path=OSM_DIRECTORY_PATH, | ||
namespace=OSM_NAMESPACE, | ||
since_seconds=since_seconds, | ||
) | ||
|
||
|
||
def fetch_services(): | ||
return process_services( | ||
directory_path=OSM_DIRECTORY_PATH, | ||
namespace=OSM_NAMESPACE, | ||
) | ||
|
||
|
||
def fetch_configmaps(): | ||
return process_config_maps( | ||
directory_path=OSM_DIRECTORY_PATH, | ||
namespace=OSM_NAMESPACE, | ||
) | ||
|
||
|
||
support_runtime_elements = { | ||
"configmaps": fetch_configmaps, | ||
"deployments": fetch_deployments, | ||
"replicasets": fetch_replicasets, | ||
"services": fetch_services, | ||
} | ||
|
||
|
||
def prepare_bundle( | ||
log_age_seconds: int = DAY_IN_SECONDS, | ||
apis: Optional[Iterable[EdgeResourceApi]] = None, | ||
) -> dict: | ||
osm_to_run = {} | ||
|
||
if apis: | ||
osm_to_run.update(assemble_crd_work(apis=apis)) | ||
|
||
support_runtime_elements["pods"] = partial(fetch_pods, since_seconds=log_age_seconds) | ||
osm_to_run.update(support_runtime_elements) | ||
|
||
return osm_to_run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
azext_edge/tests/edge/support/create_bundle_int/test_openservicemesh_int.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# 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 knack.log import get_logger | ||
from azext_edge.edge.common import OpsServiceType | ||
from azext_edge.edge.providers.edge_api import OPENSERVICEMESH_CONFIG_API_V1, OPENSERVICEMESH_POLICY_API_V1 | ||
from .helpers import ( | ||
check_custom_resource_files, | ||
check_workload_resource_files, | ||
get_file_map, | ||
run_bundle_command, | ||
) | ||
|
||
logger = get_logger(__name__) | ||
|
||
|
||
def test_create_bundle_osm(init_setup, tracked_files): | ||
"""Test for ensuring file names and content. ONLY CHECKS openservicemesh.""" | ||
# dir for unpacked files | ||
ops_service = OpsServiceType.openservicemesh.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, ops_service) | ||
|
||
# arc-osm-system | ||
osm_file_map = file_map["osm"] | ||
|
||
check_custom_resource_files(file_objs=osm_file_map, resource_api=OPENSERVICEMESH_CONFIG_API_V1) | ||
check_custom_resource_files(file_objs=osm_file_map, resource_api=OPENSERVICEMESH_POLICY_API_V1) | ||
|
||
expected_workload_types = ["configmap", "deployment", "pod", "replicaset", "service"] | ||
expected_types = set(expected_workload_types).union(OPENSERVICEMESH_CONFIG_API_V1.kinds) | ||
expected_types = expected_types.union(OPENSERVICEMESH_POLICY_API_V1.kinds) | ||
|
||
assert set(osm_file_map.keys()).issubset(set(expected_types)) | ||
|
||
workload_resource_prefixes = [ | ||
"osm", | ||
"kube-root-ca", | ||
"preset-mesh-config", | ||
] | ||
check_workload_resource_files( | ||
file_objs=osm_file_map, | ||
expected_workload_types=expected_workload_types, | ||
prefixes=workload_resource_prefixes, | ||
bundle_path=bundle_path, | ||
) |
Oops, something went wrong.