All Projects → allegro → mesos-executor

allegro / mesos-executor

Licence: Apache-2.0 License
Customizable Apache Mesos task executor

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to mesos-executor

Marathon Consul
Integrates Marathon apps with Consul service discovery.
Stars: ✭ 174 (+248%)
Mutual labels:  consul, mesos
Traefik
The Cloud Native Application Proxy
Stars: ✭ 36,089 (+72078%)
Mutual labels:  consul, mesos
Panteras
PanteraS - PaaS - Platform as a Service in a box
Stars: ✭ 189 (+278%)
Mutual labels:  consul, mesos
My Cheat Sheets
A place to keep all my cheat sheets for the complete development of ASIC/FPGA hardware or a software app/service.
Stars: ✭ 94 (+88%)
Mutual labels:  consul, mesos
consul-registration-hook
Hook that can be used for synchronous registration and deregistration in Consul discovery service on Kubernetes or Mesos cluster with Allegro executor
Stars: ✭ 17 (-66%)
Mutual labels:  consul, mesos
dynamic-sharding
用动态分片解决pushgateway高可用 单点 HA问题
Stars: ✭ 27 (-46%)
Mutual labels:  consul
seagull
Configuration server submodule for all SeaSerives
Stars: ✭ 19 (-62%)
Mutual labels:  consul
gocast
GoCast is a tool for controlled BGP route announcements from a host
Stars: ✭ 55 (+10%)
Mutual labels:  consul
deathnode
Gracefully kill Mesos nodes in AWS for autoscaling and inmutable deployments
Stars: ✭ 17 (-66%)
Mutual labels:  mesos
tuggle
Distributed file mirroring proxy in Consul cluster
Stars: ✭ 16 (-68%)
Mutual labels:  consul
retz
A batch job queuing and execution service (Mesos framework)
Stars: ✭ 23 (-54%)
Mutual labels:  mesos
container-orchestration
A Benchmark for Container Orchestration Systems
Stars: ✭ 19 (-62%)
Mutual labels:  mesos
props
config source library for golang, support properties/yaml/ini file、zookeeper\consul\etcd k/v k/props
Stars: ✭ 57 (+14%)
Mutual labels:  consul
dcos-deploy
Deploy, manage and orchestrate services and apps on DC/OS
Stars: ✭ 21 (-58%)
Mutual labels:  mesos
go-fsimpl
Go io/fs.FS filesystem implementations for various URL schemes
Stars: ✭ 225 (+350%)
Mutual labels:  consul
docker vault
Docker + Consul + Vault
Stars: ✭ 34 (-32%)
Mutual labels:  consul
consul-templaterb
consul-template-like with erb (ruby) template expressiveness
Stars: ✭ 65 (+30%)
Mutual labels:  consul
terraform-google-nomad
📗 Terraform Module for Nomad clusters with Consul on GCP
Stars: ✭ 63 (+26%)
Mutual labels:  consul
fm.consulinterop
a lib for build micro-service
Stars: ✭ 33 (-34%)
Mutual labels:  consul
Sitko.Core
Sitko.Core is a set of libraries to help build .NET Core applications fast
Stars: ✭ 46 (-8%)
Mutual labels:  consul

Mesos Executor

Build Status Go Report Card Codecov GoDoc

Executor

Customizable Apache Mesos task executor. It allows controlled graceful task shutdown and performing various additional actions during the task lifecycle, by providing hook mechanisms (see hook package).

How task execution works?

Executor uses Mesos HTTP API to communicate with agent. When executor is started, before doing anything else, it tries to subscribe to Mesos agent. After successful subscription it waits for events from agent to handle. During the whole process executor keeps connection with a Mesos agent. When connection is lost it tries to reconnect for a configured time and when it fails to do so it tries to finish the started task and stops the whole executor process.

Task is started when Event_LAUNCH is received with required TaskInfo. Before starting the received command executor fires BeforeTaskStartEvent event hook, and if any of registered hooks fail to do their jobs, it stops the execution process and fails. This hook can be used to modify the environment of the task by returning formatted variable strings ("VAR=value"). Right after starting the command, executor fires AfterTaskStartEvent event hook - and again if any of the hooks fail, executor fails also. It is worth noting that executor may exit without even starting a task.

