This repository has been archived by the owner on Jun 22, 2018. It is now read-only.
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.
Add
minimesos logs
commandThis PR implements the enhancement in issue #191
Dude, where are my logs?
In a Mesos cluster, the stdout/stderr of tasks are kept in a directory on the agent called sandbox. The content of this directory is exposed through the agent API via the
/files/download?path=...
endpoint. For more details, see the Mesos documentation.Here's an example:
The general format is as follows:
Access the logs programmatically
Generating the full URL to retrieve the stdout/stderr turned out to be trickier than expected. We need two parts:
agentServiceUrl
of the agent on which the task is runningpath
to the sandboxFigure out
agentServiceUrl
For
agentServiceUrl
, we match theslaveId
inTask
objects retrieved in the Mesos master state with theid
in eachMesosAgent.getState()
. Once found the agent, a simpleMesosAgent.getServiceUrl()
will give us what we need. This required adding parsing ofid
field inState
objects.Figure out
path
It would be tempting to build the
path
using the components already we already know (i.e.slaveId
,frameworkId
, ...). However, therunId
is only exposed in the agent state. To retrieve this bit of information, we need to parseframeworkId
andexecutorId
inTask
objects and thedirectory
of the rightexecutor
in theexecutors[]
section in the agent state. This is a stripped down example:Download the content
Once we have the URL, I simply used Unirest to get the content of the file. This could eventually be improved in terms of memory usage. An idea could be using the
offset
andlength
and the endpoint/files/read?path=...
described here.CLI
Look!
Tests
All the code was developed with a TDD approach. A full set of test is included. I also run all the test from the IDE and run a few manual test against a minimesos instance.