Skip to content

Commit a2042c4

Browse files
authored
Support C++ (#130)
* Implemented c++ pipeline execution. Build is still missing. * Implemented build of c++ pipelines * Fine tuning and some small bug fixes * Fixed two failing tests * Added test for scheduler * Tiny UI improvement * Added c++ dockerfile and updated goreleaser. Updated readme (partially). Removed mapping of variables in docker-entrypoint file * Updated readme file again * Fixed incorrect dockerfils
1 parent c3b84a9 commit a2042c4

18 files changed

+552
-33
lines changed

.goreleaser.yml

+16-1
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,32 @@ dockers:
3232
skip_push: false
3333
binary: gaia-linux-amd64
3434
dockerfile: docker/Dockerfile.golang
35+
extra_files:
36+
- docker/docker-entrypoint.sh
3537
tag_templates:
3638
- "{{ .Tag }}-go"
3739
- image: gaiapipeline/gaia
3840
skip_push: false
3941
binary: gaia-linux-amd64
4042
dockerfile: docker/Dockerfile.java
43+
extra_files:
44+
- docker/docker-entrypoint.sh
45+
- docker/settings-docker.xml
4146
tag_templates:
4247
- "{{ .Tag }}-java"
4348
- image: gaiapipeline/gaia
4449
skip_push: false
4550
binary: gaia-linux-amd64
4651
dockerfile: docker/Dockerfile.python
52+
extra_files:
53+
- docker/docker-entrypoint.sh
54+
tag_templates:
55+
- "{{ .Tag }}-python"
56+
- image: gaiapipeline/gaia
57+
skip_push: false
58+
binary: gaia-linux-amd64
59+
dockerfile: docker/Dockerfile.cpp
60+
extra_files:
61+
- docker/docker-entrypoint.sh
4762
tag_templates:
48-
- "{{ .Tag }}-python"
63+
- "{{ .Tag }}-cpp"

README.rst

+51-20
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ Installation
6161

6262
The installation of gaia is simple and often takes a few minutes.
6363

64+
Using docker
65+
~~~~~~~~~~~~
66+
67+
The following command starts gaia as a daemon process and mounts all data to the current folder. Afterwards, gaia will be available on the host system on port 8080. Use the standard user **admin** and password **admin** as initial login. It is recommended to change the password afterwards.
68+
69+
.. code:: sh
70+
71+
docker run -d -p 8080:8080 -v $PWD:/data gaiapipeline/gaia:latest
72+
73+
This uses the image with the *latest* tag which includes all required libraries and compilers for all supported languages. If you prefer a smaller image suited for your prefered language, have a look at the `available docker image tags`_.
74+
75+
Manually
76+
~~~~~~~~
77+
78+
It is possible to install Gaia directly on the host system.
79+
This can be achieved by downloading the binary from the `releases page`_.
80+
81+
Gaia will automatically detect the folder of the binary and will place all data next to it. You can change the data directory with the startup parameter *--homepath* if you want.
82+
6483
Using helm
6584
~~~~~~~~~~
6685

@@ -82,25 +101,6 @@ To deploy gaia:
82101
83102
make deploy-kube
84103
85-
Using docker
86-
~~~~~~~~~~~~
87-
88-
The following command starts gaia as a daemon process and mounts all data to the current folder. Afterwards, gaia will be available on the host system on port 8080. Use the standard user **admin** and password **admin** as initial login. It is recommended to change the password afterwards.
89-
90-
.. code:: sh
91-
92-
docker run -d -p 8080:8080 -v $PWD:/data gaiapipeline/gaia:latest
93-
94-
This uses the image with the *latest* tag which includes all required libraries and compilers for all supported languages. If you prefer a smaller image suited for your prefered language, have a look at the `available docker image tags`_.
95-
96-
Manually
97-
~~~~~~~~
98-
99-
It is possible to install Gaia directly on the host system.
100-
This can be achieved by downloading the binary from the `releases page`_.
101-
102-
Gaia will automatically detect the folder of the binary and will place all data next to it. You can change the data directory with the startup parameter *--homepath* if you want.
103-
104104
Usage
105105
-----
106106

@@ -196,6 +196,37 @@ Java
196196
}
197197
}
198198
199+
C++
200+
~~~~
201+
202+
.. code:: cpp
203+
204+
#include "cppsdk/sdk.h"
205+
#include <list>
206+
#include <iostream>
207+
208+
void DoSomethingAwesome(std::list<gaia::argument> args) throw(std::string) {
209+
std::cerr << "This output will be streamed back to gaia and will be displayed in the pipeline logs." << std::endl;
210+
211+
// An error occured? Return it back so gaia knows that this job failed.
212+
// throw "Uhh something badly happened!"
213+
}
214+
215+
int main() {
216+
std::list<gaia::job> jobs;
217+
gaia::job awesomejob;
218+
awesomejob.handler = &DoSomethingAwesome;
219+
awesomejob.title = "DoSomethingAwesome";
220+
awesomejob.description = "This job does something awesome.";
221+
jobs.push_back(awesomejob);
222+
223+
try {
224+
gaia::Serve(jobs);
225+
} catch (string e) {
226+
std::cerr << "Error: " << e << std::endl;
227+
}
228+
}
229+
199230
Pipelines are defined by jobs and a function usually represents a job. You can define as many jobs in your pipeline as you want.
200231

