Skip to content

Commit

Permalink
HDDS-10594. Update file encryption info when overwriting key (apache#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenSammi authored Mar 28, 2024
1 parent 7559e1f commit 3651d6c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@ static void createAndVerifyKeyData(OzoneBucket bucket) throws Exception {
out.write(value.getBytes(StandardCharsets.UTF_8));
}
verifyKeyData(bucket, keyName, value, testStartTime);
OzoneKeyDetails key1 = bucket.getKey(keyName);

// Overwrite the key
try (OzoneOutputStream out = bucket.createKey(keyName,
value.getBytes(StandardCharsets.UTF_8).length,
ReplicationConfig.fromTypeAndFactor(RATIS, ONE),
new HashMap<>())) {
out.write(value.getBytes(StandardCharsets.UTF_8));
}
OzoneKeyDetails key2 = bucket.getKey(keyName);
assertNotEquals(key1.getFileEncryptionInfo().toString(), key2.getFileEncryptionInfo().toString());
}

static void createAndVerifyFileSystemData(
Expand Down Expand Up @@ -325,7 +336,6 @@ static void verifyKeyData(OzoneBucket bucket, String keyName, String value,
len = is.read(fileContent);
}


assertEquals(len, value.length());
assertTrue(verifyRatisReplication(bucket.getVolumeName(),
bucket.getName(), keyName, RATIS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,8 @@ protected OmKeyInfo prepareFileInfo(
dbKeyInfo.getMetadata().clear();
dbKeyInfo.getMetadata().putAll(KeyValueUtil.getFromProtobuf(
keyArgs.getMetadataList()));

dbKeyInfo.setFileEncryptionInfo(encInfo);
return dbKeyInfo;
}

Expand Down

0 comments on commit 3651d6c

Please sign in to comment.