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 <main> 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 <zhangduo@apache.org> (cherry picked from commit 2b573ae377be926922f48238c4da45a2289f318f)
This commit is contained in:
parent
45c577a099
commit
d310bf9623
@ -61,6 +61,7 @@ end
|
|||||||
def getServerNames(hostOrServers, config)
|
def getServerNames(hostOrServers, config)
|
||||||
ret = []
|
ret = []
|
||||||
connection = ConnectionFactory.createConnection(config)
|
connection = ConnectionFactory.createConnection(config)
|
||||||
|
admin = nil
|
||||||
|
|
||||||
hostOrServers.each do |host_or_server|
|
hostOrServers.each do |host_or_server|
|
||||||
# check whether it is already serverName. No need to connect to cluster
|
# check whether it is already serverName. No need to connect to cluster
|
||||||
|
Loading…
x
Reference in New Issue
Block a user