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

Refactor UpCommand #1236

Merged
merged 4 commits into from
Mar 7, 2023
Merged

Refactor UpCommand #1236

merged 4 commits into from
Mar 7, 2023

Conversation

lann
Copy link
Collaborator

@lann lann commented Mar 7, 2023

The most complex refactoring is easier to read in just the second commit: 3073adb

@lann lann marked this pull request as ready for review March 7, 2023 18:27
@lann lann marked this pull request as draft March 7, 2023 18:29
@lann lann marked this pull request as ready for review March 7, 2023 18:57
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.

The refactoring looks great - love getting that knot of application origins untangled and getting a unified path for figuring out the trigger args.

The request changes is for an integration test change that seems unrelated to all this, but appears to be removing a desired check that we've had regressions on in the past. But I may be misunderstanding the change!

@@ -983,7 +986,7 @@ trigger = { type = "http", base = "/" }
version = "0.1.0"
[[component]]
id = "unbuilt"
source = "DOES-NOT-EXIST.wasm"
source = "spin.toml" # dirty trick
Copy link
Contributor

Choose a reason for hiding this comment

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

This appears to be changing the test - the test is meant to assert that help works even when the app has not been build (i.e. source failed to resolve at all). I.e. that spin new > spin up --help works correctly. This seems (if I'm reading it right) to be using a file that exists but isn't valid Wasm, which isn't what this test wants to prove What am I missing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, I didn't realize this was testing that intentionally; indeed this is a regression for that situation. The basic problem is that deep in spin_trigger::locked::build_locked_app we call canonicalize on all our paths, which requires those paths to exist. Maybe I can resolve that problem...

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think that was something Brian hit when trying to unify around the locked app, and is (at least part of) why the local-vs-remote code paths came to diverge.

Copy link
Collaborator Author

@lann lann Mar 7, 2023

Choose a reason for hiding this comment

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

OK it looks like that canonicalize just wasn't (ever?) necessary; Application paths appear to come pre-absolutized.

Copy link
Contributor

Choose a reason for hiding this comment

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

Certainly the local loader tries to absolutise paths as early as possible.

One of these days I want AbsolutePath and RelativePath types so we can document this behaviour at the type level and actually enforce that it remains true...

Copy link
Contributor

Choose a reason for hiding this comment

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

I was just testing this with a malformed spin.toml that is an http trigger, not sure if this has been resolved just yet but i see the following notably missing the trigger options:

❯  spin up -f examples/http-rust -h
spin-up
Start the Spin application

USAGE:
    spin up [OPTIONS]

OPTIONS:
        --direct-mounts         For local apps with directory mounts and no excluded files, mount
                                them directly instead of using a temporary directory
    -e, --env <ENV>             Pass an environment variable (key=value) to all components of the
                                application
    -f, --from <APPLICATION>    The application to run. This may be a manifest (spin.toml) file, a
                                directory containing a spin.toml file, or a remote registry
                                reference. If omitted, it defaults to "spin.toml"
    -h, --help
    -k, --insecure              Ignore server certificate errors from bindle server or registry
        --temp <TMP>            Temporary directory for the static assets of the components

Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh, good catch. I bet an actually malformed spin.toml is a whole new failure mode. Guessing it gets past the "no app so show default trigger options" stage, but then can't deserialise the file to work out the trigger and so gives up rather than calling to help-only trigger. It's an existing problem though, not an issue with this PR; I'd do it as a separate issue.

Signed-off-by: Lann Martin <lann.martin@fermyon.com>
lann added 3 commits March 7, 2023 16:00
Signed-off-by: Lann Martin <lann.martin@fermyon.com>
Signed-off-by: Lann Martin <lann.martin@fermyon.com>
The child process output was only being printed on process failure, not
later test assertions. Printing the output unconditionally allows it to
be seen on any failure without noisy --nocapture.

Signed-off-by: Lann Martin <lann.martin@fermyon.com>
@lann lann merged commit f0f6c5b into fermyon:main Mar 7, 2023
@lann lann deleted the refactor-up-command branch March 7, 2023 21:43
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