Git Product home page Git Product logo

docker-than-light's Introduction

Hi there ๐Ÿ‘‹

  • ๐Ÿ”ญ Iโ€™m currently working at Heroku, rebooting databases.
  • ๐Ÿ’ฌ Ask me about ruby, postgres and travelling.
  • ๐Ÿ“ซ How to reach me: [email protected]

docker-than-light's People

Contributors

beanieboi avatar bfosberry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

docker-than-light's Issues

Add ship client api

This should support calling

  • _ping (non 200 kills the ship)
  • action (with hit and scan notifications) (any response is ok as long as the connection goes through)
  • update (with a new ship object) (must return 200)
    bonus points for supporting /message

Connection info is "http://#{ship.addr}:#{ship.port}". This is assuming the addr we have stored is the HOST address not the container address, which I think it is...? This cannot be the swarm address.

God api should allow users to create ships

After a user submits a form the God api should connect to one of the swarm nodes using the docker client, and create a proxy container to create the ship. Once this exists with zero and the container Id and host info, the god api should store that info in the ship model

God api should mediate fire requests

When a ship fires on another ship, the God api should determine

  • If the ship has enough energy
  • if the target has not left the sector

And then

  • Send a hit notification to the target ship
  • Respnd with a success code
  • Deduct the ships energy levels
  • Dispatch a notification

Set up event aggregation system

Every time a ship moves sectors, or fires, or is destroyed, it should create a sector-wide event. These events should be sent out from the god api to all users viewing logs and be replayable.

We could just have an events model for this, but maybe there is a better way.

Maybe not replayable for mvp?

The goal here is to have this information populate in the /logs view as events occur, so as the God api mediates, it can dispatch event notifications. These are purely informational and non-functional.

After submitting a ship, user should be redirect to /logs/SHIP_NAME

This page should stream logs aggregated from the ship and the sector, (maybe two panels) returned via a websocket from the god api.

The god api will stream logs from the container via the docker client using the info stored for the ship when it was created, as well events popping in for the relevant sector

