ArafatKhan2198 opened a new pull request, #12201: URL: https://github.com/apache/ozone/pull/12201
## What changes were proposed in this pull request? This was created from the discussion in https://github.com/apache/ozone/pull/12096#issuecomment-7202152118. That PR (HDDS-17061) closed one way a container could disappear from Recon while a leftover unhealthy row still pointed to it. The remaining case was filed as this issue. **What was going wrong** `GET /api/v1/containers/unhealthy` (and `/unhealthy/{state}`) reads rows from the `UNHEALTHY_CONTAINERS` table. For each row it looks up the container in Recon. If Recon no longer has that container, the lookup throws `ContainerNotFoundException` and the whole page returns HTTP 500. One bad row hides every other unhealthy container on the page, and the row never goes away by itself. A row can end up pointing to a missing container like this: 1. A container is MISSING, so Recon stores a MISSING row for it. 2. An admin removes it from SCM with `ozone admin container delete`. 3. Recon replaces its SCM DB with an SCM snapshot (at startup when the container counts drift past the threshold, or when a snapshot sync runs). The container is gone from Recon, but `UNHEALTHY_CONTAINERS` is not cleared. 4. Later health checks only delete rows of containers Recon still has, so the row stays. 5. Every page that includes the row returns 500. The deprecated `GET /api/v1/containers/missing` has the same lookup and fails the same way. **What happens now** - If a row's container is not in Recon, Recon logs a warning and skips that row. The page returns the other unhealthy containers with HTTP 200. Other I/O errors still return 500 as before. - `firstKey` and `lastKey` are taken from the rows read from the table, not only the rows returned. A page whose last row was skipped still reports that row's id as `lastKey`, so a client that pages with `minContainerId=lastKey` moves past it instead of stopping early. - `/containers/missing` skips such rows the same way. ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-17944 ## How was this patch tested? - New `TestContainerEndpoint#testUnhealthyContainersSkipsRowOfContainerNotInRecon`. It adds MISSING rows for container 1 (in Recon) and container 100000 (not in Recon). The full list returns only container 1, with `firstKey` 1 and `lastKey` 100000. A MISSING page with `limit=1` after container 1 is empty and reports `lastKey` 100000. Without the fix it fails with HTTP 500. - New `TestContainerEndpoint#testGetMissingContainersSkipsRowOfContainerNotInRecon` covers the same case for `/containers/missing`. - `mvn -pl :ozone-recon test -Dtest=TestContainerEndpoint -DskipShade -DskipRecon` passes (34 tests, 0 failures). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
