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
[STORM-3616] add optional flag to fail upload-credentials cmd if no creds were uploaded #3243
Conversation
RuiLi8080
commented
Apr 2, 2020
•
edited
edited
…reds were uploaded
docs/Command-line-client.md
Outdated
@@ -319,7 +319,9 @@ eg: `storm shell resources/ python topology.py arg1 arg2` | |||
|
|||
Syntax: `storm upload_credentials topology-name [credkey credvalue]*` | |||
|
|||
Uploads a new set of credentials to a running topology | |||
Uploads a new set of credentials to a running topology | |||
* `-e --exception`: optioanl flag. If set, command will fail and throw exception if no credentials were uploaded. |
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.
type "optioanl"
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.
Fixed
bin/storm.py
Outdated
# If set, this flag will become true meaning that user expects non-empty creds to be uploaded. | ||
# Command exits with non-zero code if uploaded creds collection is empty. | ||
sub_parser.add_argument( | ||
"-e", "--exception", action='store_true', |
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.
--exception
is too general. Maybe --fail-on-empty
or something
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 changed --exception-when-empty here since we already use short name -f
for file.
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.
This is also good
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.
Where is args.exception_when_empty passed to java command (in storm.py:upload_credentials()?
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.
.boolOpt("e", "exception-when-empty") |
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.
Seems there is a slight problem. In python code, when exec_java_class() is called, the arguments to the java class is constructed partly from main_class_args. main_class_args is constructed by simply eliminating some arguments passed to the python code (and keeping the rest intact). So if python code got passed "-e" ii will get passed thru to java class as "-e". However, if "--exception was passed to python, then --exception will get passed to java. This wont match what java class is expecting. So in order to do a passthru, the option names should be the same, otherwise main_class_args should be suitably modified based on the args. Looks like passthru might be preferred solution.
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.
Yea, the argument in python is the same: "--exception-when-empty".
@@ -126,7 +127,7 @@ public static void pushCredentials(String name, Map<String, Object> topoConf, Ma | |||
* @throws NotAliveException if the topology is not alive | |||
* @throws InvalidTopologyException if any other error happens | |||
*/ | |||
public static void pushCredentials(String name, Map<String, Object> topoConf, Map<String, String> credentials, String expectedUser) | |||
public static boolean pushCredentials(String name, Map<String, Object> topoConf, Map<String, String> credentials, String expectedUser) |
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.
missing javadoc @return
There is another pushCredentials
method in this class needs to be taken care of
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.
Fixed
@@ -111,7 +112,13 @@ public static void main(String[] args) throws Exception { | |||
// use the local setting for the login config rather than the topology's | |||
topologyConf.remove("java.security.auth.login.config"); | |||
|
|||
StormSubmitter.pushCredentials(topologyName, topologyConf, credentialsMap, (String) cl.get("u")); | |||
boolean throwExceptionForEmptyCreds = (boolean) cl.getOrDefault("e", false); |
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.
No need for default value here. above boolOpt
is already default to false
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.
Fixed
docs/Command-line-client.md
Outdated
@@ -319,7 +319,9 @@ eg: `storm shell resources/ python topology.py arg1 arg2` | |||
|
|||
Syntax: `storm upload_credentials topology-name [credkey credvalue]*` | |||
|
|||
Uploads a new set of credentials to a running topology | |||
Uploads a new set of credentials to a running topology | |||
* `-e --exception`: optional flag. If set, command will fail and throw exception if no credentials were uploaded. |
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.
This needs to be updated too
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.
Yes, fixed
bin/storm.py
Outdated
# Command exits with non-zero code if uploaded creds collection is empty. | ||
sub_parser.add_argument( | ||
"-e", "--exception-when-empty", action='store_true', | ||
help="""whether to throw exception if there are no credentials uploaded, default to be false""" |
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.
It means true when this config is specified, otherwise it's false.
So more precisely, "If specified, throws an exception if no credentials are uploaded"
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.
Fixed
@@ -106,27 +106,30 @@ public static boolean validateZKDigestPayload(String payload) { | |||
* @param name the name of the topology to push credentials to. | |||
* @param topoConf the topology-specific configuration, if desired. See {@link Config}. | |||
* @param credentials the credentials to push. | |||
* @return whether the pushed credential collection fullCreds is non-empty. Return false if empty. |
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.
fullCreds
doesn't really mean anything and can be deleted; image anyone changed the variable name
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.
Sure. Fixed
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.
only one Travis build failed. Should be irrelevant.
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.
+1