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

SIP: Application Manifest Redesign #516

Merged
merged 1 commit into from
May 25, 2022
Merged

Conversation

lann
Copy link
Collaborator

@lann lann commented May 20, 2022

@lann lann force-pushed the manifest-redesign-sip branch 3 times, most recently from b32cc08 to 88871f9 Compare May 20, 2022 19:59
Comment on lines +70 to +79
Since this proposal represents a backward-incompatible change to the manifest format, the manifest
version changes. The existing `spin_version = "1"` field name leaves some room for misinterpretation
as "compatible with Spin project version 1". As an optional part of this proposal, change that name:

```toml
spin_manifest_version = "2"
```
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Per discussion with @fibonacci1729 we don't have to do this. See "Don't update the manifest version" below.

Copy link
Contributor

@fibonacci1729 fibonacci1729 May 20, 2022

Choose a reason for hiding this comment

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

I'm in favor of renaming spin_version to spin_manifest_version but I think we should wait to officially freeze version 1 manifest until spin 1.0

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree on this from an aesthetic point of view, but without some sort of schema ID, a user who downloads a new Spin build that changes the schema is going to get cryptic parse errors working with existing manifests. Can we make sure that we do at least enough to give a meaningful error like "this version of the manifest is no longer supported"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Says the man who just changed templates.

@lann lann marked this pull request as ready for review May 20, 2022 20:48
Copy link
Contributor

@fibonacci1729 fibonacci1729 left a comment

Choose a reason for hiding this comment

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

I really like this model!

Copy link
Contributor

@Mossaka Mossaka left a comment

Choose a reason for hiding this comment

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

enjoyed this proposal! Had some minor questions

> In the short term we can continue to enforce the use of exactly one trigger type in an
> application as a manifest validation step.

### Trigger config
Copy link
Contributor

Choose a reason for hiding this comment

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

how will manifest define triggers that are outside of the spin repo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They are identified by string type, which maps to a binary spin-trigger-<type>.

In order to support future features, we would like to enable more flexible trigger configurations:

- Multiple trigger types in an application
- Multiple triggers associated with a single component
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the difference of trigger function signature prevents one component associating with multiple triggers?

For example, a Redis trigger and a HTTP trigger can't associae with a single component since their require linking to different .wit files.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A component can implement multiple interfaces.

Copy link
Member

Choose a reason for hiding this comment

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

Theoretically, you can do that today if you implement and export more than one interface (both the HTTP and the Redis entrypoint) and use the same .wasm file.

Copy link
Contributor

@itowlson itowlson left a comment

Choose a reason for hiding this comment

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

I like this! The compatibility story is good, which minimises the number of people who will go "eh, too hard" and stop kicking the tyres, and I like the improved extensibility and cleaner organisation. A few comments/gripes but I definitely like the direction!

### Trigger IDs

We might want to be able to reference individual triggers, for example to implement a
`spin up --trigger=world`. It would save some compatibility headache if we require IDs now:
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels a bit intrusive in the simple case (which is likely to be common especially amongst the vital tyre-kicker demographic). Could we, say, plan to default the ID to the trigger type, and require IDs only if there are multiple triggers of the same type?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh wait is this meant to refer to individual components under a trigger? (or should I say trigger-config-to-component maps) This is what the example syntax seems to show, but if so I fear we may have two meanings for the term 'trigger'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think my "trigger" is equivalent to your "trigger config". Each trigger has a "type", and a "trigger executor" can serve multiple triggers of a given type.

Copy link
Contributor

Choose a reason for hiding this comment

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

