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

[Minor] Improve log messages #6531

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ protected List<RangerPolicy> wildcardSearchPolies(
try {
return rangerClient.findPolicies(searchFilters);
} catch (RangerServiceException e) {
throw new AuthorizationPluginException(e, "Failed to find the policies in the Ranger");
throw new AuthorizationPluginException(e, "Failed to find policies in Ranger");
}
}

Expand Down Expand Up @@ -278,10 +278,10 @@ private void removeSchemaMetadataObject(AuthorizationMetadataObject authzMetadat
authzMetadataObject instanceof PathBasedMetadataObject,
"The metadata object must be a PathBasedMetadataObject");
Preconditions.checkArgument(
authzMetadataObject.type() == SCHEMA, "The metadata object type must be SCHEMA");
authzMetadataObject.type() == SCHEMA, "The metadata object type must be a schema");
Preconditions.checkArgument(
authzMetadataObject.names().size() == 1,
"The size of the metadata object's name must be 1.");
"The size of the metadata object's size must be 1.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Check this again?

Copy link
Member Author

Choose a reason for hiding this comment

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

"name must be 1" makes no sense unless you mean the name must be the letter 1, which is not intended here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean "The size of the metadata object's size" doesn't make sense ... WDYT?

Copy link
Member Author

@justinmclean justinmclean Feb 27, 2025

Choose a reason for hiding this comment

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

it makes sense to me, and I don't think most people would find that confusing - as a Precondition, it's more aimed at developers.

if (RangerHelper.RESOURCE_ALL.equals(authzMetadataObject.name())) {
// Remove all schema in this catalog
String catalogName = authzMetadataObject.names().get(0);
Expand Down Expand Up @@ -361,9 +361,9 @@ private void removeTableMetadataObject(AuthorizationMetadataObject authzMetadata
authzMetadataObject instanceof PathBasedMetadataObject,
"The metadata object must be a PathBasedMetadataObject");
Preconditions.checkArgument(
authzMetadataObject.names().size() == 3, "The metadata object names must be 3");
authzMetadataObject.names().size() == 3, "The metadata object size must be 3");
Copy link
Contributor

Choose a reason for hiding this comment

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

Em ... What is "metadata object size"?

Copy link
Member Author

Choose a reason for hiding this comment

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

"Names must be 3" makes no sense, "size must be 3" does. This message is aimed at programmers, and they would understand that it needs to have 3 elements in it.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK.
Then how do I interpret "authzMetadataObject.names().size()" in plain English?

Copy link
Member Author

Choose a reason for hiding this comment

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

The size of the name or the metadata's object size or the metadata's name size, or if you really want to be verbose, the number of elements in the metadata's object's name.

Copy link
Contributor

Choose a reason for hiding this comment

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

Metadata object has a name identifier. The name identifier consists of names. This should be size of names instead of size of object.

Preconditions.checkArgument(
authzMetadataObject.type() == PATH, "The metadata object type must be PATH");
authzMetadataObject.type() == PATH, "The metadata object type must be a path");
removePolicyByMetadataObject(authzMetadataObject);
}

