Skip to content

Commit 1c6f779

Browse files
authored
Add use_gbek service option when gbek option used (#36452)
1 parent c54cc2b commit 1c6f779

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,22 @@ public DataflowPipelineJob run(Pipeline pipeline) {
12831283
options.as(SdkHarnessOptions.class).setEnableLogViaFnApi(true);
12841284
}
12851285

1286+
// Add use_gbek to dataflow_service_options if gbek is set.
1287+
List<String> dataflowServiceOptions = options.getDataflowServiceOptions();
1288+
if (dataflowServiceOptions == null) {
1289+
dataflowServiceOptions = new ArrayList<>();
1290+
}
1291+
if (!Strings.isNullOrEmpty(options.as(DataflowPipelineDebugOptions.class).getGbek())) {
1292+
if (!dataflowServiceOptions.contains("use_gbek")) {
1293+
dataflowServiceOptions.add("use_gbek");
1294+
}
1295+
} else if (dataflowServiceOptions.contains("use_gbek")) {
1296+
throw new IllegalArgumentException(
1297+
"Do not set use_gbek directly, pass in the --gbek pipeline option "
1298+
+ "with a valid secret instead.");
1299+
}
1300+
options.setDataflowServiceOptions(dataflowServiceOptions);
1301+
12861302
logWarningIfPCollectionViewHasNonDeterministicKeyCoder(pipeline);
12871303
logWarningIfBigqueryDLQUnused(pipeline);
12881304
if (shouldActAsStreaming(pipeline)) {

sdks/python/apache_beam/runners/dataflow/dataflow_runner.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,15 @@ def _check_and_add_missing_options(options):
602602
debug_options = options.view_as(DebugOptions)
603603
dataflow_service_options = options.view_as(
604604
GoogleCloudOptions).dataflow_service_options or []
605-
options.view_as(
606-
GoogleCloudOptions).dataflow_service_options = dataflow_service_options
605+
606+
# Add use_gbek to dataflow_service_options if gbek is set.
607+
if options.view_as(SetupOptions).gbek:
608+
if 'use_gbek' not in dataflow_service_options:
609+
dataflow_service_options.append('use_gbek')
610+
elif 'use_gbek' in dataflow_service_options:
611+
raise ValueError(
612+
'Do not set use_gbek directly, pass in the --gbek pipeline option '
613+
'with a valid secret instead.')
607614

608615
_add_runner_v2_missing_options(options)
609616

@@ -614,6 +621,9 @@ def _check_and_add_missing_options(options):
614621
elif debug_options.lookup_experiment('enable_prime'):
615622
dataflow_service_options.append('enable_prime')
616623

624+
options.view_as(
625+
GoogleCloudOptions).dataflow_service_options = dataflow_service_options
626+
617627
sdk_location = options.view_as(SetupOptions).sdk_location
618628
if 'dev' in beam.version.__version__ and sdk_location == 'default':
619629
raise ValueError(

0 commit comments

Comments
 (0)