Skip to content

Commit 8f66a29

Browse files
authored
[controller][admin-tool][compat] Add pub-sub encryption key URN to stores (#2962)
1 parent 8fc8a64 commit 8f66a29

30 files changed

Lines changed: 633 additions & 14 deletions

File tree

build.gradle

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,7 @@ subprojects {
328328
// Protocol changes should pin the current version via this override and remove the override in a follow-up PR
329329
// when actually using the new protocol. Example to pin KME to v12 when introducing v13:
330330
// project(':internal:venice-common').file('src/main/resources/avro/KafkaMessageEnvelope/v12', PathValidation.DIRECTORY)
331-
def versionOverrides = [
332-
project(':internal:venice-common').file('src/main/resources/avro/StoreMetaValue/v46', PathValidation.DIRECTORY),
333-
project(':services:venice-controller').file('src/main/resources/avro/AdminOperation/v101', PathValidation.DIRECTORY),
334-
]
331+
def versionOverrides = []
335332

336333
def schemaDirs = [sourceDir]
337334
sourceDir.eachDir { typeDir ->

clients/venice-admin-tool/src/main/java/com/linkedin/venice/AdminTool.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,7 @@ static UpdateStoreQueryParams getUpdateStoreQueryParams(CommandLine cmd) {
14311431
integerParam(cmd, Arg.LATEST_SUPERSET_SCHEMA_ID, p -> params.setLatestSupersetSchemaId(p), argSet);
14321432
booleanParam(cmd, Arg.ENABLE_COMPACTION, p -> params.setCompactionEnabled(p), argSet);
14331433
longParam(cmd, Arg.COMPACTION_THRESHOLD_MILLISECONDS, p -> params.setCompactionThresholdMilliseconds(p), argSet);
1434+
genericParam(cmd, Arg.PUB_SUB_ENCRYPTION_KEY_URN, s -> s, params::setPubSubEncryptionKeyUrn, argSet);
14341435
longParam(cmd, Arg.MIN_COMPACTION_LAG_SECONDS, p -> params.setMinCompactionLagSeconds(p), argSet);
14351436
longParam(cmd, Arg.MAX_COMPACTION_LAG_SECONDS, p -> params.setMaxCompactionLagSeconds(p), argSet);
14361437
integerParam(cmd, Arg.MAX_RECORD_SIZE_BYTES, params::setMaxRecordSizeBytes, argSet);

clients/venice-admin-tool/src/main/java/com/linkedin/venice/Arg.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ public enum Arg {
303303
COMPACTION_THRESHOLD_MILLISECONDS(
304304
"compaction-threshold-milliseconds", "ctms", true, "Set compaction threshold in milliseconds"
305305
),
306+
PUB_SUB_ENCRYPTION_KEY_URN(
307+
"pub-sub-encryption-key-urn", "psekurn", true, "Set the PubSub encryption key URN for an encryption-enabled store"
308+
),
306309
MIN_COMPACTION_LAG_SECONDS(
307310
"min-compaction-lag-seconds", "mcls", true, "Min compaction lag seconds for version topic of hybrid stores"
308311
),

clients/venice-admin-tool/src/main/java/com/linkedin/venice/Command.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
import static com.linkedin.venice.Arg.POSITION;
119119
import static com.linkedin.venice.Arg.PRINCIPAL;
120120
import static com.linkedin.venice.Arg.PROGRESS_INTERVAL;
121+
import static com.linkedin.venice.Arg.PUB_SUB_ENCRYPTION_KEY_URN;
121122
import static com.linkedin.venice.Arg.PUSH_ID;
122123
import static com.linkedin.venice.Arg.PUSH_STREAM_SOURCE_ADDRESS;
123124
import static com.linkedin.venice.Arg.READABILITY;
@@ -334,9 +335,9 @@ public enum Command {
334335
PUSH_STREAM_SOURCE_ADDRESS, BACKUP_VERSION_RETENTION_DAY, REPLICATION_FACTOR,
335336
NATIVE_REPLICATION_SOURCE_FABRIC, REPLICATE_ALL_CONFIGS, ACTIVE_ACTIVE_REPLICATION_ENABLED, REGIONS_FILTER,
336337
DISABLE_META_STORE, DISABLE_DAVINCI_PUSH_STATUS_STORE, STORAGE_PERSONA, STORE_VIEW_CONFIGS,
337-
LATEST_SUPERSET_SCHEMA_ID, ENABLE_COMPACTION, COMPACTION_THRESHOLD_MILLISECONDS, MIN_COMPACTION_LAG_SECONDS,
338-
MAX_COMPACTION_LAG_SECONDS, MAX_RECORD_SIZE_BYTES, MAX_NEARLINE_RECORD_SIZE_BYTES, THROUGHPUT_QUOTA_IN_BYTES,
339-
THROUGHPUT_QUOTA_IN_RECORDS, UNUSED_SCHEMA_DELETION_ENABLED, BLOB_TRANSFER_ENABLED,
338+
LATEST_SUPERSET_SCHEMA_ID, ENABLE_COMPACTION, COMPACTION_THRESHOLD_MILLISECONDS, PUB_SUB_ENCRYPTION_KEY_URN,
339+
MIN_COMPACTION_LAG_SECONDS, MAX_COMPACTION_LAG_SECONDS, MAX_RECORD_SIZE_BYTES, MAX_NEARLINE_RECORD_SIZE_BYTES,
340+
THROUGHPUT_QUOTA_IN_BYTES, THROUGHPUT_QUOTA_IN_RECORDS, UNUSED_SCHEMA_DELETION_ENABLED, BLOB_TRANSFER_ENABLED,
340341
SEPARATE_REALTIME_TOPIC_ENABLED, NEARLINE_PRODUCER_COMPRESSION_ENABLED, NEARLINE_PRODUCER_COUNT_PER_WRITER,
341342
TARGET_SWAP_REGION, TARGET_SWAP_REGION_WAIT_TIME, DAVINCI_HEARTBEAT_REPORTED, ENABLE_STORE_MIGRATION,
342343
GLOBAL_RT_DIV_ENABLED, ENUM_SCHEMA_EVOLUTION_ALLOWED, STORE_LIFECYCLE_HOOKS_LIST,

clients/venice-admin-tool/src/test/java/com/linkedin/venice/TestAdminTool.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ public void testAdminUpdateStoreRejectsEncryptionArgument() {
157157
expectThrows(ParseException.class, () -> AdminTool.getCommandLine(args));
158158
}
159159

160+
@Test
161+
public void testAdminUpdateStoreAcceptsPubSubEncryptionKeyUrn() throws ParseException, IOException {
162+
String pubSubEncryptionKeyUrn = "keyUrn:abc";
163+
String[] args = { "--update-store", "--url", "http://localhost:7036", "--cluster", "test-cluster", "--store",
164+
"testStore", "--pub-sub-encryption-key-urn", pubSubEncryptionKeyUrn };
165+
166+
UpdateStoreQueryParams params = AdminTool.getUpdateStoreQueryParams(AdminTool.getCommandLine(args));
167+
168+
assertEquals(params.getPubSubEncryptionKeyUrn(), Optional.of(pubSubEncryptionKeyUrn));
169+
}
170+
160171
@Test
161172
public void testAdminUpdateStoreArgThroughputQuota() throws ParseException, IOException {
162173
String[] args = { "--update-store", "--url", "http://localhost:7036", "--cluster", "test-cluster", "--store",

internal/venice-common/src/main/java/com/linkedin/venice/controllerapi/ControllerApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ public class ControllerApiConstants {
269269

270270
public static final String COMPACTION_ENABLED = "compaction_enabled";
271271
public static final String COMPACTION_THRESHOLD_MILLISECONDS = "compaction_threshold_milliseconds";
272+
public static final String PUB_SUB_ENCRYPTION_KEY_URN = "pub_sub_encryption_key_urn";
272273
public static final String MIN_COMPACTION_LAG_SECONDS = "min_compaction_lag_seconds";
273274
public static final String MAX_COMPACTION_LAG_SECONDS = "max_compaction_lag_seconds";
274275

internal/venice-common/src/main/java/com/linkedin/venice/controllerapi/UpdateStoreQueryParams.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import static com.linkedin.venice.controllerapi.ControllerApiConstants.PARTITION_COUNT;
5959
import static com.linkedin.venice.controllerapi.ControllerApiConstants.PERSONA_NAME;
6060
import static com.linkedin.venice.controllerapi.ControllerApiConstants.PREVIOUS_CURRENT_VERSION;
61+
import static com.linkedin.venice.controllerapi.ControllerApiConstants.PUB_SUB_ENCRYPTION_KEY_URN;
6162
import static com.linkedin.venice.controllerapi.ControllerApiConstants.PUSH_STREAM_SOURCE_ADDRESS;
6263
import static com.linkedin.venice.controllerapi.ControllerApiConstants.READ_COMPUTATION_ENABLED;
6364
import static com.linkedin.venice.controllerapi.ControllerApiConstants.READ_QUOTA_IN_CU;
@@ -140,6 +141,7 @@ public UpdateStoreQueryParams() {
140141
* @param srcStore The original store
141142
*/
142143
public UpdateStoreQueryParams(StoreInfo srcStore, boolean storeMigrating) {
144+
String pubSubEncryptionKeyUrn = srcStore.getPubSubEncryptionKeyUrn();
143145
// Copy everything except for currentVersion, daVinciPushStatusStoreEnabled, latestSuperSetValueSchemaId,
144146
// storeMetaSystemStoreEnabled, storeMetadataSystemStoreEnabled
145147
UpdateStoreQueryParams updateStoreQueryParams =
@@ -201,6 +203,10 @@ public UpdateStoreQueryParams(StoreInfo srcStore, boolean storeMigrating) {
201203
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().toString())))
202204
.setFlinkVeniceViewsEnabled(srcStore.isFlinkVeniceViewsEnabled());
203205

206+
if (pubSubEncryptionKeyUrn != null && !pubSubEncryptionKeyUrn.trim().isEmpty()) {
207+
updateStoreQueryParams.setPubSubEncryptionKeyUrn(pubSubEncryptionKeyUrn);
208+
}
209+
204210
if (srcStore.getReplicationMetadataVersionId() != -1) {
205211
updateStoreQueryParams.setReplicationMetadataVersionID(srcStore.getReplicationMetadataVersionId());
206212
}
@@ -813,6 +819,14 @@ public Optional<Long> getMinCompactionLagSeconds() {
813819
return getLong(MIN_COMPACTION_LAG_SECONDS);
814820
}
815821

822+
public UpdateStoreQueryParams setPubSubEncryptionKeyUrn(String pubSubEncryptionKeyUrn) {
823+
return putString(PUB_SUB_ENCRYPTION_KEY_URN, pubSubEncryptionKeyUrn);
824+
}
825+
826+
public Optional<String> getPubSubEncryptionKeyUrn() {
827+
return getString(PUB_SUB_ENCRYPTION_KEY_URN);
828+
}
829+
816830
public Optional<String> getViewName() {
817831
return getString(STORE_VIEW_NAME);
818832
}

internal/venice-common/src/main/java/com/linkedin/venice/meta/ReadOnlyStore.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,7 @@ public StoreProperties cloneStoreProperties() {
10901090
storeProperties.setCompactionEnabled(isCompactionEnabled());
10911091
storeProperties.setCompactionThresholdMilliseconds(getCompactionThresholdMilliseconds());
10921092
storeProperties.setEncryptionEnabled(isEncryptionEnabled());
1093+
storeProperties.setPubSubEncryptionKeyUrn(getPubSubEncryptionKeyUrn());
10931094
storeProperties.setMinCompactionLagSeconds(getMinCompactionLagSeconds());
10941095
storeProperties.setMaxCompactionLagSeconds(getMaxCompactionLagSeconds());
10951096
storeProperties.setMaxRecordSizeBytes(getMaxRecordSizeBytes());
@@ -1707,6 +1708,16 @@ public void setEncryptionEnabled(boolean encryptionEnabled) {
17071708
throw new UnsupportedOperationException();
17081709
}
17091710

1711+
@Override
1712+
public String getPubSubEncryptionKeyUrn() {
1713+
return this.delegate.getPubSubEncryptionKeyUrn();
1714+
}
1715+
1716+
@Override
1717+
public void setPubSubEncryptionKeyUrn(String pubSubEncryptionKeyUrn) {
1718+
throw new UnsupportedOperationException();
1719+
}
1720+
17101721
@Override
17111722
public long getMinCompactionLagSeconds() {
17121723
return this.delegate.getMinCompactionLagSeconds();

internal/venice-common/src/main/java/com/linkedin/venice/meta/Store.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ default void setVersionTargetRegionPromoted(int versionNumber, boolean targetReg
351351

352352
void setEncryptionEnabled(boolean encryptionEnabled);
353353

354+
String getPubSubEncryptionKeyUrn();
355+
356+
void setPubSubEncryptionKeyUrn(String pubSubEncryptionKeyUrn);
357+
354358
long getMinCompactionLagSeconds();
355359

356360
void setMinCompactionLagSeconds(long minCompactionLagSeconds);

internal/venice-common/src/main/java/com/linkedin/venice/meta/StoreInfo.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public static StoreInfo fromStore(Store store) {
7979
storeInfo.setCompactionEnabled(store.isCompactionEnabled());
8080
storeInfo.setCompactionThreshold(store.getCompactionThresholdMilliseconds());
8181
storeInfo.setEncryptionEnabled(store.isEncryptionEnabled());
82+
storeInfo.setPubSubEncryptionKeyUrn(store.getPubSubEncryptionKeyUrn());
8283
storeInfo.setMinCompactionLagSeconds(store.getMinCompactionLagSeconds());
8384
storeInfo.setMaxCompactionLagSeconds(store.getMaxCompactionLagSeconds());
8485
storeInfo.setMaxRecordSizeBytes(store.getMaxRecordSizeBytes());
@@ -371,6 +372,8 @@ public static StoreInfo fromStore(Store store) {
371372

372373
private boolean encryptionEnabled;
373374

375+
private String pubSubEncryptionKeyUrn = "";
376+
374377
private long minCompactionLagSeconds;
375378

376379
private long maxCompactionLagSeconds;
@@ -916,6 +919,14 @@ public void setEncryptionEnabled(boolean encryptionEnabled) {
916919
this.encryptionEnabled = encryptionEnabled;
917920
}
918921

922+
public String getPubSubEncryptionKeyUrn() {
923+
return pubSubEncryptionKeyUrn;
924+
}
925+
926+
public void setPubSubEncryptionKeyUrn(String pubSubEncryptionKeyUrn) {
927+
this.pubSubEncryptionKeyUrn = pubSubEncryptionKeyUrn;
928+
}
929+
919930
public long getMinCompactionLagSeconds() {
920931
return minCompactionLagSeconds;
921932
}

0 commit comments

Comments
 (0)