From 80239913d8690d859031dcdcdd2c734265524ecb Mon Sep 17 00:00:00 2001 From: frikky Date: Sat, 12 Mar 2022 13:18:58 +0100 Subject: [PATCH] Fixed log overloads and docker host proxies for worker and orborus --- functions/onprem/orborus/orborus.go | 23 ++++++++++++++++++----- functions/onprem/worker/worker.go | 18 ++++++++++++++---- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/functions/onprem/orborus/orborus.go b/functions/onprem/orborus/orborus.go index 5294b764..8c5327e2 100644 --- a/functions/onprem/orborus/orborus.go +++ b/functions/onprem/orborus/orborus.go @@ -353,6 +353,12 @@ func deployServiceWorkers(image string) { Resources: &swarm.ResourceRequirements{ Reservations: &swarm.Resources{}, }, + LogDriver: &swarm.Driver{ + Name: "json-file", + Options: map[string]string{ + "max-size": "10m", + }, + }, ContainerSpec: &swarm.ContainerSpec{ Image: image, Env: []string{ @@ -449,13 +455,16 @@ func deployWorker(image string, identifier string, env []string, executionReques //CPUShares: 256, hostConfig := &container.HostConfig{ LogConfig: container.LogConfig{ - Type: "json-file", - Config: map[string]string{}, + Type: "json-file", + Config: map[string]string{ + "max-size": "10m", + }, }, Resources: container.Resources{}, - Binds: []string{ - "/var/run/docker.sock:/var/run/docker.sock:rw", - }, + } + + if len(os.Getenv("DOCKER_HOST")) == 0 { + hostConfig.Binds = []string{"/var/run/docker.sock:/var/run/docker.sock:rw"} } hostConfig.NetworkMode = container.NetworkMode(fmt.Sprintf("container:%s", containerId)) @@ -1035,6 +1044,10 @@ func main() { env = append(env, fmt.Sprintf("DOCKER_API_VERSION=%s", dockerApiVersion)) } + if len(os.Getenv("DOCKER_HOST")) > 0 { + env = append(env, fmt.Sprintf("DOCKER_HOST=%s", os.Getenv("DOCKER_HOST"))) + } + err = deployWorker(workerImage, containerName, env, execution) zombiecounter += 1 if err == nil { diff --git a/functions/onprem/worker/worker.go b/functions/onprem/worker/worker.go index e421844a..d7a5d6e4 100644 --- a/functions/onprem/worker/worker.go +++ b/functions/onprem/worker/worker.go @@ -299,8 +299,10 @@ func deployApp(cli *dockerclient.Client, image string, identifier string, env [] //CPUPeriod: 100000, hostConfig := &container.HostConfig{ LogConfig: container.LogConfig{ - Type: "json-file", - Config: map[string]string{}, + Type: "json-file", + Config: map[string]string{ + "max-size": "10m", + }, }, Resources: container.Resources{}, } @@ -440,8 +442,10 @@ func DeployContainer(ctx context.Context, cli *dockerclient.Client, config *cont identifier = fmt.Sprintf("%s-%s-nonetwork", identifier, parsedUuid) hostConfig = &container.HostConfig{ LogConfig: container.LogConfig{ - Type: "json-file", - Config: map[string]string{}, + Type: "json-file", + Config: map[string]string{ + "max-size": "10m", + }, }, Resources: container.Resources{}, } @@ -2628,6 +2632,12 @@ func deploySwarmService(dockercli *dockerclient.Client, name, image string, depl Resources: &swarm.ResourceRequirements{ Reservations: &swarm.Resources{}, }, + LogDriver: &swarm.Driver{ + Name: "json-file", + Options: map[string]string{ + "max-size": "10m", + }, + }, ContainerSpec: &swarm.ContainerSpec{ Image: image, Env: []string{