201232
Every function accepts arguments. Those arguments can be requested from the pipeline itself and the values passed back in from the UI.
@@ -237,7 +268,7 @@ The SDK implements the Gaia plugin gRPC interface and offers helper functions li
237268

238269
Which programming languages are supported?
239270
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
240-
We currently fully support Golang, Java and Python.
271+
We currently fully support Golang, Java, Python and C++.
241272

242273
When do you support programming language **XYZ**?
243274
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

docker/Dockerfile

+21-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ RUN ln -svT "/usr/lib/jvm/java-8-openjdk-$(dpkg --print-architecture)" /docker-j
8080
ENV JAVA_HOME /docker-java-home
8181

8282
ENV JAVA_VERSION 8u181
83-
ENV JAVA_DEBIAN_VERSION 8u181-b13-1~deb9u1
83+
ENV JAVA_DEBIAN_VERSION 8u181-b13-2~deb9u1
8484

8585
# see https://bugs.debian.org/775775
8686
# and https://github.com/docker-library/java/issues/19#issuecomment-70546872
@@ -131,6 +131,26 @@ ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
131131
COPY settings-docker.xml /usr/share/maven/ref/
132132
# --------------- End Maven Part ---------------
133133

134+
# --------------- Start C++ Part ---------------
135+
RUN apt-get update && apt-get install -y \
136+
build-essential autoconf git pkg-config \
137+
automake libtool curl make g++ unzip \
138+
&& apt-get clean
139+
140+
# install protobuf first, then grpc
141+
ENV GRPC_RELEASE_TAG v1.16.x
142+
RUN git clone -b ${GRPC_RELEASE_TAG} https://github.com/grpc/grpc /var/local/git/grpc && \
143+
cd /var/local/git/grpc && \
144+
git submodule update --init && \
145+
echo "--- installing protobuf ---" && \
146+
cd third_party/protobuf && \
147+
./autogen.sh && ./configure --enable-shared && \
148+
make -j$(nproc) && make install && make clean && ldconfig && \
149+
echo "--- installing grpc ---" && \
150+
cd /var/local/git/grpc && \
151+
make -j$(nproc) && make install && make clean && ldconfig
152+
# --------------- Start C++ Part ---------------
153+
134154
# install additional deps
135155
RUN apt-get update && apt-get install -y --no-install-recommends \
136156
python2.7-dev \

docker/Dockerfile.cpp

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM debian:stretch
2+
3+
RUN apt-get update && apt-get install -y \
4+
build-essential autoconf git pkg-config \
5+
automake libtool curl make g++ unzip \
6+
&& apt-get clean
7+
8+
# install protobuf first, then grpc
9+
ENV GRPC_RELEASE_TAG v1.16.x
10+
RUN git clone -b ${GRPC_RELEASE_TAG} https://github.com/grpc/grpc /var/local/git/grpc && \
11+
cd /var/local/git/grpc && \
12+
git submodule update --init && \
13+
echo "--- installing protobuf ---" && \
14+
cd third_party/protobuf && \
15+
./autogen.sh && ./configure --enable-shared && \
16+
make -j$(nproc) && make install && make clean && ldconfig && \
17+
echo "--- installing grpc ---" && \
18+
cd /var/local/git/grpc && \
19+
make -j$(nproc) && make install && make clean && ldconfig
20+
21+
# Gaia internal port and data path.
22+
ENV GAIA_PORT=8080 \
23+
GAIA_HOMEPATH=/data
24+
25+
# Directory for the binary
26+
WORKDIR /app
27+
28+
# Copy gaia binary into docker image
29+
COPY gaia-linux-amd64 /app
30+
31+
# Fix permissions
32+
RUN chmod +x ./gaia-linux-amd64
33+
34+
# Set homepath as volume
35+
VOLUME [ "${GAIA_HOMEPATH}" ]
36+
37+
# Expose port
38+
EXPOSE ${GAIA_PORT}
39+
40+
# Copy entry point script
41+
COPY docker-entrypoint.sh /usr/local/bin/
42+
43+
# Start gaia
44+
ENTRYPOINT [ "docker-entrypoint.sh" ]

docker/docker-entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22

33
# Start gaia
4-
exec /app/gaia-linux-amd64 --port=${GAIA_PORT} --homepath=${GAIA_HOMEPATH} --worker=${GAIA_WORKER}
4+
exec /app/gaia-linux-amd64
File renamed without changes.

frontend/client/views/overview/index.vue

