You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2022/05/22 07:07:53 UTC

[hbase] branch branch-2.4 updated: HBASE-27030 Fix undefined local variable error in draining_servers.rb (#4427)

This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.4 by this push:
     new d310bf96239 HBASE-27030 Fix undefined local variable error in draining_servers.rb (#4427)
d310bf96239 is described below

commit d310bf962398c0d62236d9799741f027a8e277b0
Author: Junegunn Choi <ju...@gmail.com>
AuthorDate: Sun May 22 12:31:48 2022 +0900

    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 <zh...@apache.org>
    (cherry picked from commit 2b573ae377be926922f48238c4da45a2289f318f)
---
 bin/draining_servers.rb | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bin/draining_servers.rb b/bin/draining_servers.rb
index 12f0ba4e174..7e1a4e95c25 100644
--- a/bin/draining_servers.rb
+++ b/bin/draining_servers.rb
@@ -61,6 +61,7 @@ end
 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