ihji commented on a change in pull request #15764:
URL: https://github.com/apache/beam/pull/15764#discussion_r765230472
##########
File path:
runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java
##########
@@ -850,6 +850,47 @@ private Debuggee registerDebuggee(CloudDebugger
debuggerClient, String uniquifie
}
}
+ protected RunnerApi.Pipeline applySdkEnvironmentOverrides(
+ RunnerApi.Pipeline pipeline, DataflowPipelineDebugOptions options) {
+ String sdkHarnessContainerImageOverrides =
options.getSdkHarnessContainerImageOverrides();
+ if (Strings.isNullOrEmpty(sdkHarnessContainerImageOverrides)) {
+ return pipeline;
+ }
+ String[] overrides = sdkHarnessContainerImageOverrides.split(",", -1);
+ if (overrides.length % 2 != 0) {
+ throw new RuntimeException(
+ "invalid syntax for SdkHarnessContainerImageOverrides: "
+ + options.getSdkHarnessContainerImageOverrides());
+ }
+ RunnerApi.Pipeline.Builder pipelineBuilder = pipeline.toBuilder();
+ RunnerApi.Components.Builder componentsBuilder =
pipelineBuilder.getComponentsBuilder();
+ componentsBuilder.clearEnvironments();
+ for (Map.Entry<String, RunnerApi.Environment> entry :
+ pipeline.getComponents().getEnvironmentsMap().entrySet()) {
+ RunnerApi.Environment.Builder environmentBuilder =
entry.getValue().toBuilder();
+ if (BeamUrns.getUrn(RunnerApi.StandardEnvironments.Environments.DOCKER)
+ .equals(environmentBuilder.getUrn())) {
+ RunnerApi.DockerPayload dockerPayload;
+ try {
+ dockerPayload =
RunnerApi.DockerPayload.parseFrom(environmentBuilder.getPayload());
+ } catch (InvalidProtocolBufferException e) {
+ throw new RuntimeException("Error parsing environment docker
payload.", e);
+ }
+ String containerImage = dockerPayload.getContainerImage();
+ for (int i = 0; i < overrides.length; i += 2) {
+ containerImage = containerImage.replaceAll(overrides[i], overrides[i
+ 1]);
Review comment:
It applies the same replacing tactic with the corresponding option in
Python SDK (`re.sub` also only replaces matching parts):
https://github.com/apache/beam/blob/master/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py#L737
I think it would be better to have the same behavior for the same option in
both Java and Python SDK.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]