+18-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<div class="outer-box">
1010
<router-link :to="{ path: '/pipeline/detail', query: { pipelineid: pipeline.p.id }}" class="hoveraction">
1111
<div class="outer-box-icon-image">
12-
<img :src="getImagePath(pipeline.p.type)" class="outer-box-image" v-bind:class="{ 'outer-box-image-python': pipeline.p.type === 'python', 'outer-box-image': pipeline.p.type !== 'python' }">
12+
<img :src="getImagePath(pipeline.p.type)" v-bind:class="pipelineImageClass(pipeline.p.type)">
1313
</div>
1414
<div>
1515
<span class="subtitle">{{ pipeline.p.name }}</span>
@@ -103,6 +103,14 @@ export default {
103103
})
104104
},
105105
106+
pipelineImageClass (type) {
107+
return {
108+
'outer-box-image-python': type === 'python',
109+
'outer-box-image-cpp': type === 'cpp',
110+
'outer-box-image': type !== 'python' && type !== 'cpp'
111+
}
112+
},
113+
106114
checkPipelineArgs (pipeline) {
107115
this.pipeline = pipeline
108116
@@ -259,6 +267,15 @@ export default {
259267
transform: translate(-50%, -50%);
260268
}
261269
270+
.outer-box-image-cpp {
271+
position: absolute;
272+
width: 27px;
273+
height: 30px;
274+
top: 50%;
275+
left: 50%;
276+
transform: translate(-50%, -50%);
277+
}
278+
262279
.hoveraction:hover .outer-box-icon-image {
263280
border-color: #4da2fc !important;
264281
}

frontend/client/views/pipeline/create.vue

+10-3
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@
7777
</div>
7878
</div>
7979
<div class="content" style="display: flex;">
80-
<div class="pipelinetype" title="C++ (not yet supported)" v-tippy="{ arrow : true, animation : 'shift-away'}" v-bind:class="{ pipelinetypeactive: createPipeline.pipeline.type === 'cplusplus' }" data-tippy-hideOnClick="false">
81-
<img src="~assets/cplusplus.png" class="typeimage typeimagenotyetsupported">
80+
<div class="pipelinetype" title="C++" v-tippy="{ arrow : true, animation : 'shift-away'}" v-on:click="createPipeline.pipeline.type = 'cpp'" v-bind:class="{ pipelinetypeactive: createPipeline.pipeline.type === 'cpp' }" data-tippy-hideOnClick="false">
81+
<img src="~assets/cpp.png" class="typeimage">
8282
</div>
8383
<div class="pipelinetype" title="Node.js (not yet supported)" v-tippy="{ arrow : true, animation : 'shift-away'}" v-bind:class="{ pipelinetypeactive: createPipeline.pipeline.type === 'nodejs' }" data-tippy-hideOnClick="false">
8484
<img src="~assets/nodejs.png" class="typeimage typeimagenotyetsupported">
@@ -108,7 +108,7 @@
108108
<div v-else-if="props.row.statustype === 'success'" style="color: green;">{{ props.row.statustype }}</div>
109109
<div v-else style="color: red;">{{ props.row.statustype }}</div>
110110
</td>
111-
<td>{{ props.row.pipeline.type }}</td>
111+
<td>{{ prettifyPipelineType(props.row.pipeline.type) }}</td>
112112
<td :title="props.row.created" v-tippy="{ arrow : true, animation : 'shift-away'}">{{ convertTime(props.row.created) }}</td>
113113
<td>
114114
<a class="button is-green-button is-small" @click="showStatusOutputModal(props.row.output)">
@@ -529,6 +529,13 @@ export default {
529529
this.statusOutputModal = false
530530
this.statusOutputMsg = ''
531531
this.$emit('close')
532+
},
533+
534+
prettifyPipelineType (type) {
535+
if (type === 'cpp') {
536+
return 'C++'
537+
}
538+
return type
532539
}
533540
}
534541
}

gaia.go

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ const (
3434
// PTypePython python plugin type
3535
PTypePython PipelineType = "python"
3636

37+
// PTypeCpp C++ plugin type
38+
PTypeCpp PipelineType = "cpp"
39+
3740
// CreatePipelineFailed status
3841
CreatePipelineFailed CreatePipelineType = "failed"
3942

@@ -90,6 +93,9 @@ const (
9093

9194
// TmpGoFolder is the name of the golang temporary folder
9295
TmpGoFolder = "golang"
96+
97+
// TmpCppFolder is the name of the c++ temporary folder
98+
TmpCppFolder = "cpp"
9399
)
94100

95101
// User is the user object

handlers/user.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func UserLogin(c echo.Context) error {
3333
// Authenticate user
3434
user, err := storeService.UserAuth(u, true)
3535
if err != nil || user == nil {
36-
gaia.Cfg.Logger.Error("invalid credentials provided", "message", err.Error())
36+
gaia.Cfg.Logger.Info("invalid credentials provided", "username", u.Username)
3737
return c.String(http.StatusForbidden, "invalid username and/or password")
3838
}
3939

0 commit comments

Comments
 (0)