Expand Down Expand Up @@ -625,7 +625,7 @@ public Boolean onMetadataUpdated(MetadataObjectChange... changes) throws Runtime
((MetadataObjectChange.RenameMetadataObject) change).newMetadataObject();
Preconditions.checkArgument(
metadataObject.type() == newMetadataObject.type(),
"The old and new metadata object type must be equal!");
"The old and new metadata object types must be equal!");
if (metadataObject.type() == MetadataObject.Type.METALAKE) {
// Rename the metalake name
this.metalake = newMetadataObject.name();
Expand All @@ -641,13 +641,13 @@ public Boolean onMetadataUpdated(MetadataObjectChange... changes) throws Runtime
translateMetadataObject(newMetadataObject);
Preconditions.checkArgument(
oldAuthzMetadataObjects.size() == newAuthzMetadataObjects.size(),
"The old and new metadata objects size must be equal!");
"The old and new metadata objects sizes must be equal!");
for (int i = 0; i < oldAuthzMetadataObjects.size(); i++) {
AuthorizationMetadataObject oldAuthMetadataObject = oldAuthzMetadataObjects.get(i);
AuthorizationMetadataObject newAuthzMetadataObject = newAuthzMetadataObjects.get(i);
if (oldAuthMetadataObject.equals(newAuthzMetadataObject)) {
LOG.info(
"The metadata object({}) and new metadata object({}) are equal, so ignore rename!",
"The metadata object({}) and new metadata object({}) are equal, so ignoring rename!",
oldAuthMetadataObject.fullName(),
newAuthzMetadataObject.fullName());
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected List<RangerPolicy> wildcardSearchPolies(
try {
return rangerClient.findPolicies(searchFilters);
} catch (RangerServiceException e) {
throw new AuthorizationPluginException(e, "Failed to find the policies in the Ranger");
throw new AuthorizationPluginException(e, "Failed to find policies in Ranger");
}
}

Expand Down Expand Up @@ -226,7 +226,7 @@ protected void updatePolicyByMetadataObject(
AuthorizationSecurableObject.DOT_SPLITTER.splitToList(policyName));
Preconditions.checkArgument(
policyNames.size() >= oldAuthzMetaObject.names().size(),
String.format("The policy name(%s) is invalid!", policyName));
String.format("The policy name (%s) is invalid!", policyName));
if (policyNames.get(index).equals(RangerHelper.RESOURCE_ALL)) {
// Doesn't need to rename the policy `*`
return;
Expand All @@ -250,7 +250,7 @@ protected void updatePolicyByMetadataObject(
|| existNewPolicy.getResources().equals(policy.getResources()));
if (alreadyExist) {
LOG.warn(
"The Ranger policy for the metadata object({}) already exists!",
"The Ranger policy for the metadata object ({}) already exists!",
newAuthzMetaObject);
return;
}
Expand Down Expand Up @@ -292,9 +292,9 @@ protected void removeMetadataObject(AuthorizationMetadataObject authzMetadataObj
*/
private void doRemoveSchemaMetadataObject(AuthorizationMetadataObject authzMetadataObject) {
Preconditions.checkArgument(
authzMetadataObject.type() == SCHEMA, "The metadata object type must be SCHEMA");
authzMetadataObject.type() == SCHEMA, "The metadata object type must be a schema");
Preconditions.checkArgument(
authzMetadataObject.names().size() == 1, "The metadata object names must be 1");
authzMetadataObject.names().size() == 1, "The metadata object name size must be 1");
if (RangerHelper.RESOURCE_ALL.equals(authzMetadataObject.name())) {
// Delete metalake or catalog policies in this Ranger service
try {
Expand Down Expand Up @@ -697,16 +697,14 @@ public List<AuthorizationSecurableObject> translatePrivilege(SecurableObject sec
break;
default:
LOG.warn(
"RangerAuthorizationHivePlugin -> privilege {} is not supported for the securable object: {}",
gravitinoPrivilege.name(),
securableObject.type());
"The privilege %s is not supported for the securable object: %s",
gravitinoPrivilege.name(), securableObject.type());
}
break;
default:
LOG.warn(
"RangerAuthorizationHivePlugin -> privilege {} is not supported for the securable object: {}",
gravitinoPrivilege.name(),
securableObject.type());
"The privilege %s is not supported for the securable object: %s",
gravitinoPrivilege.name(), securableObject.type());
}
});

Expand All @@ -721,7 +719,7 @@ public List<AuthorizationSecurableObject> translatePrivilege(SecurableObject sec
public List<AuthorizationMetadataObject> translateMetadataObject(MetadataObject metadataObject) {
Preconditions.checkArgument(
!(metadataObject instanceof RangerPrivileges),
"The metadata object must be not a RangerPrivileges object.");
"The metadata object must not be a RangerPrivileges object.");
List<String> nsMetadataObject =
Lists.newArrayList(SecurableObjects.DOT_SPLITTER.splitToList(metadataObject.fullName()));
Preconditions.checkArgument(
Expand Down Expand Up @@ -757,7 +755,7 @@ public Boolean onMetadataUpdated(MetadataObjectChange... changes) throws Runtime
((MetadataObjectChange.RenameMetadataObject) change).newMetadataObject();
Preconditions.checkArgument(
metadataObject.type() == newMetadataObject.type(),
"The old and new metadata object type must be equal!");
"The old and new metadata object types must be equal!");
if (metadataObject.type() == MetadataObject.Type.METALAKE) {
// Rename the metalake name
this.metalake = newMetadataObject.name();
Expand All @@ -773,13 +771,13 @@ public Boolean onMetadataUpdated(MetadataObjectChange... changes) throws Runtime
translateMetadataObject(newMetadataObject);
Preconditions.checkArgument(
oldAuthzMetadataObjects.size() == newAuthzMetadataObjects.size(),
"The old and new metadata objects size must be equal!");
"The old and new metadata objects sizes must be equal!");
for (int i = 0; i < oldAuthzMetadataObjects.size(); i++) {
AuthorizationMetadataObject oldAuthMetadataObject = oldAuthzMetadataObjects.get(i);
AuthorizationMetadataObject newAuthzMetadataObject = newAuthzMetadataObjects.get(i);
if (oldAuthMetadataObject.equals(newAuthzMetadataObject)) {
LOG.info(
"The metadata object({}) and new metadata object({}) are equal, so ignore rename!",
"The metadata object({}) and new metadata object({}) are equal, so ignoring rename!",
oldAuthMetadataObject.fullName(),
newAuthzMetadataObject.fullName());
continue;
Expand Down