Skip to content

HIVE-28716: Add owner information in HivePrivilegeObject for create database query - #5616

Merged
okumin merged 2 commits into
apache:masterfrom
Aggarwal-Raghav:HIVE-28716
Jan 28, 2025
Merged

HIVE-28716: Add owner information in HivePrivilegeObject for create database query#5616
okumin merged 2 commits into
apache:masterfrom
Aggarwal-Raghav:HIVE-28716

Conversation

@Aggarwal-Raghav

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Refer to HIVE-28716 and RANGER-5097 for the info

Why are the changes needed?

Currently we are not passing the owner information for database in HivePrivilegeObject. This object is passed to ranger and ranger is using this owner information but as it is missing, NoSuchObjectException is thrown HS2 logs. Check the above mentioned JIRA for stacktrace and debugging screenshot.

NOTE: There is no impact on the functionality, table/db is getting created in hive. It more of a noise in the HS2 logs coming from ranger.

Does this PR introduce any user-facing change?

No

Is the change a dependency upgrade?

No

How was this patch tested?

On Cluster testing and monitoring HS2 logs

if (managedLocationUri != null) {
database.setManagedLocationUri(managedLocationUri);
}
database.setOwnerName(SessionState.getUserFromAuthenticator());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CreateDatabaseOperation sets the ownername both for native and remote db type. I wonder, should we follow the same pattern?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review @InvisibleProgrammer, actually I was under some other assumption.

I will address this.

…atabase query

Check RANGER-5097 for more info
database.setType(DatabaseType.REMOTE);
database.setRemote_dbname(remoteDbName);
}
database.setOwnerName(SessionState.getUserFromAuthenticator());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it be better or more consistent if we set the owner type? I could be wrong

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @okumin, for the review and a vaild question but I think there is no need to set owner type. My reasoning is, why set additional info which is not getting utilized by Ranger and post authorization the code flow will enter the CreateDatabaseOperation and there ownerType and other attributes of class will be set. We only need owner name info as it is used by ranger, it doesn't require owner type. In future if Ranger requires ownerType info then we can address it separately.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks. Your statement makes sense. Let me make the last challenge.
We currently encounter the problem of Apache Ranger, and this minimal fix surely resolves the problem. I agree that this fact supports your opinion.
I'd like to add two perspectives here. First, I think adding owner information is theoretically not only for Ranger, i.e., another authorization system or another plugin such as HiveSemanticAnalyzerHook can use the information. Second, the context would be more explicit and less confusing with a principal type as users don't have to worry that the name is linked to a role or group. Because of the two reasons, I am guessing aligning this with CreateDatabaseOperation is not a bad investment.
At least, this change will likely work and resolve the problem. So, I don't have any strong objections to have this merged. Just I want to make a decision once I get your response as you are more knowledgeable with this part 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure @okumin, the first point makes sense if other authorizer or in future ranger starts using it. I will update the PR by adding database.setOwnerType(PrincipalType.USER);

My understanding is when we do kinit ntid/serviceId@Realm , even serviceId is considered as user. So setting PrincipalType.USER from hive should be ok!

@sonarqubecloud

Copy link
Copy Markdown

@okumin okumin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1. I'm waiting for CI and 24 hours

@okumin
okumin merged commit 544c8b3 into apache:master Jan 28, 2025
henrib pushed a commit to henrib/hive that referenced this pull request Jan 31, 2025
…atabase query (apache#5616) (Raghav Aggarwal reviewed by Zsolt Miskolczi, Shohei Okumiya)
@Aggarwal-Raghav
Aggarwal-Raghav deleted the HIVE-28716 branch October 2, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants