File tree Expand file tree Collapse file tree
runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow
sdks/python/apache_beam/runners/dataflow Expand file tree Collapse file tree Original file line number Diff line number Diff 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 )) {
Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments