Shawyeok commented on PR #2180:
URL: https://github.com/apache/zookeeper/pull/2180#issuecomment-2295672361

   @ctubbsii 
   
   > The problem isn't really the addition of base64 or hex, but the addition 
of more code paths for the user to consider, making it harder for users to 
predict the behavior of zkCli.
   >
   > My preference would be to not modify the zkCli interactive shell. Instead, 
I would prefer a better tool that can interact directly with the user's 
terminal. So, if you need base64 encoding or hexdump, you can do something like 
bin/zk get /path/to/node | base64 or <something.bin bin/zk set /path/to/node 
--digest-auth "secret". That way, instead of baking in new features into the 
zkCli, users can more easily take full advantage of the wide variety of 
existing tools available to them on the command-line.
   
   The default behavior of the get or set command isn't changed; users may not 
even notice any difference if they just rely on plain text data. I understand 
what you aim for: making the zkCli tool simple and stupid, letting it connect 
with other tools via pipe, which is a bit like the Unix philosophy. The reality 
is that the zkCli tool is more of an interactive CLI tool, not designed for 
pipe connections. It prints a lot of stuff on stdout, such as logs, connecting 
messages, and watchers. Here is an example of a simple get command output on 
stdout:
   ```
   # bin/zkCli.sh -server 172.17.5.175 2>/dev/null get /foo 2>/dev/null
   Connecting to 172.17.5.175
   2024-08-19 01:53:30,575 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:zookeeper.version=3.10.0-SNAPSHOT-a78341b1e7b48d85ce4eb9d9dd7ce4089b437db6-dirty,
 built on 2024-08-18 10:08 UTC
   2024-08-19 01:53:30,579 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:host.name=macbook.lan
   2024-08-19 01:53:30,579 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:java.version=1.8.0_351
   2024-08-19 01:53:30,579 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:java.vendor=Oracle Corporation
   2024-08-19 01:53:30,579 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_351.jdk/Contents/Home/jre
   2024-08-19 01:53:30,579 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:java.class.path=<ELLIPSIS>
   2024-08-19 01:53:30,580 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:java.library.path=<ELLIPSIS>
   2024-08-19 01:53:30,580 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:java.io.tmpdir=/var/folders/cp/bcjqx5q56h7gp_3kts42xglm0000gp/T/
   2024-08-19 01:53:30,580 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:java.compiler=<NA>
   2024-08-19 01:53:30,580 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:os.name=Mac OS X
   2024-08-19 01:53:30,580 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:os.arch=x86_64
   2024-08-19 01:53:30,580 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:os.version=14.5
   2024-08-19 01:53:30,580 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:user.name=<ELLIPSIS>
   2024-08-19 01:53:30,580 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:user.home=<ELLIPSIS>
   2024-08-19 01:53:30,580 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:user.dir=<ELLIPSIS>
   2024-08-19 01:53:30,580 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:jvm.memory.free=226MB
   2024-08-19 01:53:30,580 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:jvm.memory.max=245MB
   2024-08-19 01:53:30,580 [myid:] - INFO  [main:o.a.z.Environment@98] - Client 
environment:jvm.memory.total=245MB
   2024-08-19 01:53:30,581 [myid:] - INFO  [main:o.a.z.ZooKeeper@1082] - 
Initiating client connection, connectString=172.17.5.175 sessionTimeout=30000 
watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@44c8afef
   2024-08-19 01:53:30,588 [myid:] - INFO  [main:o.a.z.c.X509Util@88] - Setting 
-D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated 
TLS renegotiation
   2024-08-19 01:53:30,929 [myid:] - INFO  [main:o.a.z.c.X509Util@110] - 
Default TLS protocol is TLSv1.3, supported TLS protocols are [TLSv1.3, TLSv1.2, 
TLSv1.1, TLSv1, SSLv3, SSLv2Hello]
   2024-08-19 01:53:30,941 [myid:] - INFO  [main:o.a.z.ClientCnxnSocket@233] - 
jute.maxbuffer value is 1048575 Bytes
   2024-08-19 01:53:30,951 [myid:] - INFO  [main:o.a.z.ClientCnxn@1677] - 
zookeeper.request.timeout value is 0. feature enabled=false
   2024-08-19 01:53:31,023 [myid:172.17.5.175:2181] - INFO  
[main-SendThread(172.17.5.175:2181):o.a.z.ClientCnxn$SendThread@1113] - Opening 
socket connection to server 172.17.5.175/172.17.5.175:2181.
   2024-08-19 01:53:31,024 [myid:172.17.5.175:2181] - INFO  
[main-SendThread(172.17.5.175:2181):o.a.z.ClientCnxn$SendThread@1115] - SASL 
config status: Will not attempt to authenticate using SASL (unknown error)
   2024-08-19 01:53:31,047 [myid:172.17.5.175:2181] - INFO  
[main-SendThread(172.17.5.175:2181):o.a.z.ClientCnxn$SendThread@966] - Socket 
connection established, initiating session, client: /10.7.1.242:58827, server: 
172.17.5.175/172.17.5.175:2181
   2024-08-19 01:53:31,084 [myid:172.17.5.175:2181] - INFO  
[main-SendThread(172.17.5.175:2181):o.a.z.ClientCnxn$SendThread@1383] - Session 
establishment complete on server 172.17.5.175/172.17.5.175:2181, session id = 
0x40ef32da9020099, negotiated timeout = 30000
   
   WATCHER::
   
   WatchedEvent state:SyncConnected type:None path:null zxid: -1
   zookeeper
   2024-08-19 01:53:31,105 [myid:] - INFO  [main:o.a.z.u.ServiceUtils@45] - 
Exiting JVM with code 0
   ```
   
   Filtering with grep -v ' - INFO ', you still get:
   ```
   Connecting to 172.17.5.175
   
   WATCHER::
   
   WatchedEvent state:SyncConnected type:None path:null zxid: -1
   zookeeper
   ```
   
   It's hard to write a command in the `bin/zk get /path/to/node | base64` 
format, at least in the current implementation of the zkCli tool.
   
   > I'd consider binary data to fall into the category of domain-specific 
serialization.
   
   Binary data is a first-class primitive in ZooKeeper. All the setData and 
getData methods exchange data via byte arrays, not text. Therefore, binary data 
should not be considered domain-specific serialization.
   
   
   In conclusion, what you aim for seems to require a brand new tool similar to 
`etcdctl`. I believe it is not appropriate to implement this in this small 
feature PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to