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

Fix redis/http triggers #800

Merged
merged 5 commits into from
Oct 3, 2022
Merged

Fix redis/http triggers #800

merged 5 commits into from
Oct 3, 2022

Conversation

etehtsea
Copy link
Contributor

@etehtsea etehtsea commented Oct 2, 2022

chore: Drop trigger-new leftovers

If this is intentional, I'll drop this commit.

fix(spin-redis-engine): Fix error during startup

Steps to reproduce:

spin main $ cargo build
$ cd ..
$ spin/target/debug/spin new redis-rust spin-redis-rust-example
Project description: 
Redis address: redis://localhost:6379
Redis channel: messages
$ cd spin-redis-rust-example
spin-redis-rust-example $ ../spin/target/debug/spin build --up --follow-all
Executing the build command for component spin-redis-rust-example: cargo build --target wasm32-wasi --release
Successfully ran the build command for the Spin components.
Error: Failed to configure Redis trigger

Caused by:
    metadata error: missing required "redis_address"
Error: exit status: 1

Closes #799.

chore(spin-http): Fix base mapping

Set base path in spin-http rather than joining it as part of the route.
Split test configs in spin-testing because the trigger's configuration
is different for http and redis.

The latter isn't a user-facing bug, but the base is set internally to / (because there is no such key in metadata) and all routes have a base prefix in their paths. This commit makes the behavior consistent with the redis trigger.

Also, out of the current testing crate, it looks like it's possible to have different triggers (http and redis) simultaneously in one spin app. According to the current templates, I couldn't figure out how to do this, so I split testing configs for now.

@mikkelhegn
Copy link
Member

I can confirm the redis-rust trigger template works with a build from this PR.

@etehtsea etehtsea force-pushed the fix-trigger branch 4 times, most recently from 8a98bcd to 4b3d985 Compare October 3, 2022 11:26
Refs: fermyon#763.

Signed-off-by: Konstantin Shabanov <mail@etehtsea.me>
Fixes the following error:

$ spin build up --follow-all
<..>
Successfully ran the build command for the Spin components.
Error: Failed to configure Redis trigger

Caused by:
    metadata error: missing required "redis_address"
Error: exit status: 1

Refs: fermyon#763.
Closes fermyon#799.

Signed-off-by: Konstantin Shabanov <mail@etehtsea.me>
Set base path in spin-http rather than joining it as part of the route.
Split test configs in spin-testing because the trigger's configuration
is different for http and redis.

Refs: fermyon#763.

Signed-off-by: Konstantin Shabanov <mail@etehtsea.me>
Signed-off-by: Konstantin Shabanov <mail@etehtsea.me>
Example:

2022-10-03T09:04:25.628294Z ERROR spin_trigger::cli: Trigger executor failed
Error: Redis trigger failed to connect to redis://localhost:6379

Caused by:
    Connection refused (os error 111)
Error: exit status: 1

Closes fermyon#704.

Signed-off-by: Konstantin Shabanov <mail@etehtsea.me>
@lann
Copy link
Collaborator

lann commented Oct 3, 2022

chore: Drop trigger-new leftovers

Thanks. This must have been a bad rebase conflict resolution from right before merging.

Copy link
Collaborator

@lann lann left a comment

Choose a reason for hiding this comment

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

Thanks @etehtsea; clearly we don't have enough test coverage... 😬

Comment on lines -53 to +61
.require_metadata("redis_address")
.context("Failed to configure Redis trigger")?;
.require_metadata::<TriggerMetadata>("trigger")?
.address;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's only been three weeks and I can't even remember switching back to trigger here, let alone why. 🤔

This fix looks correct so I think its good to merge, but I'll probably be reverting this and fixing the matching metadata generation later (which should be fine as the metadata is an unstable interface).

@@ -37,13 +37,18 @@ macro_rules! from_json {
}

#[derive(Default)]
pub struct TestConfig {
pub struct HttpTestConfig {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good change, thanks. 👍

trigger_type = "http";
let route = base.trim_end_matches('/').to_string() + &route;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ugh, missed this in a meta-refactor of the refactor PR.

@lann lann merged commit d6b6ccc into fermyon:main Oct 3, 2022
@etehtsea etehtsea deleted the fix-trigger branch October 3, 2022 14:14
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.

Redis triggered template for rust fails
3 participants