Merge pull request #56 from elemoine/stacklight-hostname
Display an error when set_member_status fails
diff --git a/heka/files/lua/common/gse.lua b/heka/files/lua/common/gse.lua
index d1a01a6..3e6948e 100644
--- a/heka/files/lua/common/gse.lua
+++ b/heka/files/lua/common/gse.lua
@@ -95,8 +95,16 @@
function set_member_status(cluster_id, member, value, alarms, hostname)
local cluster = clusters[cluster_id]
if cluster then
+ if cluster.group_by == 'hostname' and not hostname then
+ local err = string.format(
+ 'Cannot update member status of cluster %s; ' ..
+ 'group_by is set to "hostname" while input GSE/AFD message ' ..
+ 'has no "hostname" field', cluster_id)
+ return false, err
+ end
cluster:update_fact(member, hostname, value, alarms)
end
+ return true
end
-- The cluster status depends on the status of its members.
diff --git a/heka/files/lua/filters/gse_cluster_filter.lua b/heka/files/lua/filters/gse_cluster_filter.lua
index d1fef2b..2bf6926 100644
--- a/heka/files/lua/filters/gse_cluster_filter.lua
+++ b/heka/files/lua/filters/gse_cluster_filter.lua
@@ -72,8 +72,13 @@
-- update all clusters that depend on this entity
for _, cluster_id in ipairs(cluster_ids) do
- gse.set_member_status(cluster_id, member_id, status, alarms, hostname)
+ local ok, err = gse.set_member_status(
+ cluster_id, member_id, status, alarms, hostname)
+ if not ok then
+ return -1, err
+ end
end
+
return 0
end