marathon icon indicating copy to clipboard operation
marathon copied to clipboard

Marathon treats working tasks as unhealthy and kills them

Open IharKrasnik opened this issue 10 years ago • 23 comments

Hi, I have a bunch of applications deployed in dockers on Mesos (v0.22.1) and Marathon (v0.9.0). Sometimes services restarting in Mesos (completed tasks status is KILLED).

Services use HTTP health checks (intervalSeconds = 30, maxConsecutiveFailures = 3, timeoutSeconds = 20). It happens randomly and sometimes I even can see when task turns red at Marathon UI even so http check works well in browser (so service is healthy) and then Marathon kills and restart service that impacts overall system performance.

Log: I1223 12:23:45.058763 32718 slave.cpp:1581] Asked to kill task prod-tracker-backend-processor.63dbfa9b-a965-11e5-a046-e24e 30c7374f of framework 20150527-135958-3712123914-5050-2238-0000

I1223 12:23:45.189750 32720 slave.cpp:2531] Handling status update TASK_KILLED (UUID: 09e76bce-f24c-4999-8933-270baf023c62 ) for task prod-tracker-backend-processor.63dbfa9b-a965-11e5-a046-e24e30c7374f of framework 20150527-135958-3712123914-505 0-2238-0000 from executor(1)@10.132.66.219:33503

I1223 12:23:45.214113 32718 docker.cpp:1009] Updated 'cpu.shares' to 102 at /sys/fs/cgroup/cpu/docker/9e0bc3b40ad9b37c4a0f 6133ca1316c2addd2e2c5a7941e56a4e1770d7afd3a2 for container 9dad82a5-34e1-4bf9-a641-17129464a226

W1223 12:23:45.214740 32718 docker.cpp:1021] Container 9dad82a5-34e1-4bf9-a641-17129464a226 does not appear to be a member of a cgroup where the 'memory' subsystem is mounted

I1223 12:23:45.216114 32724 status_update_manager.cpp:317] Received status update TASK_KILLED (UUID: 09e76bce-f24c-4999-89 33-270baf023c62) for task prod-tracker-backend-processor.63dbfa9b-a965-11e5-a046-e24e30c7374f of framework 20150527-135958 -3712123914-5050-2238-0000

I1223 12:23:45.216359 32724 status_update_manager.hpp:346] Checkpointing UPDATE for status update TASK_KILLED (UUID: 09e76 bce-f24c-4999-8933-270baf023c62) for task prod-tracker-backend-processor.63dbfa9b-a965-11e5-a046-e24e30c7374f of framework 20150527-135958-3712123914-5050-2238-0000

I1223 12:23:45.221278 32720 slave.cpp:2776] Forwarding the update TASK_KILLED (UUID: 09e76bce-f24c-4999-8933-270baf023c62) for task prod-tracker-backend-processor.63dbfa9b-a965-11e5-a046-e24e30c7374f of framework 20150527-135958-3712123914-5050 -2238-0000 to [email protected]:5050

I1223 12:23:45.222024 32720 slave.cpp:2709] Sending acknowledgement for status update TASK_KILLED (UUID: 09e76bce-f24c-499 9-8933-270baf023c62) for task prod-tracker-backend-processor.63dbfa9b-a965-11e5-a046-e24e30c7374f of framework 20150527-13 5958-3712123914-5050-2238-0000 to executor(1)@10.132.66.219:33503

I1223 12:23:45.233886 32725 status_update_manager.cpp:389] Received status update acknowledgement (UUID: 09e76bce-f24c-499 9-8933-270baf023c62) for task prod-tracker-backend-processor.63dbfa9b-a965-11e5-a046-e24e30c7374f of framework 20150527-13 5958-3712123914-5050-2238-0000

IharKrasnik avatar Dec 23 '15 14:12 IharKrasnik

A lot has changed since Marathon v0.9.0. Does this also happen with a more recent version?

