Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 types and TPR #266

Merged
merged 14 commits into from Aug 5, 2017
Merged

V2 types and TPR #266

merged 14 commits into from Aug 5, 2017

Conversation

soamvasani
Copy link
Member

@soamvasani soamvasani commented Jul 26, 2017

This changes the core fission function, environment and trigger types. It also changes Fission's storage to use ThirdPartyResources.

  1. 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.
  2. Environments have a build and runtime component.
  3. 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.

Operationally, moving our state to TPRs means that users no longer have to maintain an etcd instance just for fission, and they also don't have to use persistent volumes for the fission api server. It also means they can specify functions and triggers declaratively and version control these declarations.

This change breaks compatibility with the v1 Fission API. It removes versioning from the core API. Some points of rationale for this:

  1. Moving our type system closer to Kubernetes architectural patterns is important, gives us declarative infrastructure, allows better interoperability with other K8s projects, and the potential to use tools like Helm to install functions in the future.
  2. Versioning in the v1 Fission API was based on immutability of objects. It also had a very implicit notion of "latest". Both these concepts don't fit cleanly into K8s API patterns.
  3. We also wanted to avoid doing too much in one layer; it is best to look at the core of fission as a platform that you deploy functions into, and implement some sort of "Versioned Function" object on top of this layer.
  4. Adding a v1 compatibility layer was in theory possible, but messy because of the immutability in v1. At the current pre-beta stage of the project it wasn't worthwhile adding and maintaining this complexity.
  5. Broadly, we take breaking compatibility very seriously, but we're early enough in the project to be able to do it.

Note that all v1 environments are still compatible Fission even after the API change. This is largely because environments don't have fission-api-specific stuff in them.

The fission CLI retains all of its old commands, but loses the versioning semantics. To migrate from a v1 to v2 deployment, you have to use the v1 CLI to get functions, envs and triggers; and then use the v2 CLI to create them again. This is a rather manual process. We'll be happy to help anyone having trouble with this process on the fission slack channel.

This is not a complete Environment v2 implementation; the remaining changes for that are:

  1. adding zip file support to fetcher
  2. implementing a storage service for large packages
  3. build management: a build manager to invoke builders, and API and CLI support for running builds, showing errors, etc.

@soamvasani
Copy link
Member Author

cc @yqf3139 @dgoujard This change breaks compatibility with the UI. I was initially planning on a compatiblity layer, but I think it would be better to update the UI for the new types. Let me know if I can help with that in any way.

@yqf3139
Copy link
Contributor

yqf3139 commented Jul 26, 2017

@soamvasani Thanks. I made some experiments with TPR in fission-benchmark. I will work on the new types.

@soamvasani
Copy link
Member Author

Issues #103, #129, #184, #246.

types.go Outdated
// "sha256" is the only currently supported one. Sum is hex
// encoded.
Checksum struct {
Type string `json:"type"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to alias this to ChecksumType, similar to PackageType

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Literal []byte `json:"literal"`

// URL references a package.
URL string `json:"url"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not read through all the changes yet, but why do you need the distinction here between literal and URL? That might be something to extract from the actual Package struct to something like this:

PackageLocation (Url/Filesystem) ---fetch--> Package

That would make the package agnostic of what way it was retrieved.

types.go Outdated
@@ -92,6 +175,52 @@ type (
}

errorCode int

//
// Fission-Environment interface. The following types are not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just about FunctionLoadRequest? For clarity it might be an idea to split these internal type definitions to a separate file/package.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is; I'll split it out.

Metadata `json:"metadata"`
RunContainerImageUrl string `json:"runContainerImageUrl"`
// FunctionSpec describes the contents of the function.
FunctionSpec struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the definition of a function in general or the definition of a (deployed) function instance?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the definition of a fission function. Not sure I get the question, what do you mean by "instance"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I thought there was also a plan to introduce a declarative function definition (something like the serverless.yml file in the serverless framework or npm's package.json). I thought this was it. :P So how do users have to specify package metadata (like the package entrypoint and version) now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the plan for declarative definitions. You can have a yaml file that's the serialized version of these objects, just like any other kubernetes yaml files. (Client tooling to work with those files will be improved in future changes.)

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.
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.
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.
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.
Also adds a poolmgr_test.
Also adds a function reference resolver, which separates out the job
of resolving a FunctionReference to a function.
Remove controllerUrl flag, since we don't need it any more.
Also update the poolmgr commandline, and use an env var for the
fetcher image URL.
@soamvasani soamvasani merged commit e238776 into master Aug 5, 2017
@darkgerm darkgerm deleted the v2-types-and-tpr branch May 25, 2019 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants