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

api: Add snap info to each task #13902

Conversation

sergio-costas
Copy link
Contributor

@sergio-costas sergio-costas commented Apr 26, 2024

In order to allow Refresh Awareness to be able to link a task to the corresponding snap being refreshed when a single notice contains several snaps, it is a must to include that info into each task.

This patch adds the snap name, snap instance and snap revision (when available) into each task.

This is only required if a change sent through the notices interface to inform about a snap being auto-refreshed after being closed by the user, can hold tasks for more than one snap. If it is guaranteed that only one snap is assigned to a change, then this isn't needed.

Thanks for helping us make a better snapd!
Have you signed the license agreement and read the contribution guide?

@github-actions github-actions bot added the Needs Documentation -auto- Label automatically added which indicates the change needs documentation label Apr 26, 2024
In order to allow Refresh Awareness to be able to link a task
to the corresponding snap being refreshed when a single notice
contains several snaps, it is a must to include that info into
each task.

This patch adds the snap name, snap instance and snap revision
(when available) into each task.
@sergio-costas sergio-costas force-pushed the UDENG-2282-add-snap-info-in-each-task branch from 78f76ac to 0befff6 Compare April 26, 2024 13:33
@sergio-costas sergio-costas changed the title Add snap info to each task api: Add snap info to each task Apr 26, 2024
@pedronis pedronis added the Needs Samuele review Needs a review from Samuele before it can land label Apr 26, 2024
@pedronis pedronis self-requested a review April 26, 2024 16:13
@bboozzoo bboozzoo self-requested a review April 29, 2024 08:54
@sergio-costas
Copy link
Contributor Author

This is only required if a change sent through the notices interface to inform about a snap being auto-refreshed after being closed by the user, can hold tasks for more than one snap. If it is guaranteed that only one snap is assigned to a change, then this isn't needed.

Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

I don't think we want to add these fields directly this way to all tasks, it also doesn't match the approach we use to do similar things for Changes. See suggestions.

Comment on lines +69 to +71
SnapName string `json:"snap-name,omitempty"`
InstanceName string `json:"instance-name,omitempty"`
Revision string `json:"revision,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

we don't want to add this kind of data this way. We probably want to add support instead for something like api-data that we have for Changes. Also (even) if we do that the closest thing we can do that doesn't feel too forced would be to expose a list of instance names "affected-snaps" that matches the same concept in snapstate conflict logic, we would have to expose some of that to daemon

Copy link
Collaborator

Choose a reason for hiding this comment

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

Separately, how are the consumers expected to use this information? Say if a change touches more than one, would they list all the tasks, and then continue observing which ones for which snap are done?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@bboozzoo consumer is expected to poll the associated refresh change, if it happens to include multiple snaps then filtering on the task level is needed.

Check the "Proposed snap-run during refresh UX flow" section in SD167.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can see a video with what I have right now: https://warthogs.atlassian.net/browse/UDENG-2282 , in the most recent comment. As you can see, the idea is to have a progress bar for each snap being updated, and that requires to know how many tasks are assigned to that snap refresh, and how many are already done. Currently I'm presuming that there is one change per snap, so each change has only one snap in its snap_names property, and thus all the tasks belong to that snap. But if there are several snaps in the same change, then each progress bar will show the same progress, unless this patch (or something similar) is implemented, that allows me to separate the tasks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, here is an screen capture
imagen

Copy link
Collaborator

Choose a reason for hiding this comment

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

unclear that "snap-tasks" is a good name for it, so we don't have a good name, also it's not an obvious approach except is compact

Copy link
Collaborator

Choose a reason for hiding this comment

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

also the obvious way to attach the information in snap-tasks form would be when we set snap-names, but actually a Change can grow more tasks after that point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point... if the task list can grow, then it makes sense to include this info in the task.

Copy link
Collaborator

Choose a reason for hiding this comment

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

but actually a Change can grow more tasks after that point

to reiterate on this, snap can pull prerequisites (like a new base) or a re-refresh may occur, at which point the task list will grow again, so any progress bar the user sees will need to be adjusted such that it doesn't jump backwards

Copy link
Collaborator

Choose a reason for hiding this comment

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

Anyway, as I said in the top, if it is guaranteed that, when doing a refresh after the user closes the application, only one snap is associated with each change, this won't be needed. I tried killing two applications "at the same time" using kill XXXXX && kill YYYYY, and still receive two changes, one per snap...

There is still another scenario where snap run of a certain snap is inhibited from running due to a normal refresh/auto-refresh that includes that snap and the progress UI should only be relevant to the snap that is being started and not the other snaps in the auto-refresh. It not just when running the snap after closing.

@pedronis
Copy link
Collaborator

pedronis commented May 2, 2024

we agreed on a different approach, matching more how this works for Changes, as discussed in the comments here. @ZeyadYasser will work on that. Closing this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Documentation -auto- Label automatically added which indicates the change needs documentation Needs Samuele review Needs a review from Samuele before it can land
Projects
None yet
4 participants