Skip to content

WIP: Property Validation handling on backend #3173

Closed
ddanielr wants to merge 5 commits into
apache:2.1from
ddanielr:feature/thrift-woes
Closed

WIP: Property Validation handling on backend #3173
ddanielr wants to merge 5 commits into
apache:2.1from
ddanielr:feature/thrift-woes

Conversation

@ddanielr

Copy link
Copy Markdown
Contributor

I'm looking for feedback on direction of thrift error handling.
I'm not seeing the errors I'm expecting, so I'm attempting to figure out what disconnect I still have

My expectation is that I would have ThriftPropertyExceptions returned for any accumulo shell config command that sets an invalid property.

However, I'm only getting exceptions back for setting properties on tables and namespaces.

If I set a direct property without specifying a table or namespace, no exception is raised

Invalid Table Property Example:

root@uno test> config -s table.walog.enabled=foo -t test
2023-01-25T18:38:29,837 [shell.Shell] ERROR: org.apache.accumulo.core.client.AccumuloException: ThriftPropertyException(property:table.walog.enabled, value:foo, description:Invalid property for : TablePropKey{TableId=1'} name: table.walog.enabled, value: foo)

Invalid Namespace Property Example:

test> config -s table.walog.enabled=foo -ns testns
2023-01-25T18:40:50,534 [shell.Shell] ERROR: org.apache.accumulo.core.client.AccumuloException: ThriftPropertyException(property:table.walog.enabled, value:foo, description:Invalid property for : NamespacePropKey{NamespaceId=2'} name: table.walog.enabled, value: foo)

Refactored the isTablePropertyValid method to be mroe generic for other usecases.
Added 'throws' back to method signatures in partial attempt to improve error visibilites.
Attempt at raising exceptions via thrift for invalid properties.
2:SecurityErrorCode code
}

exception ThriftPropertyException {

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.

No need to put this exception in the client thrift IDL file. You can just put it in the manager.thrift file unless you need to import it into other IDL files.

} catch (Exception e) {
Manager.log.error("Problem setting config property in zookeeper", e);
throw new TException(e.getMessage());
throw new ThriftPropertyException(property, value, e.getMessage());

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.

Do you want this above where IllegalArgumentException is caught?

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.

Yes, I moved up my Thrift property Exception to handle the caught iae

Comment on lines +1705 to +1712
* valid see {@link #isValidPropertyKey} and that the value is a valid format for the type see
* {@link PropertyType#isValidFormat}.
*
* @param key property key
* @param value property value
* @return true if key is valid (recognized, or has a recognized prefix)
*/
public static boolean isTablePropertyValid(final String key, final String value) {
public static boolean isValidProperty(final String key, final String value) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I haven't done a full review of this PR, but it seems weird that this method would have had the name "Table" in it if it weren't specifically constraining the validity check to properties that can be set scoped to a table (or namespace). We should be careful about changing this name, and its current behavior that constrains validity to properties whose keys are appropriate for a table (or namespace). There's a good chance that this method is expected to enforce that constraint, and now it no longer does.

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.

I agree that the previous method was constrained to only checking table validity.

It was accomplishing this by checking if the property was valid and then also doing a call to isValidTablePropertyKey to determine if the property key itself was valid for tables.

However, since isValidTablePropertyKey is public, I refactored all usages of isTablePropertyValid with two separate method calls to isValidProperty and isValidTablePropertyKey.

I did this because I wanted to try and streamline the Property.java class.

This class had this method (isTablePropertyValid) along with isValidTablePropertyKey and isValidBooleanPropertyKey.

If we followed this pattern, we would end up with a validity check for each property type [PropertyType.java
as well as validity checks for table, namespace, and system key types.

The end state would be a cluttered class with a lot of different isValid<X> methods that has the potential to be confusing.
I chose to streamline down to a single isValid method and enforce the context check of "table" in the usage location.

However, if those extra methods are the desired goal then I can pivot and create a new generic isValidProperty method while leaving isTablePropertyValid intact?

Validate System properties as well as checking if property is mutable in zookeeper.
Added formatting change
Adds tests for setting invalid namespace and table properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants