Skip to content

Fix subsets inheriting service chaining requirement from whole app #3093

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

itowlson
Copy link
Collaborator

@itowlson itowlson commented Apr 7, 2025

Fixes #2915 and #3088

When an application uses local service chaining, this is noted in the lockfile, so that if a host can't provide the service chaining guarantees, it can reject the application at load time.

Unfortunately, this does not play nicely with application splitting or multi-trigger applications. If a host doesn't support service chaining, it's perfectly safe for that host to run a subset of the app that doesn't use service chaining. But currently this doesn't work because the lockfile's "host requirements" section is calculated on the basis of the whole app not the subset.

I don't much love the fix in this PR. I've added a pass to app splitting/subsetting to recalculate if service chaining is needed, but this duplicates a lot of the existing validation pass. (Perhaps they could/should be combined? Allowing a validator to mutate the validatee revolts my gentle spirit though.) The PR also, of necessity, creates separate lockfiles to pass to different trigger binaries, each with only the components used by the relevant trigger type. This feels like a substantial and complicating change to a simple protocol that has served us well since the early days. I'm also anxious about unintended consequences of deferring the creation of the lockfile.

Anyway putting it up as a draft so that knowledgeable folks can weigh in on better approaches and possible impacts. (And so I can see if it blows up the integration tests!)

cc @kate-goldenring as the app splitting expert!

@itowlson itowlson linked an issue Apr 10, 2025 that may be closed by this pull request
@itowlson
Copy link
Collaborator Author

This turned out to be bad and wrong because it breaks wildcard service chaining. I will look at other ways.

@itowlson itowlson force-pushed the fix-subsets-not-needing-service-chaining branch 3 times, most recently from a1fcfb7 to 3e03d0a Compare April 10, 2025 23:06
@itowlson itowlson marked this pull request as ready for review April 10, 2025 23:08
@itowlson
Copy link
Collaborator Author

Okay I think this is fixed although still unlovely. I'm not sure how to unit-test it though - open to advice!

@@ -213,6 +215,8 @@ impl UpCommand {
)?;
}

self.update_locked_app(&mut locked_app);
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 moved up because the borrow of the trigger type strings (in the next stanza) now lasts longer, so I have to get the mutable borrow out the way first, or the compiler gets mad.

@itowlson
Copy link
Collaborator Author

itowlson commented Apr 10, 2025

A specific concern I have here is that, as I customise the lockfile to each trigger (needed to modify the host requirements), I subset the components to be just the ones needed for that trigger. This worries me because I know Till wants to have "untriggered" components in the manifest that are used e.g. for composition. So maybe I should not filter in the lockfile, but only temporarily (in memory) as part of updating the host requirements.

That said all this makes me lean towards Kate's original proposal of putting host requirements on components rather than apps. This would, I think, remove the need for per-trigger lockfiles, but oh man I am not eager to go through the whole lockfile-revving must-understand dance again... (Plus who knows if we would later find some unavoidably app-level host requirement after all and have to go through all this guff anyway.)

@kate-goldenring
Copy link
Contributor

I know Till wants to have "untriggered" components in the manifest that are used e.g. for composition

For this scenario, are those types of components always pulled in via component dependencies/oci artifacts rather than being a stand alone top level component. (aside: this is where the word "component" is hard in a spin.toml and may be better termed "function".)

@kate-goldenring
Copy link
Contributor

That said all this makes me lean towards Kate's original proposal of putting host requirements on components rather than apps. This would, I think, remove the need for per-trigger lockfiles, but oh man I am not eager to go through the whole lockfile-revving must-understand dance again... (Plus who knows if we would later find some unavoidably app-level host requirement after all and have to go through all this guff anyway.)

I wonder if we need a SIP that defines the unit of an "app" and the unit of a "component". Now that we have app splitting, what are app requirements vs component requirements and is there a third "splice" requirement level too?

Copy link
Contributor

@kate-goldenring kate-goldenring left a comment

Choose a reason for hiding this comment

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

I am mainly wrapping my head around the per-trigger lockfiles and whether there may be tradeoffs due to it.

@itowlson itowlson force-pushed the fix-subsets-not-needing-service-chaining branch from 3e03d0a to c2407a9 Compare April 16, 2025 04:19
Copy link
Contributor

@kate-goldenring kate-goldenring left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for fixing this issue and getting service chaining working to selecting components.

@itowlson
Copy link
Collaborator Author

@lann Do you have a moment to glance over this please? I am still not sure how comfortable I feel about its radicalism, and I think you are more au fait with LockedApps and potential pitfalls in the loader-trigger-engine handoffs than anyone!

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.

Local Service Chaining blocks spin start Feature check is not properly done at trigger level
2 participants