Skip to content

Commit API spec and design doc#444

Merged
evankanderson merged 13 commits intoknative:masterfrom
evankanderson:spec
Mar 27, 2018
Merged

Commit API spec and design doc#444
evankanderson merged 13 commits intoknative:masterfrom
evankanderson:spec

Conversation

@evankanderson
Copy link
Member

@evankanderson evankanderson commented Mar 21, 2018

This is a conversion from GDoc-to-markdown (and cleanup) of the initial API spec written at Google and shared with various partners.

The goal is for this to become the official repo of the API specification.

  • Add images from API draft

Evan Anderson added 2 commits February 15, 2018 20:07
Still TODO:
- Appendices A-E.
- Resolve diffs between spec.md and concrete API definition.
- Define process for updating the API specification.
- Additional API specifications covering:
  * Logging / monitoring / observability contract
  * Runtime container contract / environment
@evankanderson evankanderson requested a review from a team March 21, 2018 18:32
@google-prow-robot google-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 21, 2018
@evankanderson evankanderson self-assigned this Mar 21, 2018

* **Revisions**, which are immutable snapshots of code + config, created by a

* **Configuration**, which acts as a stream of environments for Revisions.
Copy link
Member

Choose a reason for hiding this comment

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

The diagram @mchmarny has in his docs PR would be fantastic here.

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean https://github.com/mchmarny/elafros/blob/master/docs/overview/images/api-objects.png ?

That's one of about 5-6 pictures that needs to be added to the PR.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, exactly.

@evankanderson
Copy link
Member Author

Much credit to @cooperneil for much of the original prose of the document.

* a single resource that can be watched to see a history of all
revisions created

* enables (but doesn’t mandate) PATCH semantics for new revisions to
Copy link
Contributor

Choose a reason for hiding this comment

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

parallelism fail: "provides enables PATCH semantics"

Copy link

Choose a reason for hiding this comment

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

Configuration:

  • provides a single referenceable...
  • provides a single resource ...
  • enables ...
  • provides the ability

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I can just omit "enables" here, and say "provides (but does not mandate) PATCH semantics ..."

change to configuration, such as updating an env variable,
inheriting all other configuration and source/image.

When creating an initial route and performing the first deployment,
Copy link
Contributor

Choose a reason for hiding this comment

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

This paragraph will want to change with a resolution to #412

Choose a reason for hiding this comment

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

I think another layer of this document will be necessary after formalizing #412, but in its original form, this doc describes operating on the core elafros building blocks

  selfLink: ...
...
spec:
rollout:
Copy link
Contributor

Choose a reason for hiding this comment

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

Current API has traffic bumped up a level, and no rollout field.

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, thanks!

- type: BuildFailed
status: True
reason: BuildStepFailed # could also be SourceMissing, etc
# reason is for machine consumption, message is for human consumption

Choose a reason for hiding this comment

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

I think this is in conflict with the recommendation in #351, where:

Reason is typically defined in terms of a string and so the values this takes on (while camelcase words) should be treated as opaque. Clients shouldn't programmatically act on their values, but bias towards using Reason as a terse explanation of the state for end-users

Copy link
Member

Choose a reason for hiding this comment

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

+1

- revisionName: def
percent: 25
conditions:
- type: RolloutInProgress

Choose a reason for hiding this comment

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

In the spirit of making terminal happy-path conditions true, perhaps we should flip this to change RolloutInProgress -> RolloutComplete

Copy link
Member

@mattmoor mattmoor Mar 22, 2018

Choose a reason for hiding this comment

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

We have a Ready condition today, to reflect the time until the referenced Revisions and Configurations are themselves first ready. After it becomes Ready I wouldn't expect transitions such as Configuration rollouts to affect readiness.

RolloutComplete with status: False (or conversely RolloutInProgress) certainly communicate a notable condition, but I wonder if this is adequately covered by .status.traffic and events?

# +optional. composable Build spec, if omitted provide image directly
build: # This is a build.dev/v1alpha1.BuildTemplateSpec
source:
# oneof archive|manifest|repository:
Copy link

@cooperneil cooperneil Mar 21, 2018

Choose a reason for hiding this comment

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

this can be updated with the new proposed Build structure, featuring:
source:
git:
gcs:
custom:

@mattmoor - I can't recall the issue # that describes this form

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.


These are generally software engineres looking to build and run a
stateless software application, without concern about the underlying
infrastructure.
Copy link

Choose a reason for hiding this comment

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

The developer personas are software engineers, who are looking to build and run a stateless software application without having to worry about the underlying infrastructure.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the comma in "software engineers, who are looking to build..." is unnecessary. I'm also unsure what a stateless non-software application would be; is it necessary to mention software? I'd rephrase this as:

The developer personas are software engineers looking to build and run a stateless application without worrying about the underlying infrastructure.

Copy link

Choose a reason for hiding this comment

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

Yes, right on both counts!

Copy link
Member

Choose a reason for hiding this comment

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

typo: engineres

Copy link
Member Author

Choose a reason for hiding this comment

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

