Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: skip crd capture when related api not deployed for support bundle #316

Merged
merged 11 commits into from
Aug 23, 2024
2 changes: 1 addition & 1 deletion azext_edge/edge/providers/edge_api/mq.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MqResourceKinds(ListableEnum):


MQTT_BROKER_API_V1B1 = EdgeResourceApi(
group="mqttbroker.iotoperations.azure.com",
group="mqtt.iotoperations.azure.com",
version="v1beta1",
moniker="broker",
label="microsoft-iotoperations-mqttbroker",
Expand Down
2 changes: 1 addition & 1 deletion azext_edge/edge/providers/edge_api/opcua.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class OpcuaResourceKinds(ListableEnum):


OPCUA_API_V1 = EdgeResourceApi(
group="opcuabroker.iotoperations.azure.com",
group="opcuabroker2.iotoperations.azure.com",
version="v1beta1",
moniker="opcua",
label="microsoft-iotoperations-opcuabroker",
Expand Down
7 changes: 7 additions & 0 deletions azext_edge/edge/providers/support_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ def build_bundle(
if ops_service in [OpsServiceType.auto.value, service_moniker]:
deployed_apis = api_info["apis"].get_deployed()

if not deployed_apis:
expected_api_version = api_info["apis"].as_str()
logger.warning(
Elsie4ever marked this conversation as resolved.
Show resolved Hide resolved
f"Skip capturing CRD for {service_moniker} since {expected_api_version} is not deployed, "
Elsie4ever marked this conversation as resolved.
Show resolved Hide resolved
"will try to get rest of the resources..."
)

# still try fetching other resources even crds are not available due to api version mismatch
bundle_method = api_info["prepare_bundle"]
# Check if the function takes a second argument
Expand Down
4 changes: 4 additions & 0 deletions azext_edge/tests/edge/support/test_support_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ def test_create_bundle_crd_work(
support_bundle(None, ops_service=OpsServiceType.mq.value, bundle_dir=a_bundle_dir)

if mocked_cluster_resources["param"] == []:
mocked_root_logger.warning.assert_called_with(
"Skip capturing CRD for broker since mqtt.iotoperations.azure.com/[v1beta1] is not deployed, "
"will try to get rest of the resources..."
)
mocked_assemble_crd_work.assert_not_called()
else:
mocked_assemble_crd_work.assert_called_once()
Expand Down