Routing error in prod :(

I borked it!

ActionController::RoutingError (uninitialized constant Application::ShipsController)

Unsure why this is happening, not doing anything weird with the ships controller that was not done with the dashboards controller.

2016-03-23T02:38:58.602152+00:00 app[web.1]: Started POST "/ships" for 72.182.15.101 at 2016-03-23 02:38:58 +0000
2016-03-23T02:38:58.604961+00:00 app[web.1]: 
2016-03-23T02:38:58.604971+00:00 app[web.1]: ActionController::RoutingError (uninitialized constant Application::ShipsController):
2016-03-23T02:38:58.604972+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/inflector/methods.rb:263:in `const_get'
2016-03-23T02:38:58.604973+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/inflector/methods.rb:263:in `block in constantize'
2016-03-23T02:38:58.604974+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/inflector/methods.rb:259:in `each'
2016-03-23T02:38:58.604975+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/inflector/methods.rb:259:in `inject'
2016-03-23T02:38:58.604976+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/inflector/methods.rb:259:in `constantize'
2016-03-23T02:38:58.604977+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/routing/route_set.rb:70:in `controller_reference'
2016-03-23T02:38:58.604977+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/routing/route_set.rb:60:in `controller'
2016-03-23T02:38:58.604978+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/routing/route_set.rb:39:in `serve'
2016-03-23T02:38:58.604979+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/journey/router.rb:43:in `block in serve'
2016-03-23T02:38:58.604980+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/journey/router.rb:30:in `each'
2016-03-23T02:38:58.604980+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/journey/router.rb:30:in `serve'
2016-03-23T02:38:58.604981+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/routing/route_set.rb:817:in `call'
2016-03-23T02:38:58.604982+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:186:in `call!'
2016-03-23T02:38:58.604983+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:164:in `call'
2016-03-23T02:38:58.604984+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/builder.rb:63:in `call'
2016-03-23T02:38:58.604985+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/rack-1.6.4/lib/rack/etag.rb:24:in `call'
2016-03-23T02:38:58.604985+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/rack-1.6.4/lib/rack/conditionalget.rb:38:in `call'
2016-03-23T02:38:58.604986+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/rack-1.6.4/lib/rack/head.rb:13:in `call'
2016-03-23T02:38:58.604987+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
2016-03-23T02:38:58.604988+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/flash.rb:260:in `call'
2016-03-23T02:38:58.604988+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:225:in `context'
2016-03-23T02:38:58.604989+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:220:in `call'
2016-03-23T02:38:58.604990+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/cookies.rb:560:in `call'
2016-03-23T02:38:58.604990+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.6/lib/active_record/query_cache.rb:36:in `call'
2016-03-23T02:38:58.604992+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
2016-03-23T02:38:58.604992+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
2016-03-23T02:38:58.604993+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:88:in `__run_callbacks__'
2016-03-23T02:38:58.604994+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
2016-03-23T02:38:58.604994+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:81:in `run_callbacks'
2016-03-23T02:38:58.604995+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2016-03-23T02:38:58.604996+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
2016-03-23T02:38:58.604996+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
2016-03-23T02:38:58.604997+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2016-03-23T02:38:58.604998+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/rack/logger.rb:38:in `call_app'
2016-03-23T02:38:58.604999+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/rack/logger.rb:20:in `block in call'
2016-03-23T02:38:58.604999+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/tagged_logging.rb:68:in `block in tagged'
2016-03-23T02:38:58.605000+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/tagged_logging.rb:26:in `tagged'
2016-03-23T02:38:58.605001+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/tagged_logging.rb:68:in `tagged'
2016-03-23T02:38:58.605001+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/rack/logger.rb:20:in `call'
2016-03-23T02:38:58.605006+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2016-03-23T02:38:58.605006+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call'
2016-03-23T02:38:58.605007+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call'
2016-03-23T02:38:58.605008+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
2016-03-23T02:38:58.605008+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/static.rb:120:in `call'
2016-03-23T02:38:58.605009+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call'
2016-03-23T02:38:58.605010+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/ssl.rb:24:in `call'
2016-03-23T02:38:58.605010+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:518:in `call'
2016-03-23T02:38:58.605011+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/application.rb:165:in `call'
2016-03-23T02:38:58.605012+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/puma-3.1.1/lib/puma/configuration.rb:227:in `call'
2016-03-23T02:38:58.605013+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/puma-3.1.1/lib/puma/server.rb:561:in `handle_request'
2016-03-23T02:38:58.605013+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/puma-3.1.1/lib/puma/server.rb:406:in `process_client'
2016-03-23T02:38:58.605014+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/puma-3.1.1/lib/puma/server.rb:271:in `block in run'
2016-03-23T02:38:58.605015+00:00 app[web.1]:   vendor/bundle/ruby/2.3.0/gems/puma-3.1.1/lib/puma/thread_pool.rb:111:in `block in spawn_thread'
2016-03-23T02:38:58.605016+00:00 app[web.1]: 
2016-03-23T02:38:58.605016+00:00 app[web.1]: 

Fix logs view

Logs view should use application tempate and render logs in a 1000 row subsection

God api should facilitate scanning

Ship sending a scan request for the sector or ships should lose some energy but receive lists of ships

OR details on a specific ship like health and power. This sohuld send a scan notification to the target ship

Create public container image for executing privileged swarm actions

We need a public container we can run on a node in our cluster, which reaches out to the swarm cluster and performs privileged actions. Since no apis exist for this, and we will be remote this will have to be a container.

Container needs to have docker experimental client, and it'll have to be run with the DOCKER_HOST and certs for the swarm master node. Running it should execute the docker cluster change as needed.

These changes include

  • Create a ship on the cluster
  • Kill a ship
  • Move a ship between networks (kill the container, start it on the new network, update god api with details, this should not consitute a kill)

the image should be run with the following args, some of which are optional for remove:

  • ACTION - which action to perform (start/stop/move)
  • CONTAINER_ID - the id of the container on the cluster
  • CONTAINER_NAME - the user provided ship name
  • CONTAINER_IMAGE - the user provided ship image
  • DESIRED_NETWORK - which sector the ship should be started in
  • API_URL - a url to the God api for the ship to use

Move is a combination of start and stop, and tt should execute the following changes:

verify current network is not desired network
docker rm -f CONTAINER_ID
docker run --publish-service CONTAINER_NAME.DESIRED_NETWORK --name CONTAINER_NAME -tid CONTAINER_IMAGE
return the new CONTAINER_ID and HOST_IP

Add /initialize endpoint

This should pass down the initial ship state as well as the simulation rules

  • shield
  • energy
  • recharge rate
  • costs (energy, time and probability)
  • fire damage

Determine/Document energy and time costs for all God api actions

Everything a ship can do should take time

Make a simply list of appropriate time and energy costs for the different actions.

This should include globals such as starting health and energy, weapon damage, charge rates, max fire rates etc. These will be balanced as we go on

Add docker client to API

This will only be used for pulling logs from specific containers, and for executing the experimental control container to create/move/destroy ships from the cluster

God api should clean up ships with zero health

Any time a ships health drops to zero, the container should be killed, and the ship should be marked as kill. The websocket should be closed and the user notified and invited to respawn

depends on #2

Add sector scaffold

We need a sector seed, model and basic join between ships and sectors.

We will also need to facilitate "scanning" of sectors and of ships. Unsure if this should be on the ship/sector model though

Add token based auth for api

We need to find a way to secure (or intentionally not fully secure) the api. Currently ships are hitting the api and being asked to log in. We can

  1. Skip this filter for now and rely on the fact we know the source of the request maps to a ship we control (prob not super secure)
  2. Add a simple token based auth like api_key header or param
  3. Add a more complex auth setup like signing requests or tls

God api should mediate movement requests

As a ship, if I have sufficient energy (decide how much that is), and I make a request to the God api to move sectors, the God api should shut down my container and move me to a new sector, and start me up again.

Logs should not be interrupted (but maybe old logs are lost for now

Depends on #2

Set up proxy/public ip assignment

Currently due to the way caraina works we can't hit the containers directly since our master API is outside the private network. We need to stick a container proxy in, or assign public IPs to each container (meh).

God api should periodically update ships

Ship state updates should be included in state changes such as scanning and firing in the response to the ship, however if the ship does not act for a while there could be some drift in understanding.

Every 1 minute without action we should tell the ship what its current state is to sync understanding.

Not part of MVP

Create simple ship scaffold in Go

We need to create a simple Go ship scaffold that meets the basic API requirements as defined in the README. This ship does not have to do anything, but must not be destroyed by the God api due to lack of responses.

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.