Page MenuHomePhabricator

[components-api] decide how to tell webservice components apart from continuous components
Closed, ResolvedPublicBUG REPORT

Description

Currently we treat the component_type field in component config as a nice to have/optional.
We instead look at the run fields as defined in the config and choose the component model that best suits that.

The reason this has worked in the past was because it's structurally impossible for the two components types we support (continuous and scheduled)
to be a subset of each other.
scheduled has a schedule field that continuous will never have, so it's immediately obvious to pydantic which is which.

This is a problem now as we move forward to support webservice component type, because, the only thing that can reliably tell a webservice from a continuous component is the component_type field.
(their fields overlap, and as a result there are some combination of fields that can be mistaken for either webservice or continuous if the component_type field is not provided)

Things to keep in mind

We'll need to figure out migration.
We can do this for sure by bumping config version, and leave behind support code to help parse old config version to the newer version. This might include some prometheus things to detect anyone still using the old config version.

something that helps here is that we can be sure that webservice component_type has never been supported for the old config version, so we can assume that any continuous shaped run belongs to the continuous component_type.

for configs in our storage, we can run a migration script that'd add component_type field to them all.

Update:
We went with @dcaro's suggestion instead of renaming the command field: component_type is required for webservice components only. Continuous and scheduled components without component_type are still picked by their run fields, so no migration is needed, and existing configs keep working.
The trade-off is that component_type is required for one type but optional for the other two. We accepted that to avoid a breaking change for existing configs.

Event Timeline

Raymond_Ndibe changed the task status from Open to In Progress.Sep 29 2026, 2:00 AM
Raymond_Ndibe moved this task from Backlog to In progress on the tools-platform-team board.
aputhin renamed this task from components-api: pick component model based on component-type field, not data shape to [components-api] pick component model based on component-type field, not data shape.Sep 30 2026, 1:39 PM
aputhin triaged this task as High priority.

If we can avoid migrating all existing configs, I think it would be nice.

This is a new feature, and should not require any work from people who are not using webservice components and are happy with their current config.

I would suggest we start by assuming that if component_type: webservice is not specified, then it is not a webservice.

Enforcing component_type as a strictly required parameter is a breaking change and can be done later, with at least one month of notice for users.

One alternative that we discussed today with @dcaro and @Raymond_Ndibe could be to use the publish: field to determine if a component is a web service, e.g. if a component has publish: / in the config, then it should be treated as a web service and not a continuous job.

One alternative that we discussed today with @dcaro and @Raymond_Ndibe could be to use the publish: field to determine if a component is a web service, e.g. if a component has publish: / in the config, then it should be treated as a web service and not a continuous job.

so I played with this even more and while the publish approach is nice, it does prevent you from ever defining a continuous published job in components-api.

We could say good riddance and that if someone really wanted to expose a job to the internet they should just use webservice component and not continuous component.
The problem with that though is that the specific difference between how command is handled in continuous job or webservice job means one might want to just fully customize everything, without using the webservice scripts that webservice jobs use.

Because of this publish is not very ideal, so I'm going with using a different field name like webservice_command or argument etc instead of command for webservice component.
This can be justified because in webservice, command field works more like k8s args (atleast for prebuilt images), where things passed via --command are appended to the default webservice command defined in the image, instead of completely overriding that.
This is very different from how --command works in other job types (and was implemented like so it can have feature parity with webservice-cli).
Here we can indicate that difference with a slightly different command field name,
and as a bonus it solves this problem too.

so I played with this even more and while the publish approach is nice, it does prevent you from ever defining a continuous published job in components-api.

Do you have the code? Seems fixable imo.

so I played with this even more and while the publish approach is nice, it does prevent you from ever defining a continuous published job in components-api.

Do you have the code? Seems fixable imo.

what do you suggest?

I'm going with using a different field name like webservice_command or argument etc instead of command for webservice component

forgot to mention but the above approach just helps to unblock us for now. When we make up our minds on whether to support one-off jobs or not, we'd need to revisit this again (probably more of a problem for one-off jobs, because I have no idea if we can break the ambiguity like we did here).

This is probably the bigger question imo. If we'd still have to face this in the future with one-off jobs what's the point of kicking the can down the road?
It'll probably be better to sit down and decide on a sustainable approach, but we don't have a consensus yet, especially on approaches that'd work here and for one-off jobs or any other thing in the future.

raymond-ndibe closed https://gitlab.wikimedia.org/repos/cloud/toolforge/components-api/-/merge_requests/194

config: change config schema to v1beta2 while maintaining v1beta1 support

so I played with this even more and while the publish approach is nice, it does prevent you from ever defining a continuous published job in components-api.

Do you have the code? Seems fixable imo.

what do you suggest?

Nothing yet, do you have the code for the tests you did where you found that it was preventing you from defining the continuous publish job? I can try to give it a look if you have something.

group_203_bot_3c0afd0d9fd9529f3b7bc7e69a4a3bce opened https://gitlab.wikimedia.org/repos/cloud/toolforge/toolforge-deploy/-/merge_requests/1460

components-api: bump to 0.0.223-20261008141649-232ab50c

Raymond_Ndibe renamed this task from [components-api] pick component model based on component-type field, not data shape to [components-api] decide how to tell webservice components apart from continuous components.Fri, Oct 30, 8:02 PM
Raymond_Ndibe closed this task as Resolved.
Raymond_Ndibe updated the task description. (Show Details)