Skip to content

Fix output of peadm::status when used with multiple clusters #209

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

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
39 changes: 21 additions & 18 deletions plans/status.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

# produce titles and headers for tables
$table_title = "Overall Status: ${overall_status}"
$table_head = ['Stack', 'Status']
$service_table_head = ['Stack', 'Service', 'Url', 'Status']
$table_head = ['Cluster', 'Status']
$service_table_head = ['Cluster', 'Service', 'Url', 'Status']

$stack_table_rows = $stack_status.map | $item | { [$item[0], $item[1][status]] }
$passed_table_rows = $overall_passed_stacks.map | $item | { [$item[0], $item[1][status]] }
Expand All @@ -60,26 +60,29 @@

# print to table via out::message or return json output
if $format == 'table' {
$summary_table = format::table({title => $table_title,
head => $table_head,
rows => $stack_table_rows,
style => {width => 80}
})
out::message($summary_table)
# Summary table
out::message(
format::table({
title => $table_title,
head => $table_head,
rows => $stack_table_rows}))

# Failed services table
unless $bad_svc_rows.empty {
$failed_table = format::table({title => 'Failed Service Status',
head => $service_table_head,
rows => $bad_svc_rows[0]
})
out::message($failed_table)
out::message(
format::table({
title => 'Failed Service Status',
head => $service_table_head,
rows => $bad_svc_rows.reduce([]) |$memo,$rows| { $memo + $rows }}))
}

# Operational services table
if $verbose and ! $good_svc_rows.empty {
$passed_table = format::table({title => 'Operational Service Status',
head => $service_table_head,
rows => $good_svc_rows[0]
})
out::message($passed_table)
out::message(
format::table({
title => 'Operational Service Status',
head => $service_table_head,
rows => $good_svc_rows.reduce([]) |$memo,$rows| { $memo + $rows }}))
}
} else {
if $summarize {
Expand Down
42 changes: 30 additions & 12 deletions spec/fixtures/plans/failed_table.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
+-----------+------------------+--------------------------+--------+
| Failed Service Status |
+-----------+------------------+--------------------------+--------+
| Stack | Service | Url | Status |
+-----------+------------------+--------------------------+--------+
| pnw_stack | file-sync-client | pe-std-replica.puppet.vm | failed |
| pnw_stack | master | pe-std-replica.puppet.vm | failed |
| pnw_stack | classifier | pe-std-replica.puppet.vm | failed |
| pnw_stack | rbac | pe-std-replica.puppet.vm | failed |
| pnw_stack | activity | pe-std-replica.puppet.vm | failed |
| pnw_stack | puppetdb | pe-std-replica.puppet.vm | failed |
+-----------+------------------+--------------------------+--------+
+-----------------+------------------+--------------------------+--------+
| Failed Service Status |
+-----------------+------------------+--------------------------+--------+
| Cluster | Service | Url | Status |
+-----------------+------------------+--------------------------+--------+
| pnw_stack | file-sync-client | pe-std-replica.puppet.vm | failed |
| pnw_stack | master | pe-std-replica.puppet.vm | failed |
| pnw_stack | classifier | pe-std-replica.puppet.vm | failed |
| pnw_stack | rbac | pe-std-replica.puppet.vm | failed |
| pnw_stack | activity | pe-std-replica.puppet.vm | failed |
| pnw_stack | puppetdb | pe-std-replica.puppet.vm | failed |
| east_stack | file-sync-client | pe-std-replica.puppet.vm | failed |
| east_stack | master | pe-std-replica.puppet.vm | failed |
| east_stack | classifier | pe-std-replica.puppet.vm | failed |
| east_stack | rbac | pe-std-replica.puppet.vm | failed |
| east_stack | activity | pe-std-replica.puppet.vm | failed |
| east_stack | puppetdb | pe-std-replica.puppet.vm | failed |
| west_stack | file-sync-client | pe-std-replica.puppet.vm | failed |
| west_stack | master | pe-std-replica.puppet.vm | failed |
| west_stack | classifier | pe-std-replica.puppet.vm | failed |
| west_stack | rbac | pe-std-replica.puppet.vm | failed |
| west_stack | activity | pe-std-replica.puppet.vm | failed |
| west_stack | puppetdb | pe-std-replica.puppet.vm | failed |
| northeast_stack | file-sync-client | pe-std-replica.puppet.vm | failed |
| northeast_stack | master | pe-std-replica.puppet.vm | failed |
| northeast_stack | classifier | pe-std-replica.puppet.vm | failed |
| northeast_stack | rbac | pe-std-replica.puppet.vm | failed |
| northeast_stack | activity | pe-std-replica.puppet.vm | failed |
| northeast_stack | puppetdb | pe-std-replica.puppet.vm | failed |
+-----------------+------------------+--------------------------+--------+
62 changes: 46 additions & 16 deletions spec/fixtures/plans/passed_table.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,46 @@
+-----------+---------------------------+------------------+-------------+
| Operational Service Status |
+-----------+---------------------------+------------------+-------------+
| Stack | Service | Url | Status |
+-----------+---------------------------+------------------+-------------+
| pnw_stack | code-manager-service | pe-std.puppet.vm | operational |
| pnw_stack | file-sync-storage-service | pe-std.puppet.vm | operational |
| pnw_stack | file-sync-client-service | pe-std.puppet.vm | operational |
| pnw_stack | pe-master | pe-std.puppet.vm | operational |
| pnw_stack | classifier-service | pe-std.puppet.vm | operational |
| pnw_stack | rbac-service | pe-std.puppet.vm | operational |
| pnw_stack | activity-service | pe-std.puppet.vm | operational |
| pnw_stack | orchestrator-service | pe-std.puppet.vm | operational |
| pnw_stack | broker-service | pe-std.puppet.vm | operational |
| pnw_stack | puppetdb-status | pe-std.puppet.vm | operational |
+-----------+---------------------------+------------------+-------------+
+-----------------+---------------------------+------------------+-------------+
| Operational Service Status |
+-----------------+---------------------------+------------------+-------------+
| Cluster | Service | Url | Status |
+-----------------+---------------------------+------------------+-------------+
| pnw_stack | code-manager-service | pe-std.puppet.vm | operational |
| pnw_stack | file-sync-storage-service | pe-std.puppet.vm | operational |
| pnw_stack | file-sync-client-service | pe-std.puppet.vm | operational |
| pnw_stack | pe-master | pe-std.puppet.vm | operational |
| pnw_stack | classifier-service | pe-std.puppet.vm | operational |
| pnw_stack | rbac-service | pe-std.puppet.vm | operational |
| pnw_stack | activity-service | pe-std.puppet.vm | operational |
| pnw_stack | orchestrator-service | pe-std.puppet.vm | operational |
| pnw_stack | broker-service | pe-std.puppet.vm | operational |
| pnw_stack | puppetdb-status | pe-std.puppet.vm | operational |
| east_stack | code-manager-service | pe-std.puppet.vm | operational |
| east_stack | file-sync-storage-service | pe-std.puppet.vm | operational |
| east_stack | file-sync-client-service | pe-std.puppet.vm | operational |
| east_stack | pe-master | pe-std.puppet.vm | operational |
| east_stack | classifier-service | pe-std.puppet.vm | operational |
| east_stack | rbac-service | pe-std.puppet.vm | operational |
| east_stack | activity-service | pe-std.puppet.vm | operational |
| east_stack | orchestrator-service | pe-std.puppet.vm | operational |
| east_stack | broker-service | pe-std.puppet.vm | operational |
| east_stack | puppetdb-status | pe-std.puppet.vm | operational |
| west_stack | code-manager-service | pe-std.puppet.vm | operational |
| west_stack | file-sync-storage-service | pe-std.puppet.vm | operational |
| west_stack | file-sync-client-service | pe-std.puppet.vm | operational |
| west_stack | pe-master | pe-std.puppet.vm | operational |
| west_stack | classifier-service | pe-std.puppet.vm | operational |
| west_stack | rbac-service | pe-std.puppet.vm | operational |
| west_stack | activity-service | pe-std.puppet.vm | operational |
| west_stack | orchestrator-service | pe-std.puppet.vm | operational |
| west_stack | broker-service | pe-std.puppet.vm | operational |
| west_stack | puppetdb-status | pe-std.puppet.vm | operational |
| northeast_stack | code-manager-service | pe-std.puppet.vm | operational |
| northeast_stack | file-sync-storage-service | pe-std.puppet.vm | operational |
| northeast_stack | file-sync-client-service | pe-std.puppet.vm | operational |
| northeast_stack | pe-master | pe-std.puppet.vm | operational |
| northeast_stack | classifier-service | pe-std.puppet.vm | operational |
| northeast_stack | rbac-service | pe-std.puppet.vm | operational |
| northeast_stack | activity-service | pe-std.puppet.vm | operational |
| northeast_stack | orchestrator-service | pe-std.puppet.vm | operational |
| northeast_stack | broker-service | pe-std.puppet.vm | operational |
| northeast_stack | puppetdb-status | pe-std.puppet.vm | operational |
+-----------------+---------------------------+------------------+-------------+
34 changes: 17 additions & 17 deletions spec/fixtures/plans/summarized.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,102 +10,102 @@
},
"failed": [
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "file-sync-client",
"Url": "pe-std-replica.puppet.vm",
"Status": "failed"
},
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "master",
"Url": "pe-std-replica.puppet.vm",
"Status": "failed"
},
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "classifier",
"Url": "pe-std-replica.puppet.vm",
"Status": "failed"
},
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "rbac",
"Url": "pe-std-replica.puppet.vm",
"Status": "failed"
},
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "activity",
"Url": "pe-std-replica.puppet.vm",
"Status": "failed"
},
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "puppetdb",
"Url": "pe-std-replica.puppet.vm",
"Status": "failed"
}
],
"operational": [
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "code-manager-service",
"Url": "pe-std.puppet.vm",
"Status": "operational"
},
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "file-sync-storage-service",
"Url": "pe-std.puppet.vm",
"Status": "operational"
},
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "file-sync-client-service",
"Url": "pe-std.puppet.vm",
"Status": "operational"
},
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "pe-master",
"Url": "pe-std.puppet.vm",
"Status": "operational"
},
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "classifier-service",
"Url": "pe-std.puppet.vm",
"Status": "operational"
},
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "rbac-service",
"Url": "pe-std.puppet.vm",
"Status": "operational"
},
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "activity-service",
"Url": "pe-std.puppet.vm",
"Status": "operational"
},
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "orchestrator-service",
"Url": "pe-std.puppet.vm",
"Status": "operational"
},
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "broker-service",
"Url": "pe-std.puppet.vm",
"Status": "operational"
},
{
"Stack": "pnw_stack",
"Cluster": "pnw_stack",
"Service": "puppetdb-status",
"Url": "pe-std.puppet.vm",
"Status": "operational"
}
]
}
}
20 changes: 10 additions & 10 deletions spec/fixtures/plans/summary_table.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
+---------------------------------------+--------------------------------------+
| Overall Status: degraded |
+---------------------------------------+--------------------------------------+
| Stack | Status |
+---------------------------------------+--------------------------------------+
| pnw_stack | degraded |
| east_stack | degraded |
| west_stack | degraded |
| northeast_stack | degraded |
+---------------------------------------+--------------------------------------+
+-----------------+----------+
| Overall Status: degraded |
+-----------------+----------+
| Cluster | Status |
+-----------------+----------+
| pnw_stack | degraded |
| east_stack | degraded |
| west_stack | degraded |
| northeast_stack | degraded |
+-----------------+----------+