tendrilinc / marathon-autoscaler

A simple autoscaler for Marathon applications
https://hub.docker.com/r/tendril/marathon-autoscaler/
Apache License 2.0
41 stars 16 forks source link

Not working with DCOS #39

Closed hassaanp closed 6 years ago

hassaanp commented 6 years ago

Hi,

I am trying out the autoscaler on DCOS. The autoscaler is up and running and can fetch data from mesos and marathon as expected. However, it is not scaling the applications.

i tried to add logs around the autoscaler to see what might be wrong. Apparently the application-definition always turns out to be empty {} so the is_app_participating function is always passed an empty dict app_def = ApplicationDefinition(metrics_summary.get("application_ returns null

My application's marathon JSON (condensed) is as follows: { "id": "/spark3", "backoffFactor": 1.15, "backoffSeconds": 1, "container": { "type": "DOCKER", "volumes": [], "docker": { "image": "mesosphere/spark:2.0.1-2.2.0-1-hadoop-2.6", "forcePullImage": true, "privileged": false, "parameters": [ { "key": "user", "value": "root" } ] } }, "cpus": 1, "disk": 0, "instances": 1, "labels": { "mas_rule_fastscaleup": "cpu | >50 | PT1M | 2 | PT1M30S", "min_instances": "1", "max_instances": "10", "use_marathon_autoscaler": "yes" } }

Is it something wrong here? Can you please point me in the right direction?

Thanks for the help.

hassaanp commented 6 years ago

I found the culprit statement. In the following code snippet, metric_sums["application_definition"] = next((appdef for appdef in marathon_apps if app.replace("_","/") == appdef.get("id")), {}) the if statement is using a replace method and then trying to match the app name with the app id. Now, in the version of Marathon I am using, app name is not prepended with the expected "_" I made a small fix for this. metric_sums["application_definition"] = next((appdef for appdef in marathon_apps if app.replace("_","") == appdef.get("id").replace("/","")), {}) Works like a charm now. Thanks @tendrilinc I am going to make the change on a forked version of this repo.

Regards, Hassaan