Commit Graph
17 Commits
Author SHA1 Message Date
Soam Vasani c7692978f9 Reap idle pods
Idle pod reaper wakes up once a minute, looks in the functionServiceCache for pods that
haven't been accessed for more than idlePodReapTime, and deletes all such pods.

(This doesn't yet delete pods that may be leaked from previously terminated poolmgrs; it
only works with pods created by the current poolmgr instance.)
2016-11-05 23:10:52 -07:00
Soam Vasani 5650fca3fd Refactor caching in poolmgr
Move separate caches to one cache -- functionServiceCache.  It can be
looked up by function, can update atime by address, and can be deleted
by podname.  This removes the other caches.  Some of the concurrency
logic is still a bit hairy; it might be better not to use fission.Cache.
2016-11-05 22:03:48 -07:00
Soam Vasani 78687d24b3 Idle pod reaper
Delete pods that are unused for more than a certain timeout.  This
change isn't complete -- other funcSvc caches need to be invalidated
on delete.  This needs a bit of refactoring.
2016-11-04 23:05:29 -07:00
Soam Vasani 35a5c94731 Add a reaped bit to funcSvc struct 2016-11-04 23:05:29 -07:00
Soam Vasani d512159cb3 Fix poolmgr cache bug
Poolmgr cache was useless because it was keying by *fission.Metadata
instead of the metadata itself.
2016-11-04 23:05:29 -07:00
Soam Vasani 5cfe4b7c1d Log and ignore errors on eager pool creation 2016-11-04 23:05:29 -07:00
Soam Vasani f3eba4b825 Call poolmgr from router while using a cached service
Poolmgr needs to know usage statistics for a function's pod.  This
change asynchronously taps poolmgr API when router uses a service.
Poolmgr can use this information to control pod expiry.  It may also
be useful later as one of the metrics for autoscaling.
2016-11-04 23:05:29 -07:00
Soam Vasani a6cd6e99fe Eagerly create generic pools
Poolmgr now watches the controller's list of environments and eagerly
creates a generic pool for each environment, if one doesn't already exist.
2016-11-03 15:08:06 -07:00
Soam Vasani c978efa1d9 Return bare pod IPs to router, instead of creating services
Even though the K8s api returns quickly after creating a service, that
service doesn't seem usage until about a second or two later.  We need
to investigate this and see if there's something we can do to make it
faster.  If there isn't we'll remove the svc code entirely; for now
it's behind a useSvc flag that's set to false.
2016-11-03 15:07:26 -07:00
Soam Vasani bbaa766fe1 Poolmgr -- add retries to specialize call
If the pool is new or very busy, we may call the chosen container's
specialize endpoint before it's actually up -- handle the case by
retrying a few times.

Also namespace-qualify service hostname (since router and
functions run in different namespaces).
2016-11-03 10:11:25 -07:00
Soam Vasani bb687d3e98 Don't use := when some vars are defined
:= attempts to declare as many of the variables on its left side as it
can, instead of re-using as many as it can.  Consider this code:

   a, ok := foo()
   if !ok {
      a, err := bar()
      ...
   }

The inner 'a' is a different var from the outer one, and goes out of
scope at the }.  The outer 'a' is left with whatever value foo()
returned.
2016-11-02 20:29:21 -07:00
Soam Vasani 91eb0ca3cd Poolmgr bugfix -- remove double response on the same channel 2016-11-02 15:47:32 -07:00
Soam Vasani f8a1fdf4c6 Improve logging in controller, fetcher, poolmgr
TODO: most of these should be in a debug loglevel.
2016-11-02 15:06:55 -07:00
Soam Vasani 2b15b726d4 Poolmgr client 2016-11-01 18:14:38 -07:00
Soam Vasani 6e86182e19 Poolmgr API tweaks + convenient Start function 2016-11-01 18:14:23 -07:00
Soam Vasani 40dfba1a41 Switch to official Kubernetes Go client -- client-go/1.4
Switch to client-go package instead of pulling the from kubernetes.
Use a versioned client with sensible compatiblity.

This change breaks 'go get'.  For now you have to manually checkout
the 'release-1.4' branch of the client-go package after 'go get'
fetches it.  TODO: use one of the build tools to fix this.
2016-11-01 01:32:02 -07:00
Soam Vasani 7d1058d7be Pool Manager -- manage generic containers and their specialization
GenericPool is a pool of generic containers for an environment.
GenericPoolManager keeps track of all GenericPools, creating them
on-demand.

The pool manager API is simply a "lookup" for the service URL of a
function.  If one exists it is returned immediately; otherwise, a
generic pool is created, and then a pod is specialized from that pool.

poolmgr is designed to run from within the cluster, since it connects
to pod IP addresses directly.

This is a first cut with many pieces missing.

TODO:
* Use versioned kubernetes clients instead of the unversioned one
* Unit tests for GenericPoolMgr; improve unit test for GenericPool;
  test for API.
* Handle cases where a service exists but pod backing it has failed.
* On start up, use existing deployments/pods/services if they exist;
  in other words don't orphan resources on restart.
* Kill idle resources (services, pods, even generic pools)
* Autoscale generic pool (for example, by watching num ready pods)
2016-11-01 01:32:02 -07:00