D'oh, I copied this from another branch. Well, I'll copy it in because it may be useful, but we should merge it with @mchmarny 's docs.


* Hobbyist
* "Backend" SWE
* "Full stack" SWE
Copy link

Choose a reason for hiding this comment

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

remove quotes:
Backend SWE
Full stack SWE

- Start a build
- Read build logs
* Language operator
- Create a build path/build pack
Copy link

Choose a reason for hiding this comment

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

Maybe, to be parallel with the other sections this should say:

  • Developer (starting a build and reading build logs)
  • Language operator (creating a build path/build pack)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated this to add User stories in addition to the prototypical job roles that the first section had.

of the resource.

* other fields may provide status on the most-recently retrieved state
of the world as it relates to the resource (example: number of
Copy link

Choose a reason for hiding this comment

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

most recently retrieved (no hyphen)
state of the system (not world) or state of the environment?

@@ -0,0 +1,304 @@
# Error Conditions and Reporting

The standard kubernetes API pattern for reporting configuration errors
Copy link

Choose a reason for hiding this comment

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

Kubernetes API (capitalized)

to any or all backing revisions.

**Revision** is an immutable snapshot of code and configuration. A
revision may have been created from a pre-built container image or
Copy link

Choose a reason for hiding this comment

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

may have been => can be

built from source. While there is a history of previous revisions,
only those currently referenced by a Route are addressable or
routable. Older inactive revisions need not be backed by underlying
resources, they may exist only as the revision metadata in
Copy link

Choose a reason for hiding this comment

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

they exist only as revision metadata in storage.


A **Configuration** describes the desired latest Revision state, and
creates and tracks the status of Revisions as the desired state is
updated. A configuration may include instructions on how to transform
Copy link

Choose a reason for hiding this comment

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

may => might

rollouts

* a single resource that can be watched to see a history of all
revisions created
Copy link

Choose a reason for hiding this comment

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

of all the revisions created

* a single resource that can be watched to see a history of all
revisions created

* enables (but doesn’t mandate) PATCH semantics for new revisions to
Copy link

Choose a reason for hiding this comment

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

Configuration:

  • provides a single referenceable...
  • provides a single resource ...
  • enables ...
  • provides the ability

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Super excited to see this. I read through a left comments.

When this goes in, I'll so another pass and open issues for the gaps.


These are generally software engineres looking to build and run a
stateless software application, without concern about the underlying
infrastructure.
Copy link
Member

Choose a reason for hiding this comment

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

typo: engineres

- Start a build
- Read build logs
* Language operator
- Create a build path/build pack
Copy link
Member

Choose a reason for hiding this comment

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

...
status:
latestReadyRevisionName: abc
latestCreatedRevisionName: bcd # Hasn't become became "Ready"
Copy link
Member

Choose a reason for hiding this comment

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

comment needs an update.

conditions:
- type: Complete
status: True
- type: BuildFailed
Copy link
Member

Choose a reason for hiding this comment

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

On the Build resource, this would just be Failed. On the Revision, it is qualified as BuildFailed.

buildLogsLink: "http://logging.infra.mycompany.com/...?filter=..."
conditions:
- type: Complete
status: True
Copy link
Member

Choose a reason for hiding this comment

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

Complete implies success, so given the heading we should remove this in favor of just Failed.

I modeled this after Job, which does the same IIRC.

BuildSpec of a Build resource in the Configuration. This describes:

* **What** to build (`build.source`): Source can be provided as an
archive, manifest file, or repository.
Copy link
Member

Choose a reason for hiding this comment

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

git, gcs, or custom.

build: # build.dev/v1alpha1.BuildTemplateSpec
source:
# oneof archive|manifest|repository:
archive:
Copy link
Member

Choose a reason for hiding this comment

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

update

creation of two Revisions, one with the config change, and the other
with the new code deployment. It is expected that Revision will wait
for the `revisionTemplate.spec.container.image` to be live before
marking the Revision as "ready".
Copy link
Member

Choose a reason for hiding this comment

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

Change this last sentence to waiting for buildName to complete?

source:
# oneof archive|manifest|repository:
archive:
url: https://...
Copy link
Member

Choose a reason for hiding this comment

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

nit: update

revisionTemplate: # template for building Revision
metadata:
labels:
# One-of "function" or "app", convention for CLI/UI clients to list/select
Copy link
Member

Choose a reason for hiding this comment

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

or "container"?

Copy link
Member Author

Choose a reason for hiding this comment

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

"container" is a packaging format. "function" and "app" are calling styles, where a "function" typically has a single named endpoint (and possibly some supporting metadata/discovery URLs about typing etc), while an "app" has multiple HTTP endpoints.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, then I think we need to update like 99% of our samples, which IIRC I switched from serviceType: container to this kind of label w/ container :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I can see about putting together a PR to change this, but "container" doesn't really tell the UI much about what's going on inside (since both functions and apps end up being run as containers).

It's also valid to not supply the label, but then the UI will have to treat the Revision generically.

Copy link
Contributor

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

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

So excited to see these docs in the repo! These will really help people understand the project.

Several of these pages currently have no links into them, could we add some links from DEVELOPMENT.md, maybe CONTRIBUTING.md as well?

Configuration provides:

* a single referenceable resource for the route to perform automated
rollouts
Copy link
Contributor

Choose a reason for hiding this comment

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

your bulleted lists have one line too much whitespace:

  • single referenceable resource for the route to perform automated rollouts

  • a single resource that can be watched to see a history of all revisions created

v.s.

  • single referenceable resource for the route to perform automated rollouts
  • a single resource that can be watched to see a history of all revisions created

The former looks kinda strange, the latter is what one would expect to see and is easier on the eye


* Creating a revision from source

* Creating a function
Copy link
Contributor

Choose a reason for hiding this comment

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

could these be numbered and link to each section? and i think we should have 1 item for each of the 5 examples below e.g.

1. [Automatic rollout of a new Revision to existing Service - pre-built container](#1-automatic-rollout-of-a-new-revision-to-existing-service---pre-built-container)
2. [Creating Route and deploying first Revision - pre-built container](#2-creating-route-and-deploying-first-revision---pre-built-container)
3. [Manual rollout of a new Revision - config change only](#3-manual-rollout-of-a-new-revision---config-change-only)
4. [Deploy a Revision from source](#4-deploy-a-revision-from-source)
5. [Deploy a Function](#5-deploy-a-function)

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a TOC, though I used more free text than the literal section headings. I forget that github markdown doesn't automate convenient navigation.

# Elafros Personas

When discussing user actions, it is often helpful to [define specific
user roles](http://www.agilemodeling.com/artifacts/personas.htm) who
Copy link
Contributor

Choose a reason for hiding this comment

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

can we link to a different source of information about personas? or remove the link if we can't find anything better. the example persona on this page seems like a pretty classic example of 'so easy my grandmother could so it'

GRANDMA GOT STEM

<end of rant>

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I hadn't actually read the persona so much as Googled and picked out the first link where the leading 5 sentences made sense. I switched to Wikipedia, which seems less biased. If you can find a better reference, I'd be happy to switch the link again.

@@ -0,0 +1,21 @@
The goal of the Elafros project is to provide a common toolkit and API
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of making this a separate doc, what do you think about putting this into the main README? it seems like it could be a good intro to the repo/project

Copy link
Member Author

Choose a reason for hiding this comment

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

My plan is that some amount of the stuff in docs is eventually going to live at http://elafros.dev/

I'd be happy to have the README steal from some of these docs, though. (Maybe in a separate PR?)

```


## Configuration
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be handy if these sections in the spec linked back to their explanations in the overview

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 tied in well with @mattmoor's suggestion. (Done)


![Object model](images/object_model.png)

## Route
Copy link
Member

Choose a reason for hiding this comment

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

This is the only heading, which stands out looking at the rendered form.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added headers for the others, to allow reference from other docs.

- type: LatestRevisionReady
status: False
reason: RevisionMissing
message: "The latest Revision appears to have been deleted."
Copy link
Member

Choose a reason for hiding this comment

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

nit: tabs

Copy link
Member Author

Choose a reason for hiding this comment

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

New emacs -- I had indent-tabs-mode non-nil.

# build.template.arguments[_IMAGE], as the "promise" of a future build
# build.template.arguments[_IMAGE], as the "promise" of a future build.
# If buildName is provided, it is expected that this image will be
# present when the referenced build is complete.
Copy link
Member

Choose a reason for hiding this comment

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

nit: tabs

- type: RolloutInProgress
status: False
- type: TrafficDropped
status: False
Copy link
Member

Choose a reason for hiding this comment

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

Doh, these comments don't create links, otherwise they'd be perfect :(

@@ -233,7 +235,7 @@ status:
# the provenance of the revision, from the container
imageSource:
archive|manifest|repository: ...
Copy link
Member

Choose a reason for hiding this comment

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

I think this could use an update (if the intention is to match Build's source 1:1), or maybe even a qualification as something that needs more detailed specification (if we want it to match Grafeas, or some external standard).

$ elafros revisions list --service my-service
Name Traffic Id Date Deployer Git sha
next 0% v3 2018-01-19 12:16 user1 64d79ce
current 100% v2 2018-01-18 20:34 user1 a6f92d1
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, these kind of things just seem to catch my eye for some reason. I'm reminded of the early ECR UI "screenshots" where all of the images had the same digest, but different sizes :)

revisionTemplate: # template for building Revision
metadata:
labels:
# One-of "function" or "app", convention for CLI/UI clients to list/select
Copy link
Member

Choose a reason for hiding this comment

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

Ok, then I think we need to update like 99% of our samples, which IIRC I switched from serviceType: container to this kind of label w/ container :)

@mattmoor
Copy link
Member

/lgtm

@google-prow-robot google-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 27, 2018
@google-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: evankanderson, mattmoor

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [evankanderson,mattmoor]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@evankanderson evankanderson merged commit 5a496e5 into knative:master Mar 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants