-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[marathon] Count running/pending deployments #2788
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e7a16a1
Count running or pending deployments
bradhe 2a2762a
Helper for loading JSON fixtures.
bradhe c6a6669
Tests for marathon checks
bradhe efa6b4a
Normalize tabs/spaces and tidy whitespace.
bradhe 0f13bd5
Clean up some linty stuff.
bradhe 5cb1409
Users should explicitly enable deployment-related metrics.
bradhe 1f9842f
Update example docs for Marathon.
bradhe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"apps": [ | ||
{ | ||
"id": "/my-app", | ||
"cmd": "/usr/bin/run-app", | ||
"args": null, | ||
"user": null, | ||
"env": { | ||
"ENVIRONMENT": "development" | ||
}, | ||
"instances": 10, | ||
"cpus": 1.0, | ||
"mem": 512, | ||
"disk": 0, | ||
"executor": "", | ||
"constraints": [], | ||
"ports": [ | ||
10002 | ||
], | ||
"portDefinitions": [ | ||
{ | ||
"port": 10002, | ||
"protocol": "tcp", | ||
"labels": {} | ||
} | ||
], | ||
"requirePorts": false, | ||
"backoffSeconds": 1, | ||
"backoffFactor": 1.15, | ||
"maxLaunchDelaySeconds": 3600, | ||
"container": { | ||
"type": "DOCKER", | ||
"volumes": [], | ||
"docker": { | ||
"image": "my-org/my-image:latest", | ||
"network": "BRIDGE", | ||
"portMappings": [ | ||
{ | ||
"containerPort": 80, | ||
"hostPort": 0, | ||
"servicePort": 10002, | ||
"protocol": "tcp", | ||
"labels": {} | ||
} | ||
], | ||
"privileged": false, | ||
"parameters": [], | ||
"forcePullImage": true | ||
} | ||
}, | ||
"healthChecks": [ | ||
{ | ||
"path": "/health", | ||
"protocol": "HTTP", | ||
"portIndex": 0, | ||
"gracePeriodSeconds": 5, | ||
"intervalSeconds": 10, | ||
"timeoutSeconds": 20, | ||
"maxConsecutiveFailures": 3, | ||
"ignoreHttp1xx": false | ||
} | ||
], | ||
"readinessChecks": [], | ||
"dependencies": [], | ||
"upgradeStrategy": { | ||
"minimumHealthCapacity": 0.5, | ||
"maximumOverCapacity": 0.5 | ||
}, | ||
"labels": { | ||
"HAPROXY_0_VHOST": "my-app.my-org.net", | ||
"HAPROXY_GROUP": "my-app" | ||
}, | ||
"acceptedResourceRoles": null, | ||
"ipAddress": null, | ||
"version": "2016-08-25T18:13:34.079Z", | ||
"residency": null, | ||
"versionInfo": { | ||
"lastScalingAt": "2016-08-25T18:13:34.079Z", | ||
"lastConfigChangeAt": "2016-08-25T16:58:48.416Z" | ||
}, | ||
"tasksStaged": 5, | ||
"tasksRunning": 10, | ||
"tasksHealthy": 5, | ||
"tasksUnhealthy": 0, | ||
"deployments": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
[ | ||
{ | ||
"affectedApps": [ | ||
"/test/service/srv1", | ||
"/test/db/mongo1", | ||
"/test/frontend/app1" | ||
], | ||
"currentStep": 2, | ||
"currentActions": [ | ||
{ | ||
"action": "RestartApplication", | ||
"app": "/test/frontend/app1", | ||
"readinessChecks": [ | ||
{ | ||
"lastResponse": { | ||
"body": "{}", | ||
"contentType": "application/json", | ||
"status": 500 | ||
}, | ||
"name": "myReadyCheck", | ||
"ready": false, | ||
"taskId": "test_frontend_app1.c9de6033" | ||
} | ||
] | ||
} | ||
], | ||
"totalSteps": 9, | ||
"id": "2e72dbf1-2b2a-4204-b628-e8bd160945dd", | ||
"steps": [ | ||
[ | ||
{ | ||
"action": "RestartApplication", | ||
"app": "/test/service/srv1" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "RestartApplication", | ||
"app": "/test/db/mongo1" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "RestartApplication", | ||
"app": "/test/frontend/app1" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "KillAllOldTasksOf", | ||
"app": "/test/frontend/app1" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "KillAllOldTasksOf", | ||
"app": "/test/db/mongo1" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "KillAllOldTasksOf", | ||
"app": "/test/service/srv1" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "ScaleApplication", | ||
"app": "/test/service/srv1" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "ScaleApplication", | ||
"app": "/test/db/mongo1" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "ScaleApplication", | ||
"app": "/test/frontend/app1" | ||
} | ||
] | ||
], | ||
"version": "2014-07-09T11:14:11.477Z" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# project | ||
from tests.checks.common import AgentCheckTest | ||
from tests.checks.common import Fixtures | ||
|
||
DEPLOYMENT_METRICS_CONFIG = { | ||
'init_config': { | ||
'default_timeout': 5 | ||
}, | ||
'instances': [ | ||
{ | ||
'url': 'http://localhost:8080', | ||
'enable_deployment_metrics': True | ||
} | ||
] | ||
} | ||
|
||
DEFAULT_CONFIG = { | ||
'init_config': { | ||
'default_timeout': 5 | ||
}, | ||
'instances': [ | ||
{ | ||
'url': 'http://localhost:8080' | ||
} | ||
] | ||
} | ||
|
||
def getMetricNames(metrics): | ||
return [metric[0] for metric in metrics] | ||
|
||
class MarathonCheckTest(AgentCheckTest): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🙇 |
||
CHECK_NAME = 'marathon' | ||
|
||
def test_default_configuration(self): | ||
def side_effect(url, timeout, auth): | ||
if "v2/apps" in url: | ||
return Fixtures.read_json_file("apps.json") | ||
else: | ||
raise Exception("unknown url:" + url) | ||
|
||
self.run_check(DEFAULT_CONFIG, mocks={"get_json": side_effect}) | ||
self.assertMetric('marathon.apps', value=1) | ||
|
||
# deployment-related metrics aren't included by default. | ||
self.assertTrue('marathon.deployments' not in getMetricNames(self.metrics)) | ||
|
||
def test_empty_responses(self): | ||
def side_effect(url, timeout, auth): | ||
if "v2/apps" in url: | ||
return {"apps": []} | ||
else: | ||
raise Exception("unknown url:" + url) | ||
|
||
self.run_check(DEFAULT_CONFIG, mocks={"get_json": side_effect}) | ||
self.assertMetric('marathon.apps', value=0) | ||
|
||
def test_enabled_deployment_metrics(self): | ||
def side_effect(url, timeout, auth): | ||
if "v2/apps" in url: | ||
return Fixtures.read_json_file("apps.json") | ||
elif "v2/deployments" in url: | ||
return Fixtures.read_json_file("deployments.json") | ||
else: | ||
raise Exception("unknown url:" + url) | ||
|
||
self.run_check(DEPLOYMENT_METRICS_CONFIG, mocks={"get_json": side_effect}) | ||
self.assertMetric('marathon.apps', value=1) | ||
self.assertMetric('marathon.deployments', value=1) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, let's keep it in this PR