-
Notifications
You must be signed in to change notification settings - Fork 265
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
Manifest V2 #1780
Manifest V2 #1780
Conversation
ebe9287
to
463c86e
Compare
5a72369
to
2fe346d
Compare
@@ -458,6 +461,17 @@ impl AppSource { | |||
} | |||
} | |||
|
|||
impl Display for AppSource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reads more like a Debug implementation than a Display one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is responsible for the updated error message here: https://github.com/fermyon/spin/pull/1780/files#diff-82f776c9616e3a5ecda575278ca8de8a920780afe36b0fff8ab7252292425aad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All I can contribute are a couple eagle-eyed comment fixes 😂
Also wondering what our strategy is around updating example and template app manifests to v2? Perhaps as a follow-up PR before the 2.0 release? (I suppose we'll want to coordinate with developer docs updates as well.)
I
|
Yeah I want to make sure there aren't any major changes to the implementation first. There will be at least a couple of followups. |
These problems with global trigger config will probably require some refactoring of
Suggestions for improving this? The name is secretly meaningful in that it is assigned to the 1st redis trigger. |
Would it be possible to point to the line in the manifest/toml causing the error (as follow-up, if even feasible)? |
Its tricky currently because the trigger config gets validated by the trigger executor which only gets the locked app JSON. I have a couple of ideas for how to improve the error messages with varying degrees of accuracy and complexity, like injecting parse span information from the original manifest into the locked app metadata. If I can't come up with something that works reasonably well for all trigger types (including custom), I can at least (as a fallback) go back to special-casing validation of http triggers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!! I have some questions but mostly because I'm unfamiliar with a lot of this code.
#[serde(default)] | ||
pub id: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd don't love the pattern of deserializing with a defaulted, invalid field that gets updated later. I don't understand the code well enough to offer a suggestion and maybe this just the way it has to be, but if there's some way to rearrange it to not have to do this, that would be awesome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be done differently with more code, but this bit is somewhat of hack to begin with, extracting partial data from a otherwise-possibly-invalid manifest.
0: Failed to load component `hello` | ||
1: One or more allowed_http_hosts entries was invalid: | ||
ftp://random-data-api.fermyon.app isn't a valid host or host:port string | ||
example.com/wib/wob contains a path, should be host and optional port only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fail because of the lack of scheme? Perhaps we could make the error message clearer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷 this is unchanged by this PR; I just added the test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rylev The first one fails because there is a scheme (and it's not a HTTP scheme). The second fails because it contains a path, not just a host. Maybe they look too run-together at the moment which confuses matters? But as Lann says this error message already exists, I can noodle on it separately.
} | ||
|
||
// Copy files matching glob pattern or single file/directory path. | ||
async fn copy_glob_or_path( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these copy methods might be best in a separate module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They use self
...
use ui_testing::{Failed, Normalizer, UiTestsRunner}; | ||
|
||
fn main() -> anyhow::Result<()> { | ||
// Insert dummy wasm into cache to avoid network traffic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by this. Why would the network be hit if we don't add the dummy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
valid-manifest.toml
has a remote source which the loader would (try and fail to) download.
crates/manifest/src/normalize.rs
Outdated
/// Extracts each `ComponentSpec::Inline` into `AppManifest::component`s, | ||
/// replacing it with a `ComponentSpec::Reference`. | ||
pub fn normalize_inline_components(manifest: &mut AppManifest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I'm confused by the name ComponentSpec
, but I'm confused by what this function and normalize_trigger_ids
actually do a high-level (I get that they set some missing values but why?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes code that consumes manifests simpler by not needing to deal with the flexibility that these normalize.
Signed-off-by: Lann Martin <lann.martin@fermyon.com>
Signed-off-by: Lann Martin <lann.martin@fermyon.com>
Move spin-trigger UI tests to spin-loader. Signed-off-by: Lann Martin <lann.martin@fermyon.com>
Signed-off-by: Lann Martin <lann.martin@fermyon.com>
Signed-off-by: Lann Martin <lann.martin@fermyon.com>
This collects some serde tools into a separate crate, avoiding some inter-crate dependencies. Signed-off-by: Lann Martin <lann.martin@fermyon.com>
Signed-off-by: Lann Martin <lann.martin@fermyon.com>
Signed-off-by: Lann Martin <lann.martin@fermyon.com>
Signed-off-by: Lann Martin <lann.martin@fermyon.com>
@lann the "redis-1" error happens in this situation:
I suspect most users are going to think of that as 'the "hello3" trigger' or 'the "hello3" component'. |
Signed-off-by: Lann Martin <lann.martin@fermyon.com>
@itowlson I added some nicer ID normalization; see |
@lann Thanks. That feels more helpful. I have ideas for further heuristics on identifying unnamed components, but the sort of errors I was raising were the result of malicious tinkering - probably better to wait and see if people ever run into them in the wild, and iterate on them at that point. |
Implements SIP-005 as updated in #1753.
Some highlights:
spin-manifest
Application
et al. are no more; there is only theAppManifest
, which closely resembles to the parsedspin.toml
AppManifestV1
. Backward compat is provided byspin_manifest::compat::v1_to_v2_app
.spin-loader
crate takes anAppManifest
and converts it into aLockedApp
, ready to executeui-testing
crate, supporting expanded "UI" (a.k.a. "golden file") test suites for bothspin-manifest
andspin-loader
There are some (intentional) changes open for debate:
kebab-case
. The v1->v2 conversion should make this mostly transparent (searchcomponent_id_from_string
if you care), but there may be some IDs floating around that won't parse now.files
patterns have been relaxed a bit; you can now use the "placement" form for individual files, e.g.{ source = "content/some.txt", destination = "/other.txt" }
"triggers"
key to locked app metadata which is currently redundant but should help with forward-compatibility for multiple-trigger appsStill to do is the
spin doctor
manifest upgrade feature, though hopefully that is pretty simple application of thev1_to_v2_app
code. There are examples of what that should look like incrates/manifest/tests/ui/v1/*.toml.v2