So, in the HTTP case, each route is considered a separate trigger? (And for Redis it would be each channel, etc.?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, and a single component may handle multiple triggers.

Copy link
Member

Choose a reason for hiding this comment

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

This seems really useful especially for testing purposes but it would be really nice if we could make this optional so we can make "the mean time to dopamine" to understand a spin.toml file and spin up as low as possible.

Copy link
Collaborator Author

@lann lann May 23, 2022

Choose a reason for hiding this comment

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

Yeah that's why this idea is down here in "Design options" and not up there 👆 in the proposal. 🙂

### Don't update the manifest version

Instead of updating the manifest version we could not do that. It would be nice to include
error message guidance and/or a `spin doctor` tool to upgrade the manifest format. This
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this - super helpful!

Copy link
Member

Choose a reason for hiding this comment

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

+1 ... I'm such a sucker for cute names like "spin doctor"

```toml
[application]
name = "hello-world"
[application.trigger.http]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a table rather than a table array, which means that (at some point) we can have multiple triggers of different types, but not multiple triggers of the same type, is that right? Or do we envisage revving the version at that point?

(Of course I might just be misunderstanding my TOML syntax here!)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is "application-wide HTTP trigger config". I'm not entirely happy with the syntax, but didn't come up with anything better.

`[[trigger.<type>]]` sections:

```toml
[[trigger.http]]
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I see the value of this over putting the trigger-related config under the component. It adds a layer of indirection which means:

  1. Two places to edit the component ID
  2. When I look at the component it's not obvious what it's hooked up to (e.g. HTTP route)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A couple of motivations:

  • I think it makes more sense conceptually for triggers to be a top-level entity. Another design I considered was just inverting the component/trigger relationship, i.e. turning component.trigger into trigger.component, but:
  • I want to enable HTTP middleware (and other kinds of trigger-component relationships), where a single trigger may reference multiple components (one "handler" and zero+ "interceptors"). I like the consistency of referencing them all by ID.

It's true that it introduces some duplication and potential non-locality, but in practice you can group a trigger and its "main" component together in the file, e.g.:

[[trigger.http]]
route = "/hello"
component = "world"
[[component]]
id = "world"

Copy link
Member

Choose a reason for hiding this comment

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

ref #519

Copy link
Member

Choose a reason for hiding this comment

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

@itowlson's perspective resonates with me because I have been thinking about Spin as a framework for building components and so components are the central subject in my head and everything revolves around them. However, when I tell myself that the spin.toml's job is to wire up triggers to components, then making the triggers a top level entity makes much more sense to me.

@lann lann requested a review from michelleN May 23, 2022 13:14
docs/content/sips/xxx-manifest-redesign.md Show resolved Hide resolved
docs/content/sips/xxx-manifest-redesign.md Show resolved Hide resolved
`[[trigger.<type>]]` sections:

```toml
[[trigger.http]]
Copy link
Member

Choose a reason for hiding this comment

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

@itowlson's perspective resonates with me because I have been thinking about Spin as a framework for building components and so components are the central subject in my head and everything revolves around them. However, when I tell myself that the spin.toml's job is to wire up triggers to components, then making the triggers a top level entity makes much more sense to me.


```toml
[application.trigger.http]
base = "/"
Copy link
Member

Choose a reason for hiding this comment

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

Can this top level application.trigger.http be optional/omitted if folks don't need to change base = "/"? The concept of having a base is a little distracting anyway when first looking at a spin.toml file.

Copy link
Collaborator Author

@lann lann May 23, 2022

Choose a reason for hiding this comment

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

Yes to omitting it if it doesn't need to set anything. I suspect we could drop base entirely, in favor of custom config e.g. route = "{{base}}/route", but I didn't want to drop the "global trigger config" entirely.

### Don't update the manifest version

Instead of updating the manifest version we could not do that. It would be nice to include
error message guidance and/or a `spin doctor` tool to upgrade the manifest format. This
Copy link
Member

Choose a reason for hiding this comment

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

+1 ... I'm such a sucker for cute names like "spin doctor"

### Trigger IDs

We might want to be able to reference individual triggers, for example to implement a
`spin up --trigger=world`. It would save some compatibility headache if we require IDs now:
Copy link
Member

Choose a reason for hiding this comment

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

This seems really useful especially for testing purposes but it would be really nice if we could make this optional so we can make "the mean time to dopamine" to understand a spin.toml file and spin up as low as possible.

Signed-off-by: Lann Martin <lann.martin@fermyon.com>
@lann lann merged commit 0346005 into fermyon:main May 25, 2022
@lann lann deleted the manifest-redesign-sip branch May 25, 2022 15:08
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.

6 participants