From 10634ccea13beebbd0b8438a2e19672fbc6988f6 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 22 May 2022 12:31:48 +0900 Subject: [PATCH] HBASE-27030 Fix undefined local variable error in draining_servers.rb (#4427) HBASE-21812 replaced a for-loop with an each block. Each block introduces a new scope, so a local variable defined inside it cannot be accessed afterwards. NameError: undefined local variable or method `admin' for main:Object getServerNames at /opt/khp/hbase/bin/draining_servers.rb:81 addServers at /opt/khp/hbase/bin/draining_servers.rb:88
at /opt/khp/hbase/bin/draining_servers.rb:146 This commit defines the admin local variable in the current scope beforehand, so that we can still access it after the block. Signed-off-by: Duo Zhang --- bin/draining_servers.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/draining_servers.rb b/bin/draining_servers.rb index 99d957e1251a..9e34b2bcfb07 100644 --- a/bin/draining_servers.rb +++ b/bin/draining_servers.rb @@ -61,6 +61,7 @@ def getServers(admin) def getServerNames(hostOrServers, config) ret = [] connection = ConnectionFactory.createConnection(config) + admin = nil hostOrServers.each do |host_or_server| # check whether it is already serverName. No need to connect to cluster