Validate Property Values#3177
Conversation
Refactor the `isTablePropertyValid` method to be more generic. This change moves the `isValidTablePropertyKey` method calls out from the `isTablePropertyValid` method and to the calling locations. This allows for the `isTablePropertyValid` method to be renamed to `isValidProperty`. Moving that method allowed for error messages to accurately discribe an invalid table property error and an invalid value error. Added 'throws' to method signatures in partial attempt to improve error visibilites.
Adds new `ThriftPropertyException` to allow for the `IllegalArgumentException` runtime expection to be caught and displayed to the client. Raise exceptions for setting invalid properties at the system, namespace, and table level.
Validate System properties as well as check if property is mutable in zookeeper.
Add tests for setting invalid system, namespace, and table properties. Change the error messages to be more uniform for test validation.
| break; | ||
| case CLASSNAME: | ||
| Shell.log.debug("CLASSNAME properties currently fail this test"); | ||
| Shell.log.debug("Regex used for CLASSNAME property types may need to be modified"); |
There was a problem hiding this comment.
Should we fix the regex as part of this PR?
There was a problem hiding this comment.
Currently, all of these changes don't alter property structure, they just enforce the previously defined types.
Modifying a property regex has the potential to break legitimate uses.
So, I'd rather open an issue for the regex fix and track that as a separate action.
|
Kicked off full IT build |
|
Full IT build succeeded. |
Change the `tableName` variable to use `getUniqueNames()` for uniformity.
EdColeman
left a comment
There was a problem hiding this comment.
Looks good - just some minor suggestions.
Remove unnecessary `toString()` calls on `propertyType`.
Add a property validation test in the `PropertyTest` class. This new test replaces the boolean-only validation test.
EdColeman
left a comment
There was a problem hiding this comment.
LGTM - maybe as a follow-on the tests in PropertyTest could be expanded to test variations of valid values. The boolean test that was modified was testing combinations of true, True, false, False, my initial though that it was unnecessary to loop through all of the properties, not the condition.
The testPropertyValidation test is a nice addition to check that each type will fail validation.
While the is a specific host:port test in PropertyTest, it may be an improvement if tests were included for things like 100M, 100m, 100G, 100g for memory, (or whatever is valid) for each of the expected types (assuming that they are not tested elsewhere)
EdColeman
left a comment
There was a problem hiding this comment.
Noticed that the check failed with a junit package issue:
Expected 0, but found 1 classes using the wrong JUnit APIs:
core/src/test/java/org/apache/accumulo/core/clientImpl/TabletLocatorImplTest.java
Error: Process completed with exit code 1.
Not sure where that is coming from, but it should be corrected before merging
|
The offending import in TabletLocatorImplTest is Also, there may be other checkstyle issues that need to be addressed: |
|
@EdColeman those changes weren't introduced in this PR. I think the latest merge to 2.1 caused the problem |
|
I have a PR incoming to fix 2.1 |
|
Should be fixed when #3179 is merged |
|
@EdColeman I merged in the latest changes from 2.1 and all tests are now passing. |
Switch the logger from "debug" to "error" in SystemPropUtil Use test namespace instead of creating a new one in NamespacesIT Add a logger and remove `System.out.print` statements in PropertyTest.
| IllegalArgumentException iae = | ||
| new IllegalArgumentException("Zookeeper property is not mutable: " + property); | ||
| log.debug("Attempted to set zookeeper property. It is not mutable", iae); | ||
| log.error("Encountered error setting zookeeper property", iae); |
There was a problem hiding this comment.
Did you happen to look at the exceptions as printed in the logs? It seems likely that the method that catches the exception will also printout the stack trace. If there was additional info to help development, maybe a trace statement? Otherwise the logs may end up with two identical stack traces without adding additional information.
Also, error seems rather aggressive, services are going to keep running,
If this code get reworked, it may be worth considering.
(I realize this has been merged, it was changed, committed before I got back to it. Just wanted to mention it if it helps going forward)
There was a problem hiding this comment.
@EdColeman confirmed that the calling method does in fact log the exceptions at the error level.
I've opened #3184 to revert this change.
Closes #3145
These changes add the ability to validate system, namespace, and table-specific properties for accumulo.
Values are now being validated on the backend and client validation exceptions show as a
ThriftPropertyExceptionexception type.See #3173 for WIP feedback if desired.