Skip to content
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

[FLINK-29761][runtime][security] Simplify HadoopModule #21160

Merged
merged 2 commits into from
Nov 7, 2022

Conversation

gaborgsomogyi
Copy link
Contributor

What is the purpose of the change

HadoopModule is quite complex and contains reflection which can be simplified. In this PR I've made this simplification keeping the original functionality.

The other important intention is that flink-runtime module has used several things from flink-hadoop-fs module which is just bad from architectural perspective. In this PR this I've eliminated this.

Brief change log

  • Used KerberosLoginProvider in HadoopModule

Verifying this change

  • Existing unit tests
  • Manually on YARN and K8S (please see an example here)

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

@flinkbot
Copy link
Collaborator

flinkbot commented Oct 26, 2022

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

&& !StringUtils.isBlank(securityConfig.getPrincipal())) {
String keytabPath = (new File(securityConfig.getKeytab())).getAbsolutePath();

UserGroupInformation.loginUserFromKeytab(securityConfig.getPrincipal(), keytabPath);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@steveloughran since you have quite some XP w/ UGI a quick question:
AFAIK UserGroupInformation.loginUserFromKeytab does the same just like

ugi = UserGroupInformation.loginUserFromKeytabAndReturnUGI
UserGroupInformation.setLoginUser(ugi);

right?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, plus sets up a renewer thread to do relogin on a regular basis.

Method loginUserFromSubjectMethod =
UserGroupInformation.class.getMethod(
"loginUserFromSubject", Subject.class);
loginUserFromSubjectMethod.invoke(null, (Subject) null);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@steveloughran here is another similar question:
AFAIK UserGroupInformation.loginUserFromSubject does the same just like

ugi = UserGroupInformation.getUGIFromTicketCache
UserGroupInformation.setLoginUser(ugi);

right?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh, its more complex than that. look at the source.

@gaborgsomogyi
Copy link
Contributor Author

@steveloughran So if I understand correctly it would be better to use the original UGI calls instead of the other APIs because:

  • The ticket cache part has major differences
  • The keytab part is not starting the renewer thread

Correct me if I'm wrong.

@gaborgsomogyi
Copy link
Contributor Author

Based on the fact that the UGI APIs are not doing the same things I've refactored the original PR and using the exact same API calls. Re-tested it manually and works fine.

@gaborgsomogyi
Copy link
Contributor Author

@flinkbot run azure

@gaborgsomogyi
Copy link
Contributor Author

@flinkbot run azure

@gaborgsomogyi gaborgsomogyi force-pushed the FLINK-29761 branch 2 times, most recently from 9429c05 to 2b4cae1 Compare November 1, 2022 11:52
@gaborgsomogyi
Copy link
Contributor Author

@flinkbot run azure

// UserGroupInformation.loginUserFromSubject(null);
Method loginUserFromSubjectMethod =
UserGroupInformation.class.getMethod(
"loginUserFromSubject", Subject.class);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to help reviewers this API has been added in Hadoop v2.3.0. Please see this.

@mbalassi mbalassi self-requested a review November 7, 2022 12:47
Copy link
Contributor

@mbalassi mbalassi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @gaborgsomogyi. Looks good, added a minor javadoc comment which I will squash into your commit on merge.

Merging later today EU time unless anyone has objections.

@mbalassi mbalassi merged commit 575517b into apache:master Nov 7, 2022
@gaborgsomogyi gaborgsomogyi deleted the FLINK-29761 branch September 13, 2023 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants