Skip to main content

mesoshttp

Project description

Python mesos scheduler HTTP library

This is a Python library to create a Mesos scheduler.

It removes the need to use/install Mesos python bindings and makes use of the HTTP API (native bindings are not updated anymore with new features)

MesosClient is the main entrypoint that connects to the Mesos master. You can then register for callbacks on events. On subscribe, you get a driver instance which you can use to send messages to master on current framework (kill, etc.)

MesosClient must be executed in a separate thread as it keeps a loop pooling connection with the master.

Submitted tasks should be in JSON format (according to mesos.proto).

See sample/test.py for example.

Callbacks will "block" the mesos message treatment, so they should be short, or messages should be forwarded to a queue in an other thread/process where longer tasks will handle messages.

DCOS EE Strict

Additions have been made to support login with ACS to allow access through to the master in a Strict security posture. The sample/test.py script is configured to accept the SERVICE_SECRET environment variable, which can be created and passed to the service using the script given below:

dcos security org service-accounts keypair service-account-private.pem service-account-public.pem
dcos security org service-accounts create -p service-account-public.pem -d "Service account for Scale data processing framework" service-account
dcos security secrets create-sa-secret --strict service-account-private.pem service-account service-account-secret

# Test with SUPERUSER perms on user
dcos security org users grant service-account dcos:superuser full

# Build image to test - update name in 2 commands below and marathon.json to your personal Docker Hub account name
docker build -t gisjedi/python-mesos-http -f Dockerfile-test-framework .
docker push gisjedi/python-mesos-http

# Deploy app consuming image to marathon
dcos marathon app add sample/marathon.json

# Once success has been confirmed, more granular permissions should be applied
dcos security org users revoke service-account dcos:superuser full
dcos security org users grant service-account dcos:mesos:agent:task create
dcos security org users grant service-account dcos:mesos:agent:task:app_id create
dcos security org users grant service-account dcos:mesos:agent:task:user:nobody create
dcos security org users grant service-account dcos:mesos:master:framework create
dcos security org users grant service-account dcos:mesos:master:reservation create
dcos security org users grant service-account dcos:mesos:master:reservation delete
dcos security org users grant service-account dcos:mesos:master:reservation:principal:service_account delete
dcos security org users grant service-account dcos:mesos:master:task create
dcos security org users grant service-account dcos:mesos:master:task:app_id create
dcos security org users grant service-account dcos:mesos:master:task:user:nobody create
dcos security org users grant service-account dcos:mesos:master:volume create
dcos security org users grant service-account dcos:mesos:master:volume delete
dcos security org users grant service-account dcos:mesos:master:volume:principal:service_account delete

About

This library does not implement all options of mesos.proto and manages schedulers only (not executors). Implemented features should be enough to implement a scheduler, if something is missing, please ask, or contribute ;-)

Install

pip install mesoshttp

Documentation

Documentation Status

0.4.2: Fix packaging to add README 0.4.1: Add support for heartbeat messages 0.3.2: Fix that breaks code PR #9 0.3.1: Add optional timeout to detect mesos disconnection PR #8 0.3.0: Add DCOS Strict security support (Merge #6) 0.2.14: Merge #4 Extend client to combine offers

0.2.13: Merge #3 Optionally set refuse_seconds filter in ACCEPT and DECLINE requests via new options field in methods

0.2.12: Add optional hostname and webui_url to framework (PR #2).

0.2.11: Merge #1, Operations in a Accept message is a list Operations was set to a dict, and worked, but interface defines it as a list.

0.2.10: Fix python3 zookeeper data decoding

0.2.9: Remove debug logs

0.2.8: Manage disconnection and reconnection to mesos master Add DISCONNECTED and RECONNECTED events

0.2.7: Fix retry management, catching more possible errors

0.2.6: Fix FAILURE and RESCIND management

0.2.5: Add RESCIND callback support

0.2.4: Fix case of event with no registered callback

0.2.3: Add more debug logging Fix loop condition when subscription fails

0.2.2: Print exception stack in case of subscribe exception

0.2.1: Fix case where master info is not available

0.2.0: Add zookeeper detection

0.1.0: Creation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

mesoshttp-0.4.2-py2.py3-none-any.whl (17.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file mesoshttp-0.4.2-py2.py3-none-any.whl.

File metadata

  • Download URL: mesoshttp-0.4.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.1.3 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0

File hashes

Hashes for mesoshttp-0.4.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a88ced6924920eb664addf07befdfed916dfe810a4c43e4c11d2f8b3cda93fd9
MD5 a4b66e39c1f2b56745c9762d02333bf1
BLAKE2b-256 a4e76c7b5dbf66a5df9e9c8ea89ee2cfe6cf98ce31c610cb54ae70a475c8c5bb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page