Skip to content
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

feat: remove orphan objects if copy fails at any point #531

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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 @@ -57,7 +57,6 @@
import io.aiven.kafka.tieredstorage.fetch.KeyNotFoundRuntimeException;
import io.aiven.kafka.tieredstorage.fetch.cache.DiskChunkCache;
import io.aiven.kafka.tieredstorage.fetch.cache.MemoryChunkCache;
import io.aiven.kafka.tieredstorage.manifest.SegmentEncryptionMetadataV1;
import io.aiven.kafka.tieredstorage.manifest.SegmentIndexesV1Builder;
import io.aiven.kafka.tieredstorage.manifest.index.ChunkIndex;
import io.aiven.kafka.tieredstorage.manifest.serde.EncryptionSerdeModule;
Expand Down Expand Up @@ -479,16 +478,15 @@ void testTransformingIndexes(final boolean encryption) {
"storage.root", targetDir.toString(),
"encryption.enabled", Boolean.toString(encryption)
));
final SegmentEncryptionMetadataV1 encryptionMetadata;
final DataKeyAndAAD maybeEncryptionKey;
if (encryption) {
config.put("encryption.key.pair.id", KEY_ENCRYPTION_KEY_ID);
config.put("encryption.key.pairs", KEY_ENCRYPTION_KEY_ID);
config.put("encryption.key.pairs." + KEY_ENCRYPTION_KEY_ID + ".public.key.file", publicKeyPem.toString());
config.put("encryption.key.pairs." + KEY_ENCRYPTION_KEY_ID + ".private.key.file", privateKeyPem.toString());
final var dataKeyAndAAD = aesEncryptionProvider.createDataKeyAndAAD();
encryptionMetadata = new SegmentEncryptionMetadataV1(dataKeyAndAAD.dataKey, dataKeyAndAAD.aad);
maybeEncryptionKey = aesEncryptionProvider.createDataKeyAndAAD();
} else {
encryptionMetadata = null;
maybeEncryptionKey = null;
}
rsm.configure(config);

Expand All @@ -498,7 +496,7 @@ void testTransformingIndexes(final boolean encryption) {
IndexType.OFFSET,
new ByteArrayInputStream(bytes),
bytes.length,
encryptionMetadata,
maybeEncryptionKey,
segmentIndexBuilder
);
assertThat(is).isNotEmpty();
Expand All @@ -510,21 +508,21 @@ void testTransformingIndexes(final boolean encryption) {
IndexType.TIMESTAMP,
new ByteArrayInputStream(bytes),
bytes.length,
encryptionMetadata,
maybeEncryptionKey,
segmentIndexBuilder
);
rsm.transformIndex(
IndexType.LEADER_EPOCH,
new ByteArrayInputStream(bytes),
bytes.length,
encryptionMetadata,
maybeEncryptionKey,
segmentIndexBuilder
);
rsm.transformIndex(
IndexType.PRODUCER_SNAPSHOT,
new ByteArrayInputStream(bytes),
bytes.length,
encryptionMetadata,
maybeEncryptionKey,
segmentIndexBuilder
);
final var index = segmentIndexBuilder.build();
Expand All @@ -544,14 +542,15 @@ void testTransformingEmptyIndexes(final boolean encryption) {
"storage.root", targetDir.toString(),
"encryption.enabled", Boolean.toString(encryption)
));
SegmentEncryptionMetadataV1 encryptionMetadata = null;
final DataKeyAndAAD maybeEncryptionKey;
if (encryption) {
config.put("encryption.key.pair.id", KEY_ENCRYPTION_KEY_ID);
config.put("encryption.key.pairs", KEY_ENCRYPTION_KEY_ID);
config.put("encryption.key.pairs." + KEY_ENCRYPTION_KEY_ID + ".public.key.file", publicKeyPem.toString());
config.put("encryption.key.pairs." + KEY_ENCRYPTION_KEY_ID + ".private.key.file", privateKeyPem.toString());
final var dataKeyAndAAD = aesEncryptionProvider.createDataKeyAndAAD();
encryptionMetadata = new SegmentEncryptionMetadataV1(dataKeyAndAAD.dataKey, dataKeyAndAAD.aad);
maybeEncryptionKey = aesEncryptionProvider.createDataKeyAndAAD();
} else {
maybeEncryptionKey = null;
}
rsm.configure(config);

Expand All @@ -560,7 +559,7 @@ void testTransformingEmptyIndexes(final boolean encryption) {
IndexType.OFFSET,
InputStream.nullInputStream(),
0,
encryptionMetadata,
maybeEncryptionKey,
segmentIndexBuilder
);
assertThat(is).isEmpty();
Expand All @@ -571,21 +570,21 @@ void testTransformingEmptyIndexes(final boolean encryption) {
IndexType.TIMESTAMP,
InputStream.nullInputStream(),
0,
encryptionMetadata,
maybeEncryptionKey,
segmentIndexBuilder
);
rsm.transformIndex(
IndexType.LEADER_EPOCH,
InputStream.nullInputStream(),
0,
encryptionMetadata,
maybeEncryptionKey,
segmentIndexBuilder
);
rsm.transformIndex(
IndexType.PRODUCER_SNAPSHOT,
InputStream.nullInputStream(),
0,
encryptionMetadata,
maybeEncryptionKey,
segmentIndexBuilder
);
final var index = segmentIndexBuilder.build();
Expand Down
Loading
Loading