HDDS-16084. Add ErrorProne to Ozone CI - #11056
Conversation
| omKeyLocationInfoGroup.getLocationList() | ||
| .stream().map(omKeyLocationInfo -> pipelines.add( | ||
| omKeyLocationInfo.getPipeline()))); | ||
| omKeyInfo.getKeyLocationVersions().forEach(omKeyLocationInfoGroup -> |
There was a problem hiding this comment.
Not a test-lint fix — getPipelines() returned empty before (the old stream().map(...add...) was never consumed), so this actually changes what Recon reports. Please add a test for a non-empty pipeline list and call the behavior fix out in the description instead of under "Fix tests".
There was a problem hiding this comment.
Thanks for the review, added a test for this.
There was a problem hiding this comment.
Added the non-empty pipeline regression test and updated the PR description under “Behavior fixes included” to explicitly call out the changed /api/v1/containers payload.
| if (resp.getStatus() != OK) { | ||
| throw new OMException(resp.getMessage(), | ||
| ResultCodes.values()[resp.getStatus().ordinal()]); | ||
| ResultCodes.valueOf(resp.getStatus().name())); |
There was a problem hiding this comment.
valueOf(name()) is the right pattern, but this changes error-code translation for any status where the Status and ResultCodes ordinals differ. Is this an intended behavior fix? If so, a small test (a status past the first divergence) + a note in the description would help.
There was a problem hiding this comment.
error-code translation for any status where the Status and ResultCodes ordinals differ
I'm not sure I follow this, this patch does not use Status ordinal.
There was a problem hiding this comment.
Verified this is behavior-preserving for the current enums: TestResultCodes asserts equal sizes, name parity, and valueOf(name()) conversion for every value. I also clarified the removal of ordinal coupling in the PR description.
|
@ivandika3 thanks for the patch! |
smengcl
left a comment
There was a problem hiding this comment.
Thanks @ivandika3 for the addition.
Co-authored-by: Siyao Meng <50227127+smengcl@users.noreply.github.com>
# Conflicts: # hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneClientRetriesOnExceptions.java # hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/ReconContainerMetadataManagerImpl.java
# Conflicts: # hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneClientRetriesOnExceptions.java # hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/TestOMClientRequestWithUserInfo.java
peterxcli
left a comment
There was a problem hiding this comment.
Nice work — adding Error Prone is clearly worth it, and the ERROR-level fixes catch several genuine bugs (CompactionDag, ReconContainerMetadataManagerImpl, the dropped includeNonStandardContainers row in ContainerBalancerConfiguration.toString(), and a good number of no-op assertions).
I went through the whole diff. Things I verified and am happy with:
- The
-Perrorproneprofile really does apply todefault-compileas well asdefault-testCompile— I ranmvn -Perrorprone -X -pl hadoop-hdds/config -am test-compilelocally and confirmedcombine.children="append"merges the Error Prone args with the existing-AartifactId=${project.artifactId}arg rather than replacing it. Error Prone diagnostics are emitted for both main and test sources. SCMException.ResultCodesandOMException.ResultCodes: thevalues()[ordinal()]->valueOf(name())conversions are safe, becauseTestSCMExceptionResultCodesandTestResultCodesboth assert equal enum length and exact name equality.SCMSecretKeyException.ErrorCodealso matches the proto exactly. On yourProtocolBufferOrdinalnote in the description — agreed, those three are fine; the fourth one is the odd one out (inline comment below).SCM_ROOT_CA_PREFIXisSCM_ROOT_CA + "@"with no format specifier, so droppingString.format(...)is a no-op and now matchesHASecurityUtils#initializeSecurity(SCM_ROOT_CA_PREFIX + hostname).OmRangerSyncArgs.newServiceVersionis a primitivelong, so the removedObjects.requireNonNullcould never fire.DelegatingProperties#contains->containsValue:Hashtable#containsalready has value semantics, so this is behaviour-preserving and just removes the confusion.BucketEndpoint/VolumeEndpoint: both keep the@Injectconstructor that assigns the field, so removing the redundant field annotation is safe.ContainerBalancerConfiguration#toString: I counted — 17%-50s %X%nrows = 34 conversions against 34 arguments after the patch. Correct.TestECBlockInputStream:5000 * ONEMBoverflowedintto ~904 MB;5000Lrestores the intended "very large block", andhasSufficientLocations()still holds.TestReconContainerManager:State.{UNHEALTHY,INVALID,DELETED}.getNumber()= 5/6/7 vs ordinals 4/5/6, so the container IDs shift to 125/126/127 — no collision with the other IDs used in that class.- The
errorpronecheck is wired correctly (#checks:basicmarker,check_needs_batspicks up.bats$), and the check took ~10.5 min in your run, comfortably inside the 30-minute job timeout.
Seven things I'd like your thoughts on, left as inline comments. Only the first is something I'd consider blocking; the rest are follow-ups or nits.
errorprone.shbypasses_post_process.sh, so a Maven failure that isn't an Error Prone ERROR reportsfailures=0with a misleading summary.- The
CompactionDagprune fix is a real behaviour change with no regression test. SCMSecurityProtocolProtos.Status->SCMSecurityException.ErrorCodeis the one name mapping with no parity test, and it already has a name with no counterpart.TestHSyncnow assertshasSize()on a table scanned across the whole shared MiniOzoneCluster.- The
ReconContainerMetadataManagerImplfix changes a public Recon REST payload — worth a release note. TestRocksDiffUtilsdrops a map entry rather than de-duplicating it.- Two
@SuppressWarningswithout a justification comment.
On your merge-order note: agreed, this will need master merged into in-flight PRs, and it might be worth landing the CI plumbing and the ERROR fixes as separate commits on master so a revert of one doesn't drag the other along.
peterxcli
left a comment
There was a problem hiding this comment.
@ivandika3 Thanks for the update, other LGTM.
| ReconOMMetadataManager omMetadataManager = mock(ReconOMMetadataManager.class); | ||
| Table<String, OmKeyInfo> keyTable = mock(Table.class); | ||
| when(omMetadataManager.getKeyTable(BucketLayout.LEGACY)).thenReturn(keyTable); | ||
| when(keyTable.getSkipCache(key1)).thenReturn(new OmKeyInfo.Builder() |
There was a problem hiding this comment.
getSkipCache() reads persisted OM rows, whose OmKeyInfo codec omits pipeline data via getProtobuf(true, ...). This mock bypasses that codec, so current OM rows still produce an empty pipeline list. Please test through the real table and source the pipeline from data that is actually retained.
There was a problem hiding this comment.
Good catch. The mocked getSkipCache() bypassed OM metadata serialization. Persisted OmKeyInfo omits pipeline information, so a real table cannot supply pipelines on this path. I reverted the pipeline population change and its mock-only test rather than asserting behavior that does not exist in production.
| DIAGNOSTIC_FILE="$REPORT_DIR/diagnostics.txt" | ||
| OUTPUT_LOG=$(mktemp) | ||
|
|
||
| MAVEN_OPTIONS='-B -fae --no-transfer-progress -Perrorprone -DskipDocs -DskipRecon -DskipShade' |
There was a problem hiding this comment.
Please cover ozonefs-hadoop2 and ozonefs-hadoop3: -DskipShade removes both from this reactor, so this check still passes with an Error Prone ERROR in those sources. Hadoop2 copied sources also match the global -XepExcludedPaths exclusion.
There was a problem hiding this comment.
Addressed. The check no longer sets -DskipShade, so the build-with-ozonefs profile includes both OzoneFS compatibility modules. The excluded-path regex now keeps ozonefs-hadoop2/target/generated-sources/java in scope while continuing to exclude other generated sources.
| - bats: [Checks](../hadoop-ozone/dev-support/checks/bats.sh) bash scripts, (using the [Bash Automated Testing System](https://github.com/bats-core/bats-core#bats-core-bash-automated-testing-system-2018)) | ||
| - checkstyle: [Runs](../hadoop-ozone/dev-support/checks/checkstyle.sh) 'mvn checkstyle' plugin to confirm Java source abides by Ozone coding conventions | ||
| - docs: [Builds](../hadoop-ozone/dev-support/checks/docs.sh) website with [Hugo](https://gohugo.io/) | ||
| - errorprone: [Runs](../hadoop-ozone/dev-support/checks/errorprone.sh) Error Prone static analysis during Java compilation. The check reports all warning and error diagnostics in `summary.txt` and fails for errors. |
There was a problem hiding this comment.
nit: please update this to match errorprone.sh: all diagnostics go to diagnostics.txt, while summary.txt contains only ERROR/fallback.
What changes were proposed in this pull request?
ErrorProne is a well-known static analysis tool used in other ASF projects such as Celeborn, Druid, HBase, Solr, and Beam to catch common Java coding errors. It is lightweight compared with fbinfer (HDDS-15560).
This patch adds an ErrorProne CI check that fails when it finds any ERROR-severity bug patterns (https://errorprone.info/bugpatterns). All ErrorProne diagnostics are retained in
diagnostics.txt;summary.txtcontains only ERROR diagnostics or an explicit fallback for a non-diagnostic Maven failure, which is what the CI summary presents.This patch also fixes all current ERROR-severity bug patterns in Ozone. The fixes are split into multiple commits. I have attached errorprone-error-fixes.md for the bug patterns and the possible risks. This caught real defects in
CompactionDagand no-op assertions.Behavior fixes included
CompactionDagpruning now removes pruned SST entries fromcompactionNodeMap; previouslyMap#removereceived a node instead of its file-name key and therefore did nothing.valueOf(name())conversions remove ordinal coupling. They are behavior-preserving for the currently matching protocol/error-code names; parity tests guard future enum additions, with the SCM security protocol’s two explicit historical exceptions covered separately.WARNING diagnostics are intentionally not fixed in this patch; they can be handled by follow-up work. The ErrorProne
ThreadSafeannotation is also deferred so it can be coordinated with fbinfer HDDS-15560.Note for reviewer:
ProtobufBufferOrdinalrule (https://errorprone.info/bugpattern/ProtocolBufferOrdinal), but the currentResultCodes.valueOf(protoStatus.name())mapping is covered by enum name-parity tests.Generated by: GPT 5.6 Sol
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-16084
How was this patch tested?
CI (Clean CI: https://github.com/ivandika3/ozone/actions/runs/32216855338).