Skip to content

Commit

Permalink
Merge pull request 'FIX: conflict between reconcile and heatbeat.' (#…
Browse files Browse the repository at this point in the history
…41) from fix-loop into master

Reviewed-on: https://gitea:3000/AVENTER/mesos-compose/pulls/41
  • Loading branch information
Andreas Peters committed Sep 29, 2023
2 parents d34a183 + 38fbe36 commit e0c8207
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{ "version":"v0.4.2", "builddate":"2023-08-25T21:20:56Z" }]
[{ "version":"v0.4.2", "builddate":"2023-09-11T19:36:21Z" }]
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ FROM alpine
LABEL maintainer="Andreas Peters <support@aventer.biz>"

RUN apk add --no-cache ca-certificates
RUN apk update
RUN apk upgrade
RUN adduser -S -D -H -h /app appuser

USER appuser
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 13 additions & 2 deletions docs/example/vault.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
9 changes: 5 additions & 4 deletions scheduler/heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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()
}
}

0 comments on commit e0c8207

Please sign in to comment.