HTTP health checks are performed by the Marathon leader. It would be useful to get the Marathon logs corresponding to the failing health checks.

gkleiman avatar Dec 29 '15 17:12 gkleiman

@gkleiman thanks for reply, I am migrating to the newer marathon and mesos versions now Where can I find Marathon logs?

IharKrasnik avatar Jan 05 '16 16:01 IharKrasnik

@IharKrasnik by default Marathon will log to stdout, but depending your configuration you might also find the logs somewhere in /var/log/

gkleiman avatar Jan 05 '16 16:01 gkleiman

@IharKrasnik I'm looking at this in relation to another issue. Are you still seeing the problem?

jgarcia-mesosphere avatar Feb 09 '16 00:02 jgarcia-mesosphere

@jgarcia-mesosphere hi, yes I still have this issue but only with Marathon 0.9.0 + Mesos 0.22.1. The newer cluster with Marathon 0.13.0 and Mesos 0.26.0 seems to be ok

IharKrasnik avatar Feb 09 '16 09:02 IharKrasnik

I have the same issue on RHEL7 system. Basically at random times the container is getting killed and a message is getting thrown out in the log as "...slave.cpp:1890] Asked to kill task....". Does anybody know if there is a possible solution discussed somewhere? Below is my current setup: Marathon: 0.15.0 Mesos: 0.27.0 Docker: 1.7.1

mdulla avatar Apr 25 '16 21:04 mdulla

+1 same problem :(

Our environment looks like this:

  • CentOS 7
  • Marathon: 0.15.2
  • Mesos: 0.28.1
  • Docker: 1.10.3

Our Observations

Services running inside docker are killed and restarted, when they do number crunching and/or are close to the memory limit for a few minutes.1

background information

  • typically we have Java microservices, e.g. running with memory limit "-Xmx512m"
    • the service is doing weather forecast, which just consumes ~400m Heap and runs ~3 hours on a macbook
    • BUT after ~3minutes marathon will kill/restart
    • during the number crunching the /health response times are within range 100ms ... 1200ms, always "200 OK"
  • we set marathon / docker limits to "--memory=512m"
    • we also tried marathon / docker limit set to "--memory=600m" ==> same issue, but happens later
  • we set marathon "CPU=0.1"

Marathon Configuration

Health Checks configuration

[
  {
    "path": "/health",
    "protocol": "HTTP",
    "portIndex": 0,
    "gracePeriodSeconds": 30,
    "intervalSeconds": 10,
    "timeoutSeconds": 180,
    "maxConsecutiveFailures": 6,
    "ignoreHttp1xx": false
  }
]

Any ideas, what to do to find the root cause?

nitram509 avatar Jul 07 '16 09:07 nitram509

+1 same issue

waswrongassembled avatar Jul 07 '16 10:07 waswrongassembled

+1

dnltsk avatar Jul 07 '16 10:07 dnltsk

+1

tomderuijter avatar Jul 07 '16 10:07 tomderuijter

+1

AP-GH avatar Jul 07 '16 10:07 AP-GH

+1

erikpetzold avatar Jul 07 '16 10:07 erikpetzold

+1 important

wavermartijn avatar Jul 07 '16 10:07 wavermartijn

@nitram509 can you please post the Marathon leader logs at the time that the task was killed?

One of the health checks probably timed out, making Marathon believe that the task was unhealthy.

If possible please also post the logs of the Mesos Slave on which the task was running.

gkleiman avatar Jul 07 '16 10:07 gkleiman

+1

baralc avatar Jul 07 '16 10:07 baralc

I'm afraid that I cannot help you without logs, so please post some logs instead of +1's ;-)

gkleiman avatar Jul 07 '16 10:07 gkleiman

@nitram509 with java mx and app mem both set to 512m you are certain to get tasks being killed. It is unclear if 600m is enough headroom for a java process. we commonly use 1.35x is a starting point which is just under 700m. You have to account for the JRE memory + heap + perm or metaspace. JNI etc will also have an impact... it also matters which version of Java you are running.

