Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -174,6 +174,7 @@ private boolean canIgnoreException(Result result) {
case CLOSED_CONTAINER_IO:
case DELETE_ON_OPEN_CONTAINER:
case UNSUPPORTED_REQUEST:// Blame client for sending unsupported request.
case MALFORMED_REQUEST:// Blame client for sending malformed request.
case CONTAINER_MISSING:
case CONTAINER_ALREADY_EXISTS:
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import static org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.Result.INVALID_ARGUMENT;
import static org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.Result.INVALID_CONTAINER_STATE;
import static org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.Result.IO_EXCEPTION;
import static org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.Result.MALFORMED_REQUEST;
import static org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.Result.PUT_SMALL_FILE_ERROR;
import static org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.Result.UNCLOSED_CONTAINER_IO;
import static org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.Result.UNSUPPORTED_REQUEST;
Expand Down Expand Up @@ -123,6 +124,7 @@
import org.apache.hadoop.hdds.upgrade.HDDSLayoutFeature;
import org.apache.hadoop.hdds.utils.FaultInjector;
import org.apache.hadoop.hdds.utils.HddsServerUtil;
import org.apache.hadoop.hdds.utils.db.CodecException;
import org.apache.hadoop.hdds.utils.io.RandomAccessFileChannel;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConsts;
Expand Down Expand Up @@ -685,6 +687,10 @@ ContainerCommandResponseProto handlePutBlock(
metrics.incContainerBytesStats(Type.PutBlock, numBytes);
} catch (StorageContainerException ex) {
return ContainerUtils.logAndReturnError(LOG, ex, request);
} catch (CodecException ex) {
return ContainerUtils.logAndReturnError(LOG,
new StorageContainerException("Malformed PutBlock request", ex,
MALFORMED_REQUEST), request);
} catch (IOException ex) {
return ContainerUtils.logAndReturnError(LOG,
new StorageContainerException("Put Key failed", ex, IO_EXCEPTION),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,48 @@ public void testCreateContainerWhenAlreadyExistsDoesNotMarkUnhealthy() throws IO
}
}

@Test
public void testMalformedPutBlockDoesNotMarkContainerUnhealthy() throws IOException {
String testDirPath = testDir.getPath();
try {
UUID scmId = UUID.randomUUID();
OzoneConfiguration conf = new OzoneConfiguration();
conf.set(HDDS_DATANODE_DIR_KEY, testDirPath);
conf.set(OzoneConfigKeys.OZONE_METADATA_DIRS, testDirPath);
DatanodeDetails dd = randomDatanodeDetails();
HddsDispatcher hddsDispatcher = createDispatcher(dd, scmId, conf);

ContainerCommandRequestProto writeChunkRequest =
getWriteChunkRequest(dd.getUuidString(), 1L, 1L);
ContainerCommandResponseProto writeChunkResponse =
hddsDispatcher.dispatch(writeChunkRequest, null);
assertEquals(ContainerProtos.Result.SUCCESS, writeChunkResponse.getResult());

ContainerCommandRequestProto putBlockRequest =
ContainerTestHelper.getPutBlockRequest(writeChunkRequest);
ContainerProtos.BlockData malformedBlockData =
putBlockRequest.getPutBlock().getBlockData().toBuilder()
.setSize(putBlockRequest.getPutBlock().getBlockData().getSize() + 1)
.build();
ContainerCommandRequestProto malformedPutBlockRequest =
putBlockRequest.toBuilder()
.setPutBlock(putBlockRequest.getPutBlock().toBuilder()
.setBlockData(malformedBlockData))
.build();

ContainerCommandResponseProto response =
hddsDispatcher.dispatch(malformedPutBlockRequest, null);
assertEquals(ContainerProtos.Result.MALFORMED_REQUEST, response.getResult());

Container container = hddsDispatcher.getContainer(1L);
assertNotNull(container);
assertTrue(container.getContainerData().isOpen());
assertFalse(container.getContainerData().isUnhealthy());
} finally {
ContainerMetrics.remove();
}
}

@Test
public void testDuplicateWriteChunkAndPutBlockRequest() throws IOException {
String testDirPath = testDir.getPath();
Expand Down
Loading