From 38fbe3652d2eb1e893a62485a65942329ae8f999 Mon Sep 17 00:00:00 2001 From: Andreas Peters Date: Fri, 29 Sep 2023 11:19:59 +0200 Subject: [PATCH] FIX: conflict between reconcile and heatbeat. --- .version.json | 2 +- Dockerfile | 2 ++ changelog.md | 1 + docs/example/vault.yaml | 15 +++++++++++++-- init.go | 2 +- scheduler/heartbeat.go | 9 +++++---- 6 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.version.json b/.version.json index 8734926..2c70f93 100644 --- a/.version.json +++ b/.version.json @@ -1 +1 @@ -[{ "version":"v0.4.2", "builddate":"2023-08-25T21:20:56Z" }] +[{ "version":"v0.4.2", "builddate":"2023-09-11T19:36:21Z" }] diff --git a/Dockerfile b/Dockerfile index 6bc2983..059bc4b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,8 @@ FROM alpine LABEL maintainer="Andreas Peters " RUN apk add --no-cache ca-certificates +RUN apk update +RUN apk upgrade RUN adduser -S -D -H -h /app appuser USER appuser diff --git a/changelog.md b/changelog.md index 70bfb0d..e527e35 100644 --- a/changelog.md +++ b/changelog.md @@ -29,6 +29,7 @@ - CHANGE: Change the discovery name format to fit the DNS RFC. - ADD: Better support for mesos containerizer (thanks to @harryzz) - ADD: Command Attributes (thanks to @harryzz) +- FIX: Conflict between reconcile and heatbeat could end in a task restart loop ## 0.4.2 diff --git a/docs/example/vault.yaml b/docs/example/vault.yaml index 143b20f..3b696bc 100644 --- a/docs/example/vault.yaml +++ b/docs/example/vault.yaml @@ -1,12 +1,23 @@ version: "3.9" services: vault-server1: - image: vault:latest + image: hashicorp/vault:latest environment: VAULT_ADDR: "http://0.0.0.0:8200" VAULT_DEV_ROOT_TOKEN_ID: vault-plaintext-root-token mesos: task_name: "vault:vault-server" - network_mode: "host" + network_mode: "bridge" + network: default + restart: unless-stopped + + vault-server2: + image: hashicorp/vault:latest + environment: + VAULT_ADDR: "http://0.0.0.0:8200" + VAULT_DEV_ROOT_TOKEN_ID: vault-plaintext-root-token + mesos: + task_name: "vault:vault-server" + network_mode: "bridge" network: default restart: unless-stopped diff --git a/init.go b/init.go index a60eb75..a4642b2 100644 --- a/init.go +++ b/init.go @@ -38,7 +38,7 @@ func init() { config.Credentials.Username = util.Getenv("AUTH_USERNAME", "") config.Credentials.Password = util.Getenv("AUTH_PASSWORD", "") config.AppName = "Mesos Compose Framework" - config.ReconcileLoopTime, _ = time.ParseDuration(util.Getenv("RECONCILE_WAIT", "10m")) + config.ReconcileLoopTime, _ = time.ParseDuration(util.Getenv("RECONCILE_WAIT", "30m")) config.RedisServer = util.Getenv("REDIS_SERVER", "127.0.0.1:6379") config.RedisPassword = util.Getenv("REDIS_PASSWORD", "") config.RedisDB, _ = strconv.Atoi(util.Getenv("REDIS_DB", "1")) diff --git a/scheduler/heartbeat.go b/scheduler/heartbeat.go index 3917b76..d1ec727 100644 --- a/scheduler/heartbeat.go +++ b/scheduler/heartbeat.go @@ -31,14 +31,15 @@ func (e *Scheduler) Heartbeat() { continue } - // kill task and remove it from DB + // kill task if task.State == "__KILL" { // if agent is unset, the task is not running we can just delete the DB key if task.Agent == "" { e.Redis.DelRedisKey(task.TaskName + ":" + task.TaskID) } else { + task.Restart = "no" + e.Redis.SaveTaskRedis(task) e.Mesos.Kill(task.TaskID, task.Agent) - e.Redis.DelRedisKey(task.TaskName + ":" + task.TaskID) } continue } @@ -119,7 +120,7 @@ func (e *Scheduler) ReconcileLoop() { ticker := time.NewTicker(e.Config.ReconcileLoopTime) defer ticker.Stop() for ; true; <-ticker.C { - go e.reconcile() - go e.implicitReconcile() + e.reconcile() + e.implicitReconcile() } }