[
https://issues.apache.org/jira/browse/BEAM-11935?focusedWorklogId=577143&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-577143
]
ASF GitHub Bot logged work on BEAM-11935:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 05/Apr/21 22:17
Start Date: 05/Apr/21 22:17
Worklog Time Spent: 10m
Work Description: kennknowles commented on a change in pull request
#14408:
URL: https://github.com/apache/beam/pull/14408#discussion_r607365007
##########
File path:
runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java
##########
@@ -1276,37 +1275,60 @@ public DataflowPipelineJob run(Pipeline pipeline) {
return dataflowPipelineJob;
}
+ private static String getContainerImageFromEnvironmentId(
+ String environmentId, RunnerApi.Pipeline pipelineProto) {
+ RunnerApi.Environment environment =
+ pipelineProto.getComponents().getEnvironmentsMap().get(environmentId);
+ if (!BeamUrns.getUrn(RunnerApi.StandardEnvironments.Environments.DOCKER)
+ .equals(environment.getUrn())) {
+ throw new RuntimeException(
+ "Dataflow can only execute pipeline steps in Docker environments: "
+ + environment.getUrn());
+ }
+ RunnerApi.DockerPayload dockerPayload;
+ try {
+ dockerPayload =
RunnerApi.DockerPayload.parseFrom(environment.getPayload());
+ } catch (InvalidProtocolBufferException e) {
+ throw new RuntimeException("Error parsing docker payload.", e);
+ }
+ return dockerPayload.getContainerImage();
+ }
+
+ @AutoValue
+ abstract static class EnvironmentInfo {
+ static EnvironmentInfo create(String environmentId, String containerUrl) {
+ return new AutoValue_DataflowRunner_EnvironmentInfo(environmentId,
containerUrl);
+ }
+
+ abstract String environmentId();
+
+ abstract String containerUrl();
+ }
+
+ private static List<EnvironmentInfo>
getAllEnvironmentInfo(RunnerApi.Pipeline pipelineProto) {
Review comment:
Noting that this is generally useful and could be moved outside of
`DataflowRunner` into runners-core-construction or something. (non-blocking
comment)
##########
File path:
runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java
##########
@@ -1276,37 +1275,60 @@ public DataflowPipelineJob run(Pipeline pipeline) {
return dataflowPipelineJob;
}
+ private static String getContainerImageFromEnvironmentId(
+ String environmentId, RunnerApi.Pipeline pipelineProto) {
+ RunnerApi.Environment environment =
+ pipelineProto.getComponents().getEnvironmentsMap().get(environmentId);
+ if (!BeamUrns.getUrn(RunnerApi.StandardEnvironments.Environments.DOCKER)
+ .equals(environment.getUrn())) {
+ throw new RuntimeException(
+ "Dataflow can only execute pipeline steps in Docker environments: "
+ + environment.getUrn());
+ }
+ RunnerApi.DockerPayload dockerPayload;
+ try {
+ dockerPayload =
RunnerApi.DockerPayload.parseFrom(environment.getPayload());
+ } catch (InvalidProtocolBufferException e) {
+ throw new RuntimeException("Error parsing docker payload.", e);
+ }
+ return dockerPayload.getContainerImage();
+ }
+
+ @AutoValue
+ abstract static class EnvironmentInfo {
+ static EnvironmentInfo create(String environmentId, String containerUrl) {
+ return new AutoValue_DataflowRunner_EnvironmentInfo(environmentId,
containerUrl);
+ }
+
+ abstract String environmentId();
+
+ abstract String containerUrl();
+ }
+
+ private static List<EnvironmentInfo>
getAllEnvironmentInfo(RunnerApi.Pipeline pipelineProto) {
+ return pipelineProto.getComponents().getTransformsMap().values().stream()
+ .map(transform -> transform.getEnvironmentId())
+ .filter(environmentId -> !environmentId.isEmpty())
+ .distinct()
+ .map(
+ environmentId ->
+ EnvironmentInfo.create(
+ environmentId,
+ getContainerImageFromEnvironmentId(environmentId,
pipelineProto)))
+ .collect(Collectors.toList());
+ }
+
static void configureSdkHarnessContainerImages(
- DataflowPipelineOptions options,
- RunnerApi.Pipeline pipelineProto,
- Job newJob,
- String workerHarnessContainerImage) {
+ DataflowPipelineOptions options, RunnerApi.Pipeline pipelineProto, Job
newJob) {
if (useUnifiedWorker(options)) {
- ImmutableSet.Builder<String> sdkContainerUrlSetBuilder =
ImmutableSet.builder();
- sdkContainerUrlSetBuilder.add(workerHarnessContainerImage);
- for (Map.Entry<String, RunnerApi.Environment> entry :
- pipelineProto.getComponents().getEnvironmentsMap().entrySet()) {
- if
(!BeamUrns.getUrn(RunnerApi.StandardEnvironments.Environments.DOCKER)
- .equals(entry.getValue().getUrn())) {
- throw new RuntimeException(
- "Dataflow can only execute pipeline steps in Docker
environments: "
- + entry.getValue().getUrn());
- }
- RunnerApi.DockerPayload dockerPayload;
- try {
- dockerPayload =
RunnerApi.DockerPayload.parseFrom(entry.getValue().getPayload());
- } catch (InvalidProtocolBufferException e) {
- throw new RuntimeException("Error parsing docker payload.", e);
- }
- sdkContainerUrlSetBuilder.add(dockerPayload.getContainerImage());
- }
List<SdkHarnessContainerImage> sdkContainerList =
- sdkContainerUrlSetBuilder.build().stream()
+ getAllEnvironmentInfo(pipelineProto).stream()
.map(
- (String url) -> {
+ environmentInfo -> {
SdkHarnessContainerImage image = new
SdkHarnessContainerImage();
- image.setContainerImage(url);
- if (url.toLowerCase().contains("python")) {
+ image.setEnvironmentId(environmentInfo.environmentId());
+ image.setContainerImage(environmentInfo.containerUrl());
Review comment:
Is this a temporary adapter? I would guess if there is some code that
downloads the portable pipeline it could extract the container image on the
service side based on the environment id? (non-blocking comment)
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 577143)
Time Spent: 12h 20m (was: 12h 10m)
> Update Dataflow requests to include the environment ID
> ------------------------------------------------------
>
> Key: BEAM-11935
> URL: https://issues.apache.org/jira/browse/BEAM-11935
> Project: Beam
> Issue Type: Bug
> Components: cross-language, runner-dataflow
> Reporter: Chamikara Madhusanka Jayalath
> Assignee: Chamikara Madhusanka Jayalath
> Priority: P2
> Time Spent: 12h 20m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)