Giter Club home page Giter Club logo

pudding's Introduction

pudding

Build Status

Deploy

Development and such

This repo should be cloned into your GOPATH at ${GOPATH%%:*}/src/github.com/travis-ci/pudding. If you don't know what GOPATH is or are unsure if the top entry is in a non-volatile location, you should Ask Someone ™

prerequisites

go get github.com/hamfist/deppy
go get github.com/golang/lint/golint
go get golang.org/x/tools/cmd/cover

gometalinter --install

build/test cycle

Do everything:

make

Only clean and build, with less output:

make clean build GOBUILD_FLAGS=

Running things locally

As with other heroku apps:

foreman start

The same, but without rerun in the mix:

DYNO=1 foreman start

Usage

web

The web API exposes the following resources, with most requiring authentication via token:

GET /

Provides a friendly greeting

DELETE / requires auth

Gracefully shut down the server

POST /kaboom requires auth

Simulate a panic. No body expected.

GET /instances requires auth

Provide a list of instances, optionally filtered with env and site query params.

GET /instances/{instance_id} requires auth

Provide a list containing a single instance matching the given instance_id, if it exists.

DELETE /instances/{instance_id} requires auth

Terminate an instance that matches the given instance_id, if it exists.

POST /instance-builds requires auth

Start an instance build, which will result in an EC2 instance being created. The expected body is a jsonapi singular collection of "instance_build", like so:

{
  "instance_builds": {
    "role": "worker",
    "site": "org",
    "env": "staging",
    "instance_type": "c3.2xlarge",
    "slack_channel": "#general",
    "count": 4,
    "queue": "docker",
    "boot_instance": true
  }
}

Note: You can prevent pudding from booting an instance by setting the boot_instance flag to false -- in this case it will only create a cloud-init script.

PATCH /instance-builds/{instance_build_id} requires auth

"Update" an instance build; currently used to send notifications to Slack upon completion of a build. Expects application/x-www-form-urlencoded params in the body, a la:

state=finished&instance-id=i-abcd1234&slack-channel=general

GET /init-scripts/{instance_build_id} requires auth

This route accepts both token auth and "init script auth", which is basic auth specific to the instance build and is kept in a redis key with expiry. This is the route hit by the cloud-init #include set in EC2 instance user data when the instance is created. It responds with a content type of text/x-shellscript; charset=utf-8, which is expected (but not enforced) by cloud-init.

GET /images requires auth

Provide a list of images per role, denoting which is active. Example response:

{
  "images": [
    {
      "ami": "ami-00aabbcc",
      "active": true,
      "role": "web"
    },
    {
      "ami": "ami-00aabbcd",
      "active": false,
      "role": "web"
    }
  ]
}

workers

The background job workers are started as a separate process and communicate with the web server via redis. The sidekiq-compatible workers are built using go-workers. There are also non-evented "mini workers" that run in a simple run-sleep loop in a separate goroutine.

instance-builds queue

Jobs handled on the instance-builds queue perform the following actions:

  • resolve the ami id, using the most recent available if absent
  • create a custom security group and authorize inbound port 22
  • prepare a cloud-init script and store it in redis
  • prepare an #include statement with custom URL to be used in the instance user-data
  • create an instance with the resolved ami id, #include <url> user-data, custom security group, and specified instance type
  • tag the instance with role, Name, site, env, and queue
  • send slack notification that the instance has been created

instance-terminations queue

Jobs handled on the instance-terminations queue perform the following actions:

  • terminate the instance by id, e.g. i-abcd1234
  • remove the instance from the redis cache

pudding's People

Contributors

sarahhodne avatar meatballhat avatar igorwwwwwwwwwwwwwwwwwwww avatar

Stargazers

Michael Mendy avatar Rafael Jesus avatar Isagani Mendoza avatar Matt Blair avatar Brian Hatfield avatar Angus H. avatar Nikolay Kolev avatar Rob Witoff avatar Cameron Moore avatar Torbjörn Norinder avatar em dan trim avatar  avatar Rafe Colton avatar WÁNG Xuěruì avatar Quinn Wilton avatar Alexander Dupuy avatar John Deng avatar dmnlk avatar hacfi avatar Nathan Jones avatar Michael Williams avatar Jonathan Porta avatar Benjamin Fleischer avatar Binea avatar Aleksandr Razumov avatar jon avatar Ben Firshman avatar Tengu Saruta avatar khelil avatar Minku Lee avatar 강성진 sungjin.kang avatar Matt Bajor avatar Michael Sheedy avatar Damien Mathieu avatar Joey avatar Minho Ryang avatar myoung-su,shin avatar Benjamin Dos Santos avatar Outsider avatar kyzh avatar OKAMURA Naoki aka nyarla / kalaclista avatar Rajeeva Lochan Musunuri avatar Hong Truong avatar Tomohiro Taira avatar Taichi Nakashima avatar Derek Reynolds avatar Andrew Seidl avatar Riccardo Cambiassi avatar Dan Sosedoff avatar Christopher Jenkins avatar Chavez avatar Krispin Schulz avatar Girish Duvuru avatar Jesly Varghese avatar  avatar  avatar Aaron Hill avatar Konstantin Haase avatar

Watchers

Josh Kalderimis avatar Hiro Asari avatar Eric M avatar  avatar Jan Schulte avatar Grant MacGillivray avatar Suzan Bond avatar James Cloos avatar Sergiy Golub avatar Aakriti Gupta avatar Laura avatar weban.pl avatar Alexander Toshio Davila Chinen avatar khelil avatar Damian Szymański avatar Berrak Nil avatar  avatar Renée Hendricksen avatar Maria Jose Balbontin avatar  avatar  avatar Murtaza Khan avatar

Forkers

adiputra6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.