the difference in your scenario vs the original posts is it is highly possible you are having tasks killed by the OOM cgroup manager instead of marathon. If this is the case you will see OOM notifier is triggered for container in the journal logs of the agent the task was running on.

based on information you provided I would guess you are not seeing issues with marathon but require adjustments in your configuration. The logs should reveal this either way.

The original post by @IharKrasnik clearly shows the agent log being asked to kill the container. We need the marathon logs to diagnose that issue.

kensipe avatar Jul 07 '16 11:07 kensipe

I have gathered the marathon logs for @nitram509:

Jul  7 12:42:34 ip-10-4-1-10 marathon[941]: [2016-07-07 12:42:34,900] INFO Received health result for app [/haarp/air-quality-service/prod] version [2016-07-07T09:38:22.760Z]: [Healthy(haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd,2016-07-07T09:38:22.760Z,2016-07-07T12:42:34.900Z)] (mesosphere.marathon.health.HealthCheckActor:marathon-akka.actor.default-dispatcher-10)
Jul  7 12:42:44 ip-10-4-1-10 marathon[941]: [2016-07-07 12:42:44,921] INFO Received health result for app [/haarp/air-quality-service/prod] version [2016-07-07T09:38:22.760Z]: [Healthy(haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd,2016-07-07T09:38:22.760Z,2016-07-07T12:42:44.921Z)] (mesosphere.marathon.health.HealthCheckActor:marathon-akka.actor.default-dispatcher-20)
Jul  7 12:42:54 ip-10-4-1-10 marathon[941]: [2016-07-07 12:42:54,940] INFO Received health result for app [/haarp/air-quality-service/prod] version [2016-07-07T09:38:22.760Z]: [Healthy(haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd,2016-07-07T09:38:22.760Z,2016-07-07T12:42:54.940Z)] (mesosphere.marathon.health.HealthCheckActor:marathon-akka.actor.default-dispatcher-21)
Jul  7 12:43:04 ip-10-4-1-10 marathon[941]: [2016-07-07 12:43:04,963] INFO Received health result for app [/haarp/air-quality-service/prod] version [2016-07-07T09:38:22.760Z]: [Healthy(haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd,2016-07-07T09:38:22.760Z,2016-07-07T12:43:04.963Z)] (mesosphere.marathon.health.HealthCheckActor:marathon-akka.actor.default-dispatcher-10)
Jul  7 12:43:18 ip-10-4-1-10 marathon[941]: [2016-07-07 12:43:18,855] INFO Received health result for app [/haarp/air-quality-service/prod] version [2016-07-07T09:38:22.760Z]: [Unhealthy(haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd,2016-07-07T09:38:22.760Z,ConnectionAttemptFailedException: Connection attempt to 10.4.1.176:31478 failed,2016-07-07T12:43:18.855Z)] (mesosphere.marathon.health.HealthCheckActor:marathon-akka.actor.default-dispatcher-16)
Jul  7 12:43:19 ip-10-4-1-10 mesos-master[896]: I0707 12:43:19.160756  1646 master.cpp:4763] Status update TASK_FAILED (UUID: befdfd61-cb35-48a0-bca2-e069146ca3a7) for task haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd of framework 413348e3-a215-4a98-a517-8f3784d86691-0000 from slave 89a2da04-f31b-401c-84e9-71abbf621399-S9 at slave(1)@10.4.1.176:5051 (10.4.1.176)
Jul  7 12:43:19 ip-10-4-1-10 mesos-master[896]: I0707 12:43:19.160811  1646 master.cpp:4811] Forwarding status update TASK_FAILED (UUID: befdfd61-cb35-48a0-bca2-e069146ca3a7) for task haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd of framework 413348e3-a215-4a98-a517-8f3784d86691-0000
Jul  7 12:43:19 ip-10-4-1-10 mesos-master[896]: I0707 12:43:19.160887  1646 master.cpp:6421] Updating the state of task haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd of framework 413348e3-a215-4a98-a517-8f3784d86691-0000 (latest state: TASK_FAILED, status update state: TASK_FAILED)
Jul  7 12:43:19 ip-10-4-1-10 marathon[941]: [2016-07-07 12:43:19,161] INFO Received status update for task haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd: TASK_FAILED (Docker container run error: Container exited on error: exited with status 137) (mesosphere.marathon.MarathonScheduler$$EnhancerByGuice$$c6c05dfe:Thread-155280)
Jul  7 12:43:19 ip-10-4-1-10 marathon[941]: [2016-07-07 12:43:19,165] DEBUG Ignoring status for [haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd] with no health information (mesosphere.marathon.health.MarathonHealthCheckManager$$EnhancerByGuice$$f9adff8e:ForkJoinPool-2-worker-119)
Jul  7 12:43:19 ip-10-4-1-10 marathon[941]: [2016-07-07 12:43:19,165] INFO Sending event notification for task [haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd] of app [/haarp/air-quality-service/prod]: TASK_FAILED (mesosphere.marathon.core.task.update.impl.steps.PostToEventStreamStepImpl$$EnhancerByGuice$$176ee50:ForkJoinPool-2-worker-73)
Jul  7 12:43:19 ip-10-4-1-10 marathon[941]: [2016-07-07 12:43:19,166] INFO initiating a scale check for app [/haarp/air-quality-service/prod] after task [haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd}] terminated (mesosphere.marathon.core.task.update.impl.steps.ScaleAppUpdateStepImpl$$EnhancerByGuice$$b159d64b:ForkJoinPool-2-worker-73)
Jul  7 12:43:19 ip-10-4-1-10 mesos-master[896]: I0707 12:43:19.166882  1646 master.cpp:3918] Processing ACKNOWLEDGE call befdfd61-cb35-48a0-bca2-e069146ca3a7 for task haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd of framework 413348e3-a215-4a98-a517-8f3784d86691-0000 (marathon) at [email protected]:59403 on slave 89a2da04-f31b-401c-84e9-71abbf621399-S9
Jul  7 12:43:19 ip-10-4-1-10 mesos-master[896]: I0707 12:43:19.166919  1646 master.cpp:6487] Removing task haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd with resources cpus(*):0.1; mem(*):600; ports(*):[31478-31479] of framework 413348e3-a215-4a98-a517-8f3784d86691-0000 on slave 89a2da04-f31b-401c-84e9-71abbf621399-S9 at slave(1)@10.4.1.176:5051 (10.4.1.176)

