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

Allow specifying a fallback task #185

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

Conversation

jjcarstens
Copy link

In very specific cases, it might be desirable to fallback to another
task when the target task fails. Most commonly this will be falling
back to the complete task when the upgrade fails due to the firmware
not having a previous firmware.

The fallback will only occur if the failure is withing the tasks functions
so checks before and after the task do not trigger a fallback (i.e. issues
with archive or config file)

This is inspired by nerves-project/nerves#682

In very specific cases, it might be desirable to fallback to another
task when the target task fails. Most commonly this will be falling
back to the `complete` task when the `upgrade` fails due to the firmware
not having a previous firmware.

The fallback will only occur if the failure is withing the tasks functions
so checks before and after the task do not trigger a fallback (i.e. issues
with archive or config file)

This is inspired by nerves-project/nerves#682
@fhunleth
Copy link
Collaborator

Thanks!

There's already a task failback code with --task, but it's inflexible. It supports falling back to an arbitrary number of tasks, but they all have to have the same prefix (like to try upgrade.a, upgrade.b, etc. when you just specify --task upgrade). I think that it can be made more flexible and do what you want without adding a new parameter. This will also have the nice property of letting you have n failbacks rather than just one.

The options that I can think of are to specify --task <task1>[:<task2>...] or to specify --task multiple times. Perhaps it doesn't matter. One concern is making it not look like all tasks would be run. We can't use the normal logical or character, ||, to separate tasks since that will be annoying to type in a shell. Perhaps : would be an ok separator.

I'll think more and take a look. This feels like it could end up being a small change.

@jjcarstens
Copy link
Author

I started to notice the inflexible fallback, but didn't quite see how we could make it fallback to another task vs just repeating existing tasks instructions.

I like the idea of N fallbacks. I think using the : delimiter is more favorable than multiple --task

@fhunleth
Copy link
Collaborator

Let me take a look this week. I'll post back.

jjcarstens added a commit to jjcarstens/fwup that referenced this pull request Sep 17, 2022
Based on the discussion in fwup-home#185

The idea is that you can specify a list of tasks with `-t` and fwup
will try each one until the first success supporting a "fallback"
behavior
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.

2 participants