-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HADOOP-13817. Add a finite shell command timeout to ShellBasedUnixGroupsMapping. #161
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
QwertyManiac
commented
Nov 14, 2016
- Tests required log capture so the LOG variable was elevated in visibility, which required changes in a few test methods unrelated to just this change.
- Timeout is applied to both, the regular groups and the partial group listing check commands.
- Default is left to 0 to not break current behaviour (i.e. to wait forever until groups are resolvable).
@Override | ||
public void setConf(Configuration conf) { | ||
super.setConf(conf); | ||
timeout = conf.getLong( |
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.
Can we use Configuration#getTimeDuration() instead of Configuration#getLong to make the newly added configuration key easier to use?
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.
Done in added commit.
} catch (PartialGroupNameException pge) { | ||
LOG.warn("unable to return groups for user " + user, pge); | ||
LOG.warn("unable to return groups for user {}", user, pge); | ||
return new LinkedList<>(); |
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.
Can we use flyweight pattern to minimize memory usage for the empty LinkList?
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.
Done in added commit.
Arrays.asList(executor.getExecString()), | ||
timeout | ||
); | ||
return new LinkedList<>(); |
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.
flyweight pattern applies here as well.
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.
Done in added commit.
- Shared the empty group list return objects - Switched to use of getTimeDuration for the introduced config - Changed the property name to reflect seconds (and removed a redundant word
public static final String HADOOP_SECURITY_GROUP_SHELL_COMMAND_TIMEOUT = | ||
"hadoop.security.groups.shell.groups.command.timeout"; | ||
public static final String HADOOP_SECURITY_GROUP_SHELL_COMMAND_TIMEOUT_SECS = | ||
"hadoop.security.groups.shell.command.timeout.secs"; |
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 think we should keep "hadoop.security.groups.shell.groups.command.timeout". Sorry I was not clear about this when suggesting Configuration#getTimeDuration. It allows admin to specify the time values with suffix like 10s, 1m, 2h. So the ."secs" won't be needed here.
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'd just felt it would be clearer to have '.secs' in it indicating the minimum unit type despite the parser. I've removed that in the latest commit and added some examples into its doc-text in the xml.
LoggerFactory.getLogger(ShellBasedUnixGroupsMapping.class); | ||
|
||
private long timeout = 0L; | ||
private final List<String> emptyGroupsList = new LinkedList<>(); |
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 can be static.
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.
Done in the latest commit.
- Removed 'secs' in config name and clarified examples in its docs - Made empty groups list static - Added a null guard in setConf for constructors that do not use ReflectionUtils to pass a valid config
ShellBasedUnixGroupsMapping.LOG); | ||
|
||
private static final boolean WINDOWS = | ||
(Shell.osType == Shell.OSType.OS_TYPE_WIN); |
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 think you can just use Shell.WINDOWS instead.
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.
Thank you, addressed in new commit.
message += | ||
" because of the command taking longer than " + | ||
"the configured timeout: " + timeout + " seconds"; | ||
throw new PartialGroupNameException(message); |
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.
Maybe this line is not needed if it will throw the exception anyway? The only difference is that it will not carry the original exception
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.
Thanks, addressed in new commit. I just felt the timeout exception may look weird, but I've dropped the line so we can be consistent in exposing the exception at all times.
- Also did a few small cleanups - Exposed the under-timeout stream error as a debug log, just in case its useful. Earlier change just hid it permanently
"command '{}' ran longer than the configured timeout limit of " + | ||
"{} seconds.", | ||
user, | ||
Arrays.asList(executor.getExecString()), |
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.
Reviewed the patch again, and I think it's almost ready.
Here's one nit regarding the warning message here: it would print something like "Unable to return groups for user 'foobarnonexistinguser' as shell group lookup command '[sleep, 2]'". But this can be confusing as the command is not run with brackets and comas.
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 am +1 pending this and Jenkins precommit build. Somehow Jenkins is never run for your patches.
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.
Thank you again @jojochuang. I've added a new change here addressing your comments. I've also uploaded the full patch directly to JIRA to trigger a build test.
- Instead of printing the command list form, print a readable form - Uses Guava's Joiner over Java 8's native StringJoiner to ensure compat. with branch-2
Done via e8694de. |
…ith a ProcessorIdGenerator Minor fix. Unit tests were updated and passed. Author: Sean McCauliff <[email protected]> Reviewers: Navina Ramesh <[email protected]> Closes apache#161 from smccauliff/samza-1259