Unfortunately I can only see the ConnectionAttemptFailedException from marathon master. The last healthy response was at 12:43:18 but one second later the task was updated to TASK_FAILED state. How comes this together with the health check configuration?

    "intervalSeconds": 10,
    "timeoutSeconds": 180,
    "maxConsecutiveFailures": 6,

The logs from the mesos agent regarding this task_id:

I0707 11:51:41.991942  4295 status_update_manager.cpp:824] Checkpointing ACK for status update TASK_RUNNING (UUID: 150e9b01-afea-4769-97b4-9b0539f46e8a) for task haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd of framework 413348e3-a215-4a98-a517-8f3784d86691-0000

I0707 12:43:19.079092  4288 slave.cpp:3002] Handling status update TASK_FAILED (UUID: befdfd61-cb35-48a0-bca2-e069146ca3a7) for task haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd of framework 413348e3-a215-4a98-a517-8f3784d86691-0000 from executor(1)@10.4.1.176:35355
I0707 12:43:19.156324  4295 status_update_manager.cpp:320] Received status update TASK_FAILED (UUID: befdfd61-cb35-48a0-bca2-e069146ca3a7) for task haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd of framework 413348e3-a215-4a98-a517-8f3784d86691-0000
I0707 12:43:19.156390  4295 status_update_manager.cpp:824] Checkpointing UPDATE for status update TASK_FAILED (UUID: befdfd61-cb35-48a0-bca2-e069146ca3a7) for task haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd of framework 413348e3-a215-4a98-a517-8f3784d86691-0000
I0707 12:43:19.160081  4290 slave.cpp:3400] Forwarding the update TASK_FAILED (UUID: befdfd61-cb35-48a0-bca2-e069146ca3a7) for task haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd of framework 413348e3-a215-4a98-a517-8f3784d86691-0000 to [email protected]:5050
I0707 12:43:19.160192  4290 slave.cpp:3310] Sending acknowledgement for status update TASK_FAILED (UUID: befdfd61-cb35-48a0-bca2-e069146ca3a7) for task haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd of framework 413348e3-a215-4a98-a517-8f3784d86691-0000 to executor(1)@10.4.1.176:35355
I0707 12:43:19.167239  4295 status_update_manager.cpp:392] Received status update acknowledgement (UUID: befdfd61-cb35-48a0-bca2-e069146ca3a7) for task haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd of framework 413348e3-a215-4a98-a517-8f3784d86691-0000
I0707 12:43:19.167330  4295 status_update_manager.cpp:824] Checkpointing ACK for status update TASK_FAILED (UUID: befdfd61-cb35-48a0-bca2-e069146ca3a7) for task haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd of framework 413348e3-a215-4a98-a517-8f3784d86691-0000
I0707 12:43:20.163040  4295 slave.cpp:3886] Executor 'haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd' of framework 413348e3-a215-4a98-a517-8f3784d86691-0000 exited with status 0
I0707 12:43:20.163080  4295 slave.cpp:3990] Cleaning up executor 'haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd' of framework 413348e3-a215-4a98-a517-8f3784d86691-0000 at executor(1)@10.4.1.176:35355
I0707 12:43:20.163343  4291 gc.cpp:55] Scheduling '/var/lib/mesos/slaves/89a2da04-f31b-401c-84e9-71abbf621399-S9/frameworks/413348e3-a215-4a98-a517-8f3784d86691-0000/executors/haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd/runs/996f332c-7376-4ccb-8d91-513665c6d0bb' for gc 6.99999811042667days in the future
I0707 12:43:20.163404  4291 gc.cpp:55] Scheduling '/var/lib/mesos/slaves/89a2da04-f31b-401c-84e9-71abbf621399-S9/frameworks/413348e3-a215-4a98-a517-8f3784d86691-0000/executors/haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd' for gc 6.99999810962963days in the future
I0707 12:43:20.163439  4291 gc.cpp:55] Scheduling '/var/lib/mesos/meta/slaves/89a2da04-f31b-401c-84e9-71abbf621399-S9/frameworks/413348e3-a215-4a98-a517-8f3784d86691-0000/executors/haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd/runs/996f332c-7376-4ccb-8d91-513665c6d0bb' for gc 6.99999810916741days in the future
I0707 12:43:20.163475  4291 gc.cpp:55] Scheduling '/var/lib/mesos/meta/slaves/89a2da04-f31b-401c-84e9-71abbf621399-S9/frameworks/413348e3-a215-4a98-a517-8f3784d86691-0000/executors/haarp_air-quality-service_prod.2b2c3195-4439-11e6-8f67-02f576c4e3bd' for gc 6.99999810887704days in the future

@kensipe I will check if I can find something in the journal.

bogue1979 avatar Jul 07 '16 15:07 bogue1979

@bogue1979 what those logs show is that Marathon didn't kill the task, so the health checks are just a red herring and not the root cause of the termination. Marathon got a status update from Mesos saying that the task had failed, but it didn't initiate the kill.

I'd hope to find the root cause of the task failure in the Agent logs or in the task sandbox.

gkleiman avatar Jul 07 '16 15:07 gkleiman

@gkleiman Thank you for pointing in the right direction. Will investigate further.

bogue1979 avatar Jul 07 '16 15:07 bogue1979