Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add support for building Go code and docker container images with maven (see sdks/go/BUILD.md for details). The latter is only done if the "build-containers" profile is used. * Add GCS proxy service for managing artifacts in GCS. * Add GCE md service for metdata-configured provision info in GCE. * Add beamctl tool for manually interacting with these services. This PR is focused on the execution side and would need support from the submission side as well to be functional. The ULR will likely be the first runner to tie everything together. The contents of the java image is kept simple for now.
- Loading branch information
Showing
39 changed files
with
4,205 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
############################################################################### | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
############################################################################### | ||
|
||
FROM debian:stretch | ||
MAINTAINER "Apache Beam <dev@beam.apache.org>" | ||
|
||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
ca-certificates \ | ||
&& \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ADD target/linux_amd64/gcemd /opt/apache/beam/ | ||
|
||
ENTRYPOINT ["/opt/apache/beam/gcemd"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one or more | ||
// contributor license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright ownership. | ||
// The ASF licenses this file to You under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// gcemd is a metadata-configured provisioning server for GCE. | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
"net" | ||
|
||
"cloud.google.com/go/compute/metadata" | ||
pb "github.com/apache/beam/sdks/go/pkg/beam/model/org_apache_beam_fn_v1" | ||
"github.com/apache/beam/sdks/go/pkg/beam/provision" | ||
"golang.org/x/net/context" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
var ( | ||
endpoint = flag.String("endpoint", "", "Server endpoint to expose.") | ||
) | ||
|
||
func main() { | ||
flag.Parse() | ||
if *endpoint == "" { | ||
log.Fatal("No endpoint provided. Use --endpoint=localhost:12345") | ||
} | ||
if !metadata.OnGCE() { | ||
log.Fatal("Not running on GCE") | ||
} | ||
|
||
log.Printf("Starting provisioning server on %v", *endpoint) | ||
|
||
jobID, err := metadata.InstanceAttributeValue("job_id") | ||
if err != nil { | ||
log.Fatalf("Failed to find job ID: %v", err) | ||
} | ||
jobName, err := metadata.InstanceAttributeValue("job_name") | ||
if err != nil { | ||
log.Fatalf("Failed to find job name: %v", err) | ||
} | ||
opt, err := metadata.InstanceAttributeValue("sdk_pipeline_options") | ||
if err != nil { | ||
log.Fatalf("Failed to find SDK pipeline options: %v", err) | ||
} | ||
options, err := provision.JSONToProto(opt) | ||
if err != nil { | ||
log.Fatalf("Failed to parse SDK pipeline options: %v", err) | ||
} | ||
|
||
info := &pb.ProvisionInfo{ | ||
JobId: jobID, | ||
JobName: jobName, | ||
PipelineOptions: options, | ||
} | ||
|
||
gs := grpc.NewServer() | ||
pb.RegisterProvisionServiceServer(gs, &server{info: info}) | ||
|
||
listener, err := net.Listen("tcp", *endpoint) | ||
if err != nil { | ||
log.Fatalf("Failed to listen to %v: %v", *endpoint, err) | ||
} | ||
log.Fatalf("Server failed: %v", gs.Serve(listener)) | ||
} | ||
|
||
type server struct { | ||
info *pb.ProvisionInfo | ||
} | ||
|
||
func (s *server) GetProvisionInfo(ctx context.Context, req *pb.GetProvisionInfoRequest) (*pb.GetProvisionInfoResponse, error) { | ||
return &pb.GetProvisionInfoResponse{Info: s.info}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.beam</groupId> | ||
<artifactId>beam-runners-gcp-parent</artifactId> | ||
<version>2.2.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>beam-runners-gcp-gcemd</artifactId> | ||
|
||
<packaging>pom</packaging> | ||
|
||
<name>Apache Beam :: Runners :: Google Cloud Platform :: GCE metadata provisioning</name> | ||
|
||
<properties> | ||
<!-- Add full path directory structure for 'go get' compatibility --> | ||
<go.source.base>${project.basedir}/target/src</go.source.base> | ||
<go.source.dir>${go.source.base}/github.com/apache/beam/sdks/go</go.source.dir> | ||
</properties> | ||
|
||
<build> | ||
<sourceDirectory>${go.source.base}</sourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>copy-go-cmd-source</id> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>copy-resources</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${go.source.base}/github.com/apache/beam/cmd/gcemd</outputDirectory> | ||
<resources> | ||
<resource> | ||
<directory>.</directory> | ||
<includes> | ||
<include>*.go</include> | ||
</includes> | ||
<filtering>false</filtering> | ||
</resource> | ||
</resources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<!-- CAVEAT: for latest shared files, run mvn install in sdks/go --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>copy-dependency</id> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>unpack</goal> | ||
</goals> | ||
<configuration> | ||
<artifactItems> | ||
<artifactItem> | ||
<groupId>org.apache.beam</groupId> | ||
<artifactId>beam-sdks-go</artifactId> | ||
<version>${project.version}</version> | ||
<type>zip</type> | ||
<classifier>pkg-sources</classifier> | ||
<overWrite>true</overWrite> | ||
<outputDirectory>${go.source.dir}</outputDirectory> | ||
</artifactItem> | ||
</artifactItems> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>com.igormaznitsa</groupId> | ||
<artifactId>mvn-golang-wrapper</artifactId> | ||
<executions> | ||
<execution> | ||
<id>go-get-imports</id> | ||
<goals> | ||
<goal>get</goal> | ||
</goals> | ||
<phase>compile</phase> | ||
<configuration> | ||
<packages> | ||
<package>google.golang.org/grpc</package> | ||
<package>golang.org/x/oauth2/google</package> | ||
<package>cloud.google.com/go/compute/metadata</package> | ||
</packages> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>go-build</id> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
<phase>compile</phase> | ||
<configuration> | ||
<packages> | ||
<package>github.com/apache/beam/cmd/gcemd</package> | ||
</packages> | ||
<resultName>gcemd</resultName> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>go-build-linux-amd64</id> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
<phase>compile</phase> | ||
<configuration> | ||
<packages> | ||
<package>github.com/apache/beam/cmd/gcemd</package> | ||
</packages> | ||
<resultName>linux_amd64/gcemd</resultName> | ||
<targetArch>amd64</targetArch> | ||
<targetOs>linux</targetOs> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>com.spotify</groupId> | ||
<artifactId>dockerfile-maven-plugin</artifactId> | ||
<configuration> | ||
<repository>${docker-repository-root}/gcemd</repository> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
############################################################################### | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
############################################################################### | ||
|
||
FROM debian:stretch | ||
MAINTAINER "Apache Beam <dev@beam.apache.org>" | ||
|
||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
ca-certificates \ | ||
&& \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ADD target/linux_amd64/gcsproxy /opt/apache/beam/ | ||
|
||
ENTRYPOINT ["/opt/apache/beam/gcsproxy"] |
Oops, something went wrong.