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

fix: update broker runtime status description structure in check for latest CRD #384

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions azext_edge/edge/providers/check/base/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,7 @@ def process_resource_property_by_type(
return

display_text = f"{display_name}:"
check_manager.add_display(
target_name=target_name, namespace=namespace, display=Padding(display_text, padding)
)
check_manager.add_display(target_name=target_name, namespace=namespace, display=Padding(display_text, padding))

for property in properties:
display_text = f"- {display_name} {properties.index(property) + 1}"
Expand All @@ -308,14 +306,10 @@ def process_resource_property_by_type(
display_text = f"[cyan]{properties}[/cyan]"
padding = (0, 0, 0, padding_left + 4)

check_manager.add_display(
target_name=target_name, namespace=namespace, display=Padding(display_text, padding)
)
check_manager.add_display(target_name=target_name, namespace=namespace, display=Padding(display_text, padding))
elif isinstance(properties, dict):
display_text = f"{display_name}:"
check_manager.add_display(
target_name=target_name, namespace=namespace, display=Padding(display_text, padding)
)
check_manager.add_display(target_name=target_name, namespace=namespace, display=Padding(display_text, padding))
for prop, value in properties.items():
display_text = f"{prop}: [cyan]{value}[/cyan]"
check_manager.add_display(
Expand Down Expand Up @@ -363,9 +357,7 @@ def validate_one_of_conditions(
eval_status = CheckTaskStatus.error.value

one_of_condition = f"oneOf({conditions_names})"
check_manager.add_target_conditions(
target_name=target_name, namespace=namespace, conditions=[one_of_condition]
)
check_manager.add_target_conditions(target_name=target_name, namespace=namespace, conditions=[one_of_condition])
check_manager.add_target_eval(
target_name=target_name,
namespace=namespace,
Expand Down Expand Up @@ -467,9 +459,7 @@ def process_custom_resource_status(
if prop_value:
status_text = f"{prop_name} {{{decorate_resource_status(prop_value.get('status'))}}}."
if detail_level == ResourceOutputDetailLevel.verbose.value:
status_description = prop_value.get("statusDescription") or prop_value.get(
"output", {}
).get("message")
status_description = prop_value.get("description") or prop_value.get("output", {}).get("message")
if status_description:
status_text = status_text.replace(".", f", [cyan]{status_description}[/cyan].")

Expand Down
40 changes: 34 additions & 6 deletions azext_edge/tests/edge/checks/test_mq_checks_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ def test_check_mq_by_resource_types(ops_service, mocker, mock_resource_types, re
},
"mode": "distributed",
},
status={"runtimeStatus": {"status": ResourceState.running.value, "statusDescription": ""}},
status={
"runtimeStatus": {
"status": ResourceState.running.value,
"description": "All replicas are running.",
}
},
),
# service obj
generate_resource_stub(
Expand Down Expand Up @@ -98,7 +103,12 @@ def test_check_mq_by_resource_types(ops_service, mocker, mock_resource_types, re
("name", "mock-name"),
(
"value/status",
{"runtimeStatus": {"status": ResourceState.running.value, "statusDescription": ""}},
{
"runtimeStatus": {
"status": ResourceState.running.value,
"description": "All replicas are running.",
}
},
),
],
[
Expand Down Expand Up @@ -129,7 +139,10 @@ def test_check_mq_by_resource_types(ops_service, mocker, mock_resource_types, re
},
},
status={
"runtimeStatus": {"status": ResourceState.starting.value, "statusDescription": ""},
"runtimeStatus": {
"status": ResourceState.starting.value,
"description": "Waiting for all replicas to report ready.",
},
},
),
# service obj
Expand Down Expand Up @@ -157,7 +170,12 @@ def test_check_mq_by_resource_types(ops_service, mocker, mock_resource_types, re
("name", "mock-name"),
(
"value/status",
{"runtimeStatus": {"status": ResourceState.starting.value, "statusDescription": ""}},
{
"runtimeStatus": {
"status": ResourceState.starting.value,
"description": "Waiting for all replicas to report ready.",
}
},
),
],
[
Expand Down Expand Up @@ -192,7 +210,12 @@ def test_check_mq_by_resource_types(ops_service, mocker, mock_resource_types, re
},
"mode": "distributed",
},
status={"runtimeStatus": {"status": ResourceState.running.value, "statusDescription": ""}},
status={
"runtimeStatus": {
"status": ResourceState.running.value,
"statusDescription": "All replicas are running.",
}
},
),
# service obj
generate_resource_stub(
Expand Down Expand Up @@ -224,7 +247,12 @@ def test_check_mq_by_resource_types(ops_service, mocker, mock_resource_types, re
("name", "mock-name"),
(
"value/status",
{"runtimeStatus": {"status": ResourceState.running.value, "statusDescription": ""}},
{
"runtimeStatus": {
"status": ResourceState.running.value,
"statusDescription": "All replicas are running.",
}
},
),
],
[
Expand Down
Loading