Skip to content

HDDS-12179. Improve Container Log to also capture the Volume Information #7858

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

Merged
merged 5 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -51,7 +51,7 @@ private ContainerLogger() { }
* @param containerData The container that was created and opened.
*/
public static void logOpen(ContainerData containerData) {
LOG.info(getMessage(containerData));
LOG.info(getMessage(containerData, "CommandType=CreateContainer"));
}

/**
Expand Down Expand Up @@ -80,7 +80,7 @@ public static void logQuasiClosed(ContainerData containerData,
* @param containerData The container that was closed.
*/
public static void logClosed(ContainerData containerData) {
LOG.info(getMessage(containerData));
LOG.info(getMessage(containerData, "CommandType=CloseContainer"));
}

/**
Expand Down Expand Up @@ -116,9 +116,9 @@ public static void logLost(ContainerData containerData, String message) {
*/
public static void logDeleted(ContainerData containerData, boolean force) {
if (force) {
LOG.info(getMessage(containerData, "Container force deleted"));
LOG.info(getMessage(containerData, "Container force deleted, CommandType=DeleteContainer"));
} else {
LOG.info(getMessage(containerData, "Empty container deleted"));
LOG.info(getMessage(containerData, "Empty container deleted, CommandType=DeleteContainer"));
}
}

Expand Down Expand Up @@ -146,7 +146,7 @@ public static void logExported(ContainerData containerData) {
* @param containerData The container that was recovered on this datanode.
*/
public static void logRecovered(ContainerData containerData) {
LOG.info(getMessage(containerData));
LOG.info(getMessage(containerData, "action=Recovered"));
}

private static String getMessage(ContainerData containerData,
Expand All @@ -159,6 +159,7 @@ private static String getMessage(ContainerData containerData) {
"ID=" + containerData.getContainerID(),
"Index=" + containerData.getReplicaIndex(),
"BCSID=" + containerData.getBlockCommitSequenceId(),
"State=" + containerData.getState());
"State=" + containerData.getState(),
"Volume=" + containerData.getVolume());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@
import org.apache.hadoop.ozone.container.common.interfaces.Container;
import org.apache.hadoop.ozone.container.common.report.IncrementalReportSender;
import org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine;
import org.apache.hadoop.ozone.container.common.utils.ContainerLogger;
import org.apache.hadoop.ozone.container.common.volume.HddsVolume;
import org.apache.hadoop.ozone.container.common.volume.MutableVolumeSet;
import org.apache.ozone.test.GenericTestUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import static org.assertj.core.api.Assertions.assertThat;

/**
* Test that KeyValueHandler fails certain operations when the
Expand All @@ -71,6 +74,8 @@ public class TestKeyValueHandlerWithUnhealthyContainer {
private File tempDir;

private IncrementalReportSender<Container> mockIcrSender;
private final GenericTestUtils.LogCapturer logCapturer =
GenericTestUtils.LogCapturer.log4j2(ContainerLogger.LOG_NAME);

@BeforeEach
public void init() {
Expand Down Expand Up @@ -232,6 +237,7 @@ public void testMarkContainerUnhealthyInFailedVolume() throws IOException {
handler.markContainerUnhealthy(container,
ContainerTestUtils.getUnhealthyScanResult());
verify(mockIcrSender, atMostOnce()).send(any());
assertThat(logCapturer.getOutput()).contains("CORRUPT_CHUNK");
}

// -- Helper methods below.
Expand Down