-
Notifications
You must be signed in to change notification settings - Fork 7.3k
ZOOKEEPER-3599: cli.c: Resuscitate "old-style" argument parsing #1131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This PR became partially obsolete with the merge of ZOOKEEPER-2122 into The latter makes A big difference, however, is that resulting argument parsing logic is not backwards-compatible: running @eolivelli, @anmolnar, @symat, @suhasdantkale: What do you think: should I just drop this PR and the associated ticket, or should I try and "salvage" the backwards compatibility bits? (I, for one, won't be sad to see old-style argument parsing disappear, but it might break some workflows and/or docs.) |
eolivelli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sponsor this idea of enhancing the C cli.
I don't know how many users of the C client exist, I think we are not suggesting users to use this cli. So changing the behavior is not an hard breaking change.
Personally I have always thought about the C cli as an example of how to use the C client.
I am not a C expert so I will leave a good code review to the other committers.
+0 from me
Thank you for doing this
|
Sorry, I didn't see this PR before. I actually much prefer the In general I prefer backward compatible changes. In the case of the C command line client, I am not that sure. I don't think people would use it heavily, especially not as an interface. But maybe you are right and someone is using / calling it from some devops or monitoring tool. In this case it would be nice to keep the old argument parsing. If you have the time to work on this and make command line arguments backward compatible, then I would suggest to add it back only as a secondary fallback option. Like if the new |
|
@ztzg The other patch #1107 has been submitted now. Please rebase this one. |
|
@eolivelli, @symat, @anmolnar: I think we all agree that
Secondary/fallback parsing sounds reasonable. I'll look into it as I have to rebase related work on top of #1107 anyway. |
There is no reason for it not to be--except for a silly const- correctness issue in 'strtol', and we can work around the latter by introducing a temporary variable.
The pointed-to string has the same lifetime as the argv[] entries, as
per POSIX:
https://pubs.opengroup.org/onlinepubs/009695399/functions/getopt.html
https://stackoverflow.com/a/53508112
This avoids a tiny memory leak for options passed more than once :)
ZOOKEEPER-2122 added SSL support to the C client and to the cli_st/mt tools. It introduced a (much-welcome!) GNU-style 'getopt_long' argument parsing, but did not try to preserve backwards compatibility. An earlier version of apache#1131 introduced optional POSIX-style 'getopt' argument parsing, and was consequently largely obsoleted by SSL update. It did, however, support "old-style" argument parsing, to avoid breaking workflows. This patch salvages that feature, while preserving the 'getopt_long' goodness. It is "legacy-only"; adding new positional arguments is not supported--as discussed in this thread: apache#1131 (review)
255bc26 to
b4e3106
Compare
|
The latest PR failed to build because one of the Jenkins workers was did not have the "standard" OpenSSL configuration: #1107 (comment); This should be fixed by ZOOKEEPER-3630. |
|
retest maven build |
|
Refer to this link for build results (access rights to CI server needed): Build result: FAILURE[...truncated 928.35 KB...][JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/pom.xml to org.apache.zookeeper/parent/3.6.0-SNAPSHOT/parent-3.6.0-SNAPSHOT.pom[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-recipes/zookeeper-recipes-lock/pom.xml to org.apache.zookeeper/zookeeper-recipes-lock/3.6.0-SNAPSHOT/zookeeper-recipes-lock-3.6.0-SNAPSHOT.pom[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-contrib/pom.xml to org.apache.zookeeper/zookeeper-contrib/3.6.0-SNAPSHOT/zookeeper-contrib-3.6.0-SNAPSHOT.pom[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-client/pom.xml to org.apache.zookeeper/zookeeper-client/3.6.0-SNAPSHOT/zookeeper-client-3.6.0-SNAPSHOT.pom[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-jute/pom.xml to org.apache.zookeeper/zookeeper-jute/3.6.0-SNAPSHOT/zookeeper-jute-3.6.0-SNAPSHOT.pom[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-jute/target/zookeeper-jute-3.6.0-SNAPSHOT.jar to org.apache.zookeeper/zookeeper-jute/3.6.0-SNAPSHOT/zookeeper-jute-3.6.0-SNAPSHOT.jar[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-jute/target/zookeeper-jute-3.6.0-SNAPSHOT-tests.jar to org.apache.zookeeper/zookeeper-jute/3.6.0-SNAPSHOT/zookeeper-jute-3.6.0-SNAPSHOT-tests.jar[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-jute/target/zookeeper-jute-3.6.0-SNAPSHOT-sources.jar to org.apache.zookeeper/zookeeper-jute/3.6.0-SNAPSHOT/zookeeper-jute-3.6.0-SNAPSHOT-sources.jar[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-jute/target/zookeeper-jute-3.6.0-SNAPSHOT-javadoc.jar to org.apache.zookeeper/zookeeper-jute/3.6.0-SNAPSHOT/zookeeper-jute-3.6.0-SNAPSHOT-javadoc.jar[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-recipes/zookeeper-recipes-queue/pom.xml to org.apache.zookeeper/zookeeper-recipes-queue/3.6.0-SNAPSHOT/zookeeper-recipes-queue-3.6.0-SNAPSHOT.pom[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-docs/pom.xml to org.apache.zookeeper/zookeeper-docs/3.6.0-SNAPSHOT/zookeeper-docs-3.6.0-SNAPSHOT.pom[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-docs/target/zookeeper-docs-3.6.0-SNAPSHOT.jar to org.apache.zookeeper/zookeeper-docs/3.6.0-SNAPSHOT/zookeeper-docs-3.6.0-SNAPSHOT.jar[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-docs/target/zookeeper-docs-3.6.0-SNAPSHOT-tests.jar to org.apache.zookeeper/zookeeper-docs/3.6.0-SNAPSHOT/zookeeper-docs-3.6.0-SNAPSHOT-tests.jar[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-docs/target/zookeeper-docs-3.6.0-SNAPSHOT-sources.jar to org.apache.zookeeper/zookeeper-docs/3.6.0-SNAPSHOT/zookeeper-docs-3.6.0-SNAPSHOT-sources.jar[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-recipes/pom.xml to org.apache.zookeeper/zookeeper-recipes/3.6.0-SNAPSHOT/zookeeper-recipes-3.6.0-SNAPSHOT.pom[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-client/zookeeper-client-c/pom.xml to org.apache.zookeeper/zookeeper-client-c/3.6.0-SNAPSHOT/zookeeper-client-c-3.6.0-SNAPSHOT.pom[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-contrib/zookeeper-contrib-rest/pom.xml to org.apache.zookeeper/zookeeper-contrib-rest/3.6.0-SNAPSHOT/zookeeper-contrib-rest-3.6.0-SNAPSHOT.pom[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-assembly/pom.xml to org.apache.zookeeper/zookeeper-assembly/3.6.0-SNAPSHOT/zookeeper-assembly-3.6.0-SNAPSHOT.pom[JENKINS] Archiving /home/jenkins/jenkins-slave/workspace/PreCommit-ZOOKEEPER-github-pr-build-maven/zookeeper-contrib/zookeeper-contrib-zooinspector/pom.xml to org.apache.zookeeper/zookeeper-contrib-zooinspector/3.6.0-SNAPSHOT/zookeeper-contrib-zooinspector-3.6.0-SNAPSHOT.pomchannel stopped[SpotBugs] Skipping execution of recorder since overall result is 'FAILURE'Setting status of b4e3106 to FAILURE with url https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build-maven/1684/ and message: 'FAILURE 'Using context: JenkinsMaven |
|
retest maven build |
|
Refer to this link for build results (access rights to CI server needed): |
|
looks great, thank you! I did some testing with your patch and I am not sure if it is caused by this PR or not, but batch mode seems not working now with using But doing the same with I was building using |
|
Hi @symat, Thank you for the test, and report. Nice catch! That was a bit puzzling... but it turns out that "batch mode" has never been implemented in From the first day on, I have now opened ZOOKEEPER-3640, "Implement "batch mode" in cli_mt". If you are otherwise happy with the PR, could we get this moving? I'd like to get the pipeline flushed and get a rebased/aligned SASL client sitting on top :) |
|
Okay—Thanks! |
nkalmar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not much competent in C either, but since it's a cli change to preserve backward compatibility, it looks safe to me. I'll leave the patch open for now, see if any further comment comes until, let's say, tomorrow. Or any other committers are free to merge earlier. Or if @eolivelli changes he's +0 to +1 I'll merge :)
symat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Merged to master. Thanks @ztzg |
ZOOKEEPER-2122 added SSL support to the C client and to the `cli_st`/`mt` tools. It introduced (much-welcome!) GNU-style `getopt_long` argument parsing, but did not try to preserve backwards compatibility. An earlier version of this apache#1131 introduced (optional) POSIX-style `getopt` argument parsing, and was consequently largely obsoleted by the SSL update. It did, however, support "old-style" arguments to avoid [breaking workflows](https://xkcd.com/1172/). This patch salvages that feature while preserving the `getopt_long` goodness. It is "legacy-only"; adding new positional arguments is not supported—as discussed in this thread: apache#1131 (review). Author: Damien Diederen <[email protected]> Reviewers: Enrico Olivelli <[email protected]>, Norbert Kalmar <[email protected]> Closes apache#1131 from ztzg/ZOOKEEPER-3599-use-getopt-in-cli-c
ZOOKEEPER-2122 added SSL support to the C client and to the `cli_st`/`mt` tools. It introduced (much-welcome!) GNU-style `getopt_long` argument parsing, but did not try to preserve backwards compatibility. An earlier version of this apache#1131 introduced (optional) POSIX-style `getopt` argument parsing, and was consequently largely obsoleted by the SSL update. It did, however, support "old-style" arguments to avoid [breaking workflows](https://xkcd.com/1172/). This patch salvages that feature while preserving the `getopt_long` goodness. It is "legacy-only"; adding new positional arguments is not supported—as discussed in this thread: apache#1131 (review). Author: Damien Diederen <[email protected]> Reviewers: Enrico Olivelli <[email protected]>, Norbert Kalmar <[email protected]> Closes apache#1131 from ztzg/ZOOKEEPER-3599-use-getopt-in-cli-c
ZOOKEEPER-2122 added SSL support to the C client and to the `cli_st`/`mt` tools. It introduced (much-welcome!) GNU-style `getopt_long` argument parsing, but did not try to preserve backwards compatibility. An earlier version of this apache#1131 introduced (optional) POSIX-style `getopt` argument parsing, and was consequently largely obsoleted by the SSL update. It did, however, support "old-style" arguments to avoid [breaking workflows](https://xkcd.com/1172/). This patch salvages that feature while preserving the `getopt_long` goodness. It is "legacy-only"; adding new positional arguments is not supported—as discussed in this thread: apache#1131 (review). Author: Damien Diederen <[email protected]> Reviewers: Enrico Olivelli <[email protected]>, Norbert Kalmar <[email protected]> Closes apache#1131 from ztzg/ZOOKEEPER-3599-use-getopt-in-cli-c
ZOOKEEPER-2122 added SSL support to the C client and to the `cli_st`/`mt` tools. It introduced (much-welcome!) GNU-style `getopt_long` argument parsing, but did not try to preserve backwards compatibility. An earlier version of this apache#1131 introduced (optional) POSIX-style `getopt` argument parsing, and was consequently largely obsoleted by the SSL update. It did, however, support "old-style" arguments to avoid [breaking workflows](https://xkcd.com/1172/). This patch salvages that feature while preserving the `getopt_long` goodness. It is "legacy-only"; adding new positional arguments is not supported—as discussed in this thread: apache#1131 (review). Author: Damien Diederen <[email protected]> Reviewers: Enrico Olivelli <[email protected]>, Norbert Kalmar <[email protected]> Closes apache#1131 from ztzg/ZOOKEEPER-3599-use-getopt-in-cli-c
ZOOKEEPER-2122 added SSL support to the C client and to the
cli_st/mttools. It introduced (much-welcome!) GNU-stylegetopt_longargument parsing, but did not try to preserve backwards compatibility.An earlier version of this #1131 introduced (optional) POSIX-style
getoptargument parsing, and was consequently largely obsoleted by the SSL update. It did, however, support "old-style" arguments to avoid breaking workflows.This patch salvages that feature while preserving the
getopt_longgoodness. It is "legacy-only"; adding new positional arguments is not supported—as discussed in this thread: #1131 (review).