Skip to content

Commit

Permalink
fix zk reports
Browse files Browse the repository at this point in the history
  • Loading branch information
terrywbrady committed Nov 9, 2024
1 parent f44e229 commit 86617a1
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src-admintool/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h3>ZooKeeper</h3>
<li class="graph"><a href="{{COLLADMIN_ROOT}}/web/zkdump.html?zkpath=/">ZK Node Report</a></li>
<li class="graph"><a href="{{COLLADMIN_ROOT}}/web/zkdump.html?zkpath=/&mode=keys">ZK Node Report - Keys Only</a></li>
<li class="graph"><a href="{{COLLADMIN_ROOT}}/web/zkdump.html?zkpath=/locks">ZK Node Report: Locks</a></li>
<li class="graph"><a href="{{COLLADMIN_ROOT}}/web/zkdump.html?zkpath=/&mode=test">ZK Node Orphan Report</a></li>
<li class="graph"><a href="{{COLLADMIN_HOME}}?path=zk_orphan">ZK Node Orphan Report</a></li>
</ul>

<h3>System State</h3>
Expand Down
72 changes: 55 additions & 17 deletions src-colladmin/actions/zookeeper_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def initialize(config, action, path, myparams)
@zkpath = myparams.fetch('zkpath', '/')
@mode = myparams.fetch('mode', 'data')
@full = false
@test_results = []
super
end

Expand All @@ -109,7 +110,7 @@ def system_node(n)
def show_data(n)
d = get_data(n)
df = d.is_a?(Hash) ? "\n#{JSON.pretty_generate(d)}" : " #{d}"
@buf << df
@buf << df unless @buf.nil?
end

def get_data(n)
Expand All @@ -123,13 +124,18 @@ def get_data(n)
end
end

def test_node(n)
@buf << "\n Test: #{n} should exist: "
@buf << (@zk.exists?(n) ? 'PASS' : 'FAIL')
def test_node(path, n)
return if @zk.exists?(n)
result = {path: path, test: "Test: #{n} should exist", status: 'FAIL'}
@test_results.append([result[:path], result[:test], result[:status]])
@buf << "\n #{result[:test]}: #{result[:status]}" unless @buf.nil?
end

def test_not_node(n)
@buf << "\n Test: #{n} should NOT exist: FAIL" if @zk.exists?(n)
def test_not_node(path, n)
return unless @zk.exists?(n)
result = {path: path, test: "Test: #{n} should NOT exist", status: 'FAIL'}
@test_results.append([result[:path], result[:test], result[:status]])
@buf << "\n #{result[:test]}: #{result[:status]}" unless @buf.nil?
end

def show_test(n)
Expand All @@ -141,17 +147,17 @@ def show_test(n)
case n
when %r{^/batch-uuids/(.*)}
d = get_data(n)
test_node("/batches/#{d}")
test_node(n, "/batches/#{d}")
when %r{^/batches/bid[0-9]+/submission}
d = get_data(n).fetch(:batchID, 'na')
test_node("/batch-uuids/#{d}")
test_node(n, "/batch-uuids/#{d}")
when rx1
jid = rx1.match(n)[1]
test_node("/jobs/#{jid}")
test_node(n, "/jobs/#{jid}")
when rx2
jid = rx2.match(n)[1]
bid = get_data(n)
test_node("/batches/#{bid}")
test_node(n, "/batches/#{bid}")
d = get_data("/jobs/#{jid}/status")
status = d.fetch(:status, 'na').downcase
case status
Expand All @@ -164,36 +170,37 @@ def show_test(n)
else
bstatus = 'batch-processing'
end
test_node("/batches/#{bid}/states/#{bstatus}/#{jid}")
test_node(n, "/batches/#{bid}/states/#{bstatus}/#{jid}")
%w[batch-deleted batch-completed batch-failed batch-processing].each do |ts|
next if ts == bstatus

test_not_node("/batches/#{bid}/states/#{ts}/#{jid}")
test_not_node(n, "/batches/#{bid}/states/#{ts}/#{jid}")
end
when rx3
jid = rx3.match(n)[1]
d = get_data("#{n}/status")
status = d.fetch(:status, 'na').downcase
priority = get_data("#{n}/priority")
test_node("/jobs/states/#{status}/#{format('%02d', priority)}-#{jid}")
test_node(n, "/jobs/states/#{status}/#{format('%02d', priority)}-#{jid}")
when rx4
jid = rx4.match(n)[1]
test_node("/jobs/#{jid}")
test_node(n, "/jobs/#{jid}")
end
end

def report_node(n)
@buf << "#{n}:"
@buf << "#{n}:" unless @buf.nil?
if standard_node(n)
show_data(n) if @mode == 'data'
show_test(n) if @mode == 'test'
else
@buf << " Unsupported\n"
@buf << " Unsupported\n" unless @buf.nil?
end
@buf << "\n"
@buf << "\n" unless @buf.nil?
end

def check_full
return false if @buf.nil?
return true if @full

# Lambda payload limit. May need to save output to S3.
Expand All @@ -220,6 +227,37 @@ def dump_node(n = '/')
end
end

class ZookeeperDumpTableAction < ZookeeperDumpAction
def initialize(config, action, path, myparams)
super
@mode = 'test'
end
def table_headers
['Path', 'Test', 'Status']
end

def table_types
['name', 'name', 'status']
end

def table_rows(_body)
dump_node(@zkpath)
@test_results
end

def perform_action
convert_json_to_table('')
end

def has_table
true
end

def init_status
:PASS
end
end

## Base class for new style action
class ZkAction < ZookeeperAction
def get_id
Expand Down
11 changes: 10 additions & 1 deletion src-colladmin/config/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1149,4 +1149,13 @@ system_state:
- More than 30 days: PASS
- 15-30 days: WARN
- Less than 15 days: FAIL
- Less than 15 days: FAIL
zk_orphan:
link-title: ZK Orphan Report
class: ZookeeperDumpTableAction
category: queue
sensitivity: readonly
testing: automated
breadcrumb: bp_ingest
description: |
Test for ZK orphan nodes
2 changes: 1 addition & 1 deletion src-common/template/navmenu.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<a class="graph" href="{{COLLADMIN_ROOT}}/web/zkdump.html?zkpath=/">ZK Node Report</a>
<a class="graph" href="{{COLLADMIN_ROOT}}/web/zkdump.html?zkpath=/&mode=keys">ZK Node Report - Keys Only</a>
<a class="graph" href="{{COLLADMIN_ROOT}}/web/zkdump.html?zkpath=/locks">ZK Node Report: Locks</a>
<a class="graph" href="{{COLLADMIN_ROOT}}/web/zkdump.html?zkpath=/&mode=test">ZK Node Orphan Report</a>
<a class="graph" href="{{COLLADMIN_HOME}}?path=zk_orphan">ZK Node Orphan Report</a>
<a class="graph" href="{{COLLADMIN_HOME}}?path=system_state">System State - LDAP Certs</a>
</div>
</div>
Expand Down

0 comments on commit 86617a1

Please sign in to comment.