Commit Graph
44 Commits
Author SHA1 Message Date
Soam Vasani 42261d8810 Remove retries from poolmgr eagerPoolCreator
This was initially added to avoid restarts if poolmgr starts before
fission api; but we don't really need that since k8s will restart
it. Also, poolmgr now talks to the k8s api directly instead of the
fission api.
2017-08-09 22:37:55 -07:00
Soam VasaniandGitHub e238776bf7 V2 types and TPR (#266)
This changes the core fission function, environment and trigger types. It also changes Fission's storage to use ThirdPartyResources.

 - Functions are now specified by packages. Functions can also have both source and deployment packages. A package can be specified by a literal, or by a URL.
 - Environments have a build and runtime component.
 - Triggers reference functions by a FunctionReference. This is a layer of indirection between triggers and functions, and will allow things like incremental function upgrades in future releases.

See Documentation/wip/env-v2.md for design discussion about points 1 and 2.

Changes:

* V2 Types

All types now have a spec, following the pattern of K8s objects.

Functions now have source and deployment packages. A Package can be
specified by literal, or by URL.

Environments now have a builder and runtime component.

All triggers use a new FunctionReference to specify the function. This
for now only uses a function name, but in the future can be extended
to be more flexible.

A new FunctionLoadRequest type is added for specialization requests to
the environment runtime.

* TPR types, TPR init code, and a "fission client"

Implements TPR types using the spec types in fission/types.go.

Adds code for adding creating TPR types, and convenient types for crud
operations on each of our resource types.

Adds code for connecting to K8s API and configuring a REST client with
fission types set up.

* Change old stateful controller into a thin apiserver

This apiserver is now simply a stateless api layer on top of the TPR
types. At the moment it doesn't do anything that couldn't be done by
simply talking to the TPR types. In the future we can have better
validation and potentially some higher level APIs (like versioning for
example) in here.

* Split controller client into files and update for v2 types.

* Update CLI for v2 types.

As far as possible we keep the CLI flags the same. We'll have to add
flags for source/deploy packages and builder/runtime
environments. That will come in the next change.

* Update poolmgr and fetcher for v2 types.

Also adds a poolmgr_test.

* Update router for new types.

Also adds a function reference resolver, which separates out the job
of resolving a FunctionReference to a function.

* Update kubewatcher and timer for v2 types.

* Update Message Queue trigger type for v2 types.

* Minor odds and ends.

* Fission bundle CLI updates

Remove controllerUrl flag, since we don't need it any more.

* Remove etcd deployment (replaced by storing state in TPR)

Also update the poolmgr commandline, and use an env var for the
fetcher image URL.

* Explicit ChecksumType and consts

* Clarify separation of environment interface types
2017-08-05 01:18:30 -07:00
yang qfandSoam Vasani ce4d3ac42d Fix creation of redundant pods on heavy load cold start (#232)
Modifies function specialization so that concurrent requests for the same function cause only one pod to be created.
2017-06-19 18:56:38 -07:00
yang qfandSoam Vasani c1dd8a9f35 Aggregate tap service request in interval (#229)
The poolmgr client now aggregates successive tapService() calls and sends them to the poolmgr service every 5 sec, instead of sending them immediately.
2017-06-17 20:58:10 -07:00
Ta-Ching ChenandSoam Vasani d9b98830cf Fix http response body not closed correctly, return immediately on error (#210)
* Fix controller timer handler not return when error occurred

* Fix controller not close http response correctly

This PR aims to fix controller not close response correctly. Also, I’ve check all over the project there is no more resource leak issues exist after this patch.

* Fix controller not return immediately when error occurred

* Sort import
2017-06-17 13:10:54 -07:00
Ta-Ching ChenandSoam Vasani c43cde8891 Fix pool contains wrong environment metadata (#221)
The generic pool manager creates a generic pool with the reference of environment metadata. Since the reference is address of loop variable, so the content of metadata will be replaced with the last element of envs. So pool manager sets up logging with wrong env.
2017-06-08 11:11:58 -07:00
Ta-Ching ChenandSoam Vasani a13015e75a Add function logs support (#53) (#131)
Add function log aggregation and persistence using Fluentd and InfluxDB.

Fluentd and a helper sidecar run as a daemonset.  The poolmgr sets up logging for each function pod, using the helper sidecar. Fluentd forwards logs to InfluxDB, which is run as a deployment and service. The client CLI directly queries InfluxDB for logs.

Fluentd supports many outputs besides InfluxDB, so we aren't very tied to InfluxDB.

The setup is somewhat manual, which we should be able to improve by integrating this into the helm chart.

Diagram of component interactions: https://cloud.githubusercontent.com/assets/202578/23100399/b0e3ea00-f6ba-11e6-8f2f-6588cfef2e84.png
2017-03-22 15:59:42 -07:00
Ta-Ching ChenandSoam Vasani ad63ba63c8 Fixed pod has no ip (#139) (#141)
Fixes #139.  The code before this change was saving up pointers to the loop variable in a slice. So loop was useless and we always chose the last pod in the list, whether it was ready or not.  With this fix, choosePod should always return a ready pod.

Also adds a check for the pod phase, before looping over the containers in the pod, and discard pods that aren't running yet.
2017-03-05 11:01:47 -08:00
Soam Vasani d4d917ad04 Don't wait for ready pod in MakeGenericPool
Addresses issue #113.  poolmgr.MakeGenericPool does not need to wait
for a ready pod.  Kubernetes already retries image fetching, so
there's no need to repeat the task in fission.  And if it's a
non-retriable error (like the image URL being wrong), then the
deployment will stay broken, and the user can fix the environment with
'fission env update' (or 'fission env delete' followed by 'fission env
create').
2017-02-09 15:27:57 -08:00
Soam VasaniandGitHub 20baa2ee9d Wait for Pod IP while waiting for pod ready (#89)
Addresses issue #88.
2017-01-25 15:32:34 -08:00
Alexey PalazhchenkoandGitHub 9e01b2f1a7 Make go vet happy 2017-01-24 17:11:26 +03:00
Soam Vasani 5460f8ac05 Delete generic pools when their environment is deleted 2017-01-11 13:35:28 -08:00
Soam Vasani 6af56753ea Cleanup deleted pools, partly implemented 2017-01-09 16:17:30 -08:00
Soam Vasani 0fb12af4e5 add log on specializePod error/clean up 2017-01-06 22:16:49 -08:00
Soam Vasani 3e386fb41d Handle pod cleanup on svc creation error 2017-01-06 22:09:17 -08:00
Soam Vasani e4f7027a69 Reorganize a bit to avoid duplicated error handling 2017-01-06 21:54:15 -08:00
Soam Vasani ebb486d121 Delete pods that failed to load user function 2017-01-06 17:43:03 -08:00
Soam Vasani 37a00b6116 Add cleanup.go 2017-01-06 17:14:54 -08:00
Soam Vasani eccde4fe74 Poolmgr: clean up orphaned resources on restart
Label all poolmgr-created resources with an id that's unique to a
running poolmgr instance.  On poolmgr start up, clean up resources
created by old instances.  Resources that are idle are killed
immediately; resources that could be running a user function are
killed after the maximum function timeout.
2017-01-06 17:01:21 -08:00
Soam Vasani fa272f20a0 Update router cache on new function version
Addresses issue #51. Makes versioning in poolmgr explicit, so its
cache needs no invalidation on version update.  Functions in poolmgr
are always cached by name and UID.

Router now updates implictly versioned routes with the latest version
of a function.

This means that users will see requests to implicitly-versioned routes
go to the latest version of a function within 3 seconds.  (Those 3 sec
will go away when we use a real watch instead of polling the
controller.)

There's no change in behaviour for routes that explictly specify a
function UID.
2017-01-05 15:02:16 -08:00
J. Gavin Ray 943d430870 # This is a combination of 2 commits.
# This is the 1st commit message:

Changed package names to match the new organization

# This is the commit message #2:

Forgot Cache
2016-12-24 08:11:35 -08:00
Soam Vasani f29e69c581 Fix cleanup on duplicate function specialization 2016-12-10 19:55:20 -08:00
Soam Vasani 571fa6b0e7 function service cache test bugfix 2016-12-04 15:23:55 -08:00
Lei Xue c4b7043e70 format poolmgr/gp.go 2016-12-04 14:27:51 +08:00
Soam Vasani 9aab4f0795 Move client-go dependency to 1.5
Client 1.5 is compatible with Kubernetes version 1.3 through 1.5.
2016-11-14 16:25:23 -08:00
Soam Vasani e219804cde Fix segfault in defer statement
A defer statement contained an access to a pointer that was set to
nil before the deferred statement was run; remove it and just
explicity run the statement.
2016-11-11 11:56:19 -08:00
Soam Vasani d8fdd84368 Handle pod specialization errors
Handle pod specialization success/failure better.  Make sure we only
retry on connection failure, otherwise fail immediately.
2016-11-07 12:21:10 -08:00
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