Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored Gaia parameters #198

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions .circleci/images/primary/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
FROM python:2.7-stretch

# Version and other variables which can be changed.
ENV GAIA_PORT=8080 \
GAIA_WORKER=2 \
GAIA_HOMEPATH=/data

# CircleCI required tools
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
Expand All @@ -24,20 +19,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
&& rm -rf /var/lib/apt/lists/*

ENV GOLANG_VERSION 1.12.5
ENV GOLANG_VERSION 1.12.7

RUN set -eux; \
\
# this "case" statement is generated via "update.sh"
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) goRelArch='linux-amd64'; goRelSha256='aea86e3c73495f205929cfebba0d63f1382c8ac59be081b6351681415f4063cf' ;; \
armhf) goRelArch='linux-armv6l'; goRelSha256='311f5e76c7cec1ec752474a61d837e474b8e750b8e3eed267911ab57c0e5da9a' ;; \
arm64) goRelArch='linux-arm64'; goRelSha256='ff09f34935cd189a4912f3f308ec83e4683c309304144eae9cf60ebc552e7cd8' ;; \
i386) goRelArch='linux-386'; goRelSha256='146605e13bf337ff3aacd941a816c5d97a8fef8b5817e07fcec4540632085980' ;; \
ppc64el) goRelArch='linux-ppc64le'; goRelSha256='e88b2a2098bc79ad33912d1d27bc3282a7f3231b6f4672f306465bf46ff784ca' ;; \
s390x) goRelArch='linux-s390x'; goRelSha256='168d297ec910cb446d1aea878baeb85f1387209f9eb55dde68bddcd4c006dcbb' ;; \
*) goRelArch='src'; goRelSha256='2aa5f088cbb332e73fc3def546800616b38d3bfe6b8713b8a6404060f22503e8'; \
amd64) goRelArch='linux-amd64'; goRelSha256='66d83bfb5a9ede000e33c6579a91a29e6b101829ad41fffb5c5bb6c900e109d9' ;; \
armhf) goRelArch='linux-armv6l'; goRelSha256='48edbe936e9eb74f259bfc4b621fafca4d4ec43156b4ee7bd0d979f257dcd60a' ;; \
arm64) goRelArch='linux-arm64'; goRelSha256='4da1f7198a8fa0c4067852656b6c10153a4eca5a26aca28ef02ae9f4a7939ba5' ;; \
i386) goRelArch='linux-386'; goRelSha256='ae2424b7ff557a708be12d3141f25b645966489ca49af1ad10b4fbe4c97d4c41' ;; \
ppc64el) goRelArch='linux-ppc64le'; goRelSha256='8eda20600d90247efbfa70d116d80056e11192d62592240975b2a8c53caa5bf3' ;; \
s390x) goRelArch='linux-s390x'; goRelSha256='3374ac3d646555e50be790091b51849319cfcb176904048458c7f4252337fce8' ;; \
*) goRelArch='src'; goRelSha256='95e8447d6f04b8d6a62de1726defbb20ab203208ee167ed15f83d7978ce43b13'; \
echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \
esac; \
\
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ TEST_TIMEOUT?=20s
default: dev

dev:
go run ./cmd/gaia/main.go -homepath=${PWD}/tmp -dev=true
go run ./cmd/gaia/main.go -home-path=${PWD}/tmp -dev=true

compile_frontend:
cd ./frontend && \
Expand Down Expand Up @@ -52,4 +52,4 @@ kube-ingress-lb:
kubectl apply -R -f ${HELM_DIR}/_system

lint:
golint -set_exit_status ./...
golint -set_exit_status ./...
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Manually
It is possible to install Gaia directly on the host system.
This can be achieved by downloading the binary from the `releases page`_.

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.
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 *-home-path* if you want.

Using helm
~~~~~~~~~~
Expand Down
23 changes: 11 additions & 12 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
FROM python:2.7-stretch

# Version and other variables which can be changed.
# Set env variables
ENV GAIA_PORT=8080 \
GAIA_WORKER=2 \
GAIA_HOMEPATH=/data
GAIA_HOME_PATH=/data

# --------------- Start Go Part ---------------
# gcc for cgo
Expand All @@ -15,20 +14,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
&& rm -rf /var/lib/apt/lists/*

ENV GOLANG_VERSION 1.11.4
ENV GOLANG_VERSION 1.12.7

RUN set -eux; \
\
# this "case" statement is generated via "update.sh"
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) goRelArch='linux-amd64'; goRelSha256='fb26c30e6a04ad937bbc657a1b5bba92f80096af1e8ee6da6430c045a8db3a5b' ;; \
armhf) goRelArch='linux-armv6l'; goRelSha256='9f7a71d27fef69f654a93e265560c8d9db1a2ca3f1dcdbe5288c46facfde5821' ;; \
arm64) goRelArch='linux-arm64'; goRelSha256='b76df430ba8caff197b8558921deef782cdb20b62fa36fa93f81a8c08ab7c8e7' ;; \
i386) goRelArch='linux-386'; goRelSha256='cecd2da1849043237d5f0756a93d601db6798fa3bb27a14563d201088aa415f3' ;; \
ppc64el) goRelArch='linux-ppc64le'; goRelSha256='1f10146826acd56716b00b9188079af53823ddd79ceb6362e78e2f3aafb370ab' ;; \
s390x) goRelArch='linux-s390x'; goRelSha256='4467442dacf89eb94c5d6f9f700204cb360be82db60e6296cc2ef8d0e890cd42' ;; \
*) goRelArch='src'; goRelSha256='4cfd42720a6b1e79a8024895fa6607b69972e8e32446df76d6ce79801bbadb15'; \
amd64) goRelArch='linux-amd64'; goRelSha256='66d83bfb5a9ede000e33c6579a91a29e6b101829ad41fffb5c5bb6c900e109d9' ;; \
armhf) goRelArch='linux-armv6l'; goRelSha256='48edbe936e9eb74f259bfc4b621fafca4d4ec43156b4ee7bd0d979f257dcd60a' ;; \
arm64) goRelArch='linux-arm64'; goRelSha256='4da1f7198a8fa0c4067852656b6c10153a4eca5a26aca28ef02ae9f4a7939ba5' ;; \
i386) goRelArch='linux-386'; goRelSha256='ae2424b7ff557a708be12d3141f25b645966489ca49af1ad10b4fbe4c97d4c41' ;; \
ppc64el) goRelArch='linux-ppc64le'; goRelSha256='8eda20600d90247efbfa70d116d80056e11192d62592240975b2a8c53caa5bf3' ;; \
s390x) goRelArch='linux-s390x'; goRelSha256='3374ac3d646555e50be790091b51849319cfcb176904048458c7f4252337fce8' ;; \
*) goRelArch='src'; goRelSha256='95e8447d6f04b8d6a62de1726defbb20ab203208ee167ed15f83d7978ce43b13'; \
echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \
esac; \
\
Expand Down Expand Up @@ -307,7 +306,7 @@ RUN chmod +x ./gaia-linux-amd64 \
&& chmod 600 /root/.ssh

# Set homepath as volume
VOLUME [ "${GAIA_HOMEPATH}" ]
VOLUME [ "${GAIA_HOME_PATH}" ]

# Expose port
EXPOSE ${GAIA_PORT}
Expand Down
8 changes: 4 additions & 4 deletions docker/Dockerfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ RUN apt-get update && apt-get install -y \
automake libtool curl make g++ unzip \
&& apt-get clean

# install protobuf first, then grpc
ENV GRPC_RELEASE_TAG v1.16.x
# install protobuf first, then grpc
ENV GRPC_RELEASE_TAG v1.16.x
RUN git clone -b ${GRPC_RELEASE_TAG} https://github.com/grpc/grpc /var/local/git/grpc && \
cd /var/local/git/grpc && \
git submodule update --init && \
Expand All @@ -20,7 +20,7 @@ RUN git clone -b ${GRPC_RELEASE_TAG} https://github.com/grpc/grpc /var/local/git

# Gaia internal port and data path.
ENV GAIA_PORT=8080 \
GAIA_HOMEPATH=/data
GAIA_HOME_PATH=/data

# Directory for the binary
WORKDIR /app
Expand All @@ -35,7 +35,7 @@ RUN chmod +x ./gaia-linux-amd64 \
&& chmod 600 /root/.ssh

# Set homepath as volume
VOLUME [ "${GAIA_HOMEPATH}" ]
VOLUME [ "${GAIA_HOME_PATH}" ]

# Expose port
EXPOSE ${GAIA_PORT}
Expand Down
7 changes: 3 additions & 4 deletions docker/Dockerfile.golang
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
FROM golang:1.11.4-alpine3.8
FROM golang:1.12.7-alpine3.8

# Version and other variables which can be changed.
ENV GAIA_PORT=8080 \
GAIA_WORKER=2 \
GAIA_HOMEPATH=/data
GAIA_HOME_PATH=/data

# Directory for the binary
WORKDIR /app
Expand All @@ -20,7 +19,7 @@ RUN chmod +x ./gaia-linux-amd64 \
&& chmod 600 /root/.ssh

# Set homepath as volume
VOLUME [ "${GAIA_HOMEPATH}" ]
VOLUME [ "${GAIA_HOME_PATH}" ]

# Expose port
EXPOSE ${GAIA_PORT}
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

# Version and other variables which can be changed.
ENV GAIA_PORT=8080 \
GAIA_WORKER=2 \
GAIA_HOMEPATH=/data
GAIA_HOME_PATH=/data

# Directory for the binary
WORKDIR /app
Expand All @@ -18,7 +17,7 @@
&& chmod 600 /root/.ssh

# Set homepath as volume
VOLUME [ "${GAIA_HOMEPATH}" ]
VOLUME [ "${GAIA_HOME_PATH}" ]

# Expose port
EXPOSE ${GAIA_PORT}
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.nodejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ FROM node:11.15.0-stretch

# Version and other variables which can be changed.
ENV GAIA_PORT=8080 \
GAIA_WORKER=2 \
GAIA_HOMEPATH=/data
GAIA_HOME_PATH=/data

# Directory for the binary
WORKDIR /app
Expand All @@ -18,7 +17,7 @@ RUN chmod +x ./gaia-linux-amd64 \
&& chmod 600 /root/.ssh

# Set homepath as volume
VOLUME [ "${GAIA_HOMEPATH}" ]
VOLUME [ "${GAIA_HOME_PATH}" ]

# Expose port
EXPOSE ${GAIA_PORT}
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.python
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ FROM python:2.7-alpine3.8

# Version and other variables which can be changed.
ENV GAIA_PORT=8080 \
GAIA_WORKER=2 \
GAIA_HOMEPATH=/data
GAIA_HOME_PATH=/data

# install additional deps
RUN set -ex; \
Expand All @@ -23,7 +22,7 @@ RUN chmod +x ./gaia-linux-amd64 \
&& chmod 600 /root/.ssh

# Set homepath as volume
VOLUME [ "${GAIA_HOMEPATH}" ]
VOLUME [ "${GAIA_HOME_PATH}" ]

# Expose port
EXPOSE ${GAIA_PORT}
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.ruby
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ FROM ruby:2.5.3-stretch

# Version and other variables which can be changed.
ENV GAIA_PORT=8080 \
GAIA_WORKER=2 \
GAIA_HOMEPATH=/data
GAIA_HOME_PATH=/data

# Directory for the binary
WORKDIR /app
Expand All @@ -18,7 +17,7 @@ RUN chmod +x ./gaia-linux-amd64 \
&& chmod 600 /root/.ssh

# Set homepath as volume
VOLUME [ "${GAIA_HOMEPATH}" ]
VOLUME [ "${GAIA_HOME_PATH}" ]

# Expose port
EXPOSE ${GAIA_PORT}
Expand Down
2 changes: 1 addition & 1 deletion helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:
env:
- name: GAIA_PORT
value: "8080"
- name: GAIA_HOSTNAME
- name: GAIA_HOST_NAME
value: http:0.0.0.0
ports:
- containerPort: 8080
Expand Down
42 changes: 22 additions & 20 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,25 @@ func init() {
fs.String("config", ".gaia_config", "this describes the name of the config file to use")

// command line arguments
fs.StringVar(&gaia.Cfg.ListenPort, "port", "8080", "Listen port for gaia")
fs.StringVar(&gaia.Cfg.HomePath, "homepath", "", "Path to the gaia home folder")
fs.StringVar(&gaia.Cfg.Hostname, "hostname", "https://localhost", "The host's name under which gaia is deployed at e.g.: https://gaia-pipeline.com")
fs.StringVar(&gaia.Cfg.VaultPath, "vaultpath", "", "Path to the gaia vault folder")
fs.IntVar(&gaia.Cfg.Worker, "worker", 2, "Number of worker gaia will use to execute pipelines in parallel")
fs.StringVar(&gaia.Cfg.JwtPrivateKeyPath, "jwtPrivateKeyPath", "", "A RSA private key used to sign JWT tokens")
fs.StringVar(&gaia.Cfg.CAPath, "capath", "", "Folder path where the generated CA certificate files will be saved")
fs.BoolVar(&gaia.Cfg.DevMode, "dev", false, "If true, gaia will be started in development mode. Don't use this in production!")
fs.StringVar(&gaia.Cfg.ListenPort, "port", "8080", "Listen port for Gaia")
fs.StringVar(&gaia.Cfg.HomePath, "home-path", "", "Path to the Gaia home folder where all data will be stored")
fs.StringVar(&gaia.Cfg.Hostname, "hostname", "https://localhost", "The host's name under which Gaia is deployed at e.g.: https://gaia-pipeline.io")
fs.StringVar(&gaia.Cfg.VaultPath, "vault-path", "", "Path to the Gaia vault folder. By default, will be stored inside the home folder")
fs.IntVar(&gaia.Cfg.Worker, "concurrent-worker", 2, "Number of concurrent worker the Gaia instance will use to execute pipelines in parallel")
fs.StringVar(&gaia.Cfg.JwtPrivateKeyPath, "jwt-private-key-path", "", "A RSA private key used to sign JWT tokens used for Web UI authentication")
fs.StringVar(&gaia.Cfg.CAPath, "ca-path", "", "Path where the generated CA certificate files will be saved")
fs.BoolVar(&gaia.Cfg.DevMode, "dev", false, "If true, Gaia will be started in development mode. Don't use this in production!")
fs.BoolVar(&gaia.Cfg.VersionSwitch, "version", false, "If true, will print the version and immediately exit")
fs.BoolVar(&gaia.Cfg.Poll, "poll", false, "Instead of using a Webhook, keep polling git for changes on pipelines")
fs.IntVar(&gaia.Cfg.PVal, "pval", 1, "The interval in minutes in which to poll vcs for changes")
fs.StringVar(&gaia.Cfg.ModeRaw, "mode", "server", "The mode in which gaia should be started. Possible options are server and worker")
fs.StringVar(&gaia.Cfg.WorkerName, "workername", "", "The name of the worker which will be displayed at the primary instance")
fs.StringVar(&gaia.Cfg.WorkerHostURL, "hosturl", "http://localhost:8080", "The host url of an gaia instance to connect to. Only used in worker mode")
fs.StringVar(&gaia.Cfg.WorkerGRPCHostURL, "grpchosturl", "localhost:8989", "The host url of an gaia instance gRPC interface used for worker connection. Only used in worker mode")
fs.StringVar(&gaia.Cfg.WorkerSecret, "workersecret", "", "The secret which is used to register a worker at an gaia instance")
fs.StringVar(&gaia.Cfg.WorkerServerPort, "workerserverport", "8989", "Listen port for gaia worker gRPC communication")
fs.StringVar(&gaia.Cfg.WorkerTags, "workertags", "", "Comma separated list of custom tags for this worker")
fs.BoolVar(&gaia.Cfg.PreventPrimaryWork, "preventprimarywork", false, "If true, prevents the scheduler to schedule work on this Gaia primary instance")
fs.BoolVar(&gaia.Cfg.Poll, "pipeline-poll", false, "If true, Gaia will periodically poll pipeline repositories, watch for changes and rebuild them accordingly")
fs.IntVar(&gaia.Cfg.PVal, "pipeline-poll-interval", 1, "The interval in minutes in which to poll source repositories for changes")
fs.StringVar(&gaia.Cfg.ModeRaw, "mode", "server", "The mode which Gaia should be started in. Possible options are server and worker")
fs.StringVar(&gaia.Cfg.WorkerName, "worker-name", "", "The name of the worker which will be displayed at the primary instance. Only used in worker mode")
fs.StringVar(&gaia.Cfg.WorkerHostURL, "worker-host-url", "http://localhost:8080", "The host url of an Gaia primary instance to connect to. Only used in worker mode")
fs.StringVar(&gaia.Cfg.WorkerGRPCHostURL, "worker-grpc-host-url", "localhost:8989", "The host url of an Gaia primary instance gRPC interface used for worker connection. Only used in worker mode")
fs.StringVar(&gaia.Cfg.WorkerSecret, "worker-secret", "", "The secret which is used to register a worker at an Gaia primary instance. Only used in worker mode")
fs.StringVar(&gaia.Cfg.WorkerServerPort, "worker-server-port", "8989", "Listen port for Gaia primary worker gRPC communication. Only used in server mode")
fs.StringVar(&gaia.Cfg.WorkerTags, "worker-tags", "", "Comma separated list of custom tags for this worker. Only used in worker mode")
fs.BoolVar(&gaia.Cfg.PreventPrimaryWork, "prevent-primary-work", false, "If true, prevents the scheduler to schedule work on this Gaia primary instance. Only used in server mode")

// Default values
gaia.Cfg.Bolt.Mode = 0600
Expand All @@ -74,7 +74,9 @@ func init() {
// Start initiates all components of Gaia and starts the server/agent.
func Start() (err error) {
// Parse command line flags
_ = fs.Parse(os.Args[1:])
if err := fs.Parse(os.Args[1:]); err.Error() == "flag: help requested" {
return nil
}

// Check version switch
if gaia.Cfg.VersionSwitch {
Expand Down Expand Up @@ -102,7 +104,7 @@ func Start() (err error) {

// Find path for gaia home folder if not given by parameter
if gaia.Cfg.HomePath == "" {
// Find executeable path
// Find executable path
execPath, err := findExecutablePath()
if err != nil {
gaia.Cfg.Logger.Error("cannot find executeable path", "error", err.Error())
Expand Down