Executor may exit in the following cases:

  • started tasks fail to start or run - executor quits with TASK_FAILED sent to Mesos agent
  • started tasks exit with 0 return code - executor quits with TASK_FINISHED sent to Mesos agent
  • executor receives Event_SHUTDOWN or Event_KILL - executor quits with TASK_KILLED sent to Mesos agent

Executor always fires BeforeTerminateEvent event hook when exiting - regardless of whether it started a task or not.

Graceful Shutdown

Graceful Shutdown is a feature to minimize task killing impact on other systems. It is performed in the following steps:

  1. Call all hooks with BeforeTerminateEvent.
  2. Sent SIGTERM to process tree.
  3. Wait KillPolicyGracePeriod (can be overridden with Task Kill Policy Grace Period).
  4. Sent SIGKILL to process tree.

Executor can be configured to exclude certain processes from SIGTERM signal. Provide process names to exclude in ALLEGRO_EXECUTOR_SIGTERM_EXCLUDE_PROCESSES environment variable as a comma-separated string. This feature requires pgrep -g to be available on the machine.

Log scraping

By default executor forwards service stdout/stderr to its own standard streams. It can however redirect them to data processing pipeline - Logstash. This requires you to set up the connection to the Logstash service in the executor's environmental variables:

ALLEGRO_EXECUTOR_SERVICELOG_LOGSTASH_PROTOCOL="tcp" # tcp or udp
ALLEGRO_EXECUTOR_SERVICELOG_LOGSTASH_ADDRESS="localhost:1234" # host and port

Currently, the executor is able to parse and send only logs in the logfmt format. To enable log scraping you need to set log-scraping label in Mesos TaskInfo to logfmt. For more information see documentation of servicelog package.

Hooks

Executor supports integration with external system via hooks. The hook is an interface with functions that will be called when specific actions occur. To use hooks just implement hook.Hook and plug it into hook.Manager. Hooks calls are blocking.

Consul integration

Integration with Consul is based on a hook. It mimics the behavior of allegro/marathon-consul. Task is registered in Consul once it becomes healthy and deregistered before kill. Required task metadata such as name, labels and ports are obtained from task definition. Service name is taken from consul label. Labels are transformed to Consul tags only when value is equal tag. Client does not use any ACL Token by default, this can be changed by setting CONSUL_TOKEN environment variable.

VaaS integration

VaaS integration is based on a hook. Task is registered once it becomes healthy and deregistered before kill. Task’s first port will be registered under director provided in a label named director. If task has defined weight in a label it will be used. Weight could be overridden with VAAS_INITIAL_WEIGHT environment variable. If task is a canary instance (has non empty canary label) backend is marked as a canary.

Requirements

To run executor tests locally you need following tools installed:

If you want to test executor locally, you will need additionally:

Debug mode

Executor offers a debug mode that provide extended logging and capabilities during runtime. Enabling this can significantly increase the amount of resources the executor needs to operate, so do not turn this on, when it is not needed. To enable debug mode add -debug flag to executor command or set ALLEGRO_EXECUTOR_DEBUG environment variable to true.

Development

Using Vagrant environment

To create your Vagrant environment execute following command in project root folder:

$ vagrant up

It will create a virtual machine with Apache Mesos and Marathon installed and running on it. Mesos UI will be available on http://localhost:5050 and Marathon UI on http://localhost:8080.

If you want to test executor on Vagrant Mesos you will have to create release build of it. To do this, execute the following command:

$ make release

Binary will be immediately available on virtual machine on following address:

http://localhost/executor

You can use above address to configure your Marathon application to be executed by your freshly build executor. An example application is available in marathon-test-app.json

Executor configuration can be altered via environment variables in the following way:

ALLEGRO_EXECUTOR_STATE_UPDATE_BUFFER_SIZE="2048"
ALLEGRO_EXECUTOR_STATE_UPDATE_WAIT_TIMEOUT="3s"

sets the StateUpdateBufferSize Config property to 2048, and StateUpdateWaitTimeout to 3 seconds. For all available settings and their defaults see executor.go.

Additionally, a Consul instance is available for testing purposes, its logs can be viewed by running:

$ vagrant ssh
vagrant@localhost:~$ sudo supervisorctl tail -f consul

Known Issues

  1. Executor may not send a SIGKILL to process tree after grace period, so service process may be still running when executor finishes. To clean up executor and launched tasks properly use pid isolator.

Contributing

See CONTRIBUTING for more details and code of conduct.

License

Mesos Executor is distributed under the Apache 2.0 License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].