FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Introduce new 'ok_when' attribute to let actions be OK instead of SKIPPED by xje4 · Pull Request #1004 · bundlewrap/bundlewrap · GitHub

Introduce new 'ok_when' attribute to let actions be OK instead of SKIPPED - #1004

Open
xje4 wants to merge 1 commit into
bundlewrap:mainfrom
xje4:ok-when
Open

Introduce new 'ok_when' attribute to let actions be OK instead of SKIPPED#1004
xje4 wants to merge 1 commit into
bundlewrap:mainfrom
xje4:ok-when

Conversation

xje4 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

As described in #987 I see the need for a way to let actions gain STATUS_OK to be able to distinguish between a executed-but-failed and a not-executed-because-nothing-to-do action (or any item in general).

Currently, actions may only ever gain STATUS_FIXED, STATUS_SKIPPED or STATUS_FAILED.
This becomes an issue when there's a heavy action which shall only be executed when necessary and other items depending on that action.

When the action succeeds, everything is fine.
Then the second time, the action is skipped because of an unless. And to not skip all dependent items, cascade_skip: False is implied to the action because of the unless attribute.
However, when the action fails, this is treated the same as an unless-skip and since cascade_skip is still false, all dependent items don't care and are executed nonetheless, despite on of their dependencies not being ready.

To solve this, a new ok_when attribute (the name is kinda lame and inspired by Ansible's naming. Open to better naming proposals) is introduced which works kinda like unless, however instead of implying cascade_skip and letting the item be skipped when nothing is to be done, the item just gains STATUS_OK if the condition/test succeeds.

This is basically the action-version of an item whose task is already completed like a file which contains already the expected content or a svc_systemd which is already running and enabled.
Same now goes for an action which just doesn't need to be run because its task has already been fulfilled in the past, there is nothing to fix or do and so the item can just report STATUS_OK.


I've not yet included documentation in this PR as I wanted to know your stance about this change beforehand.
My take for the documentation would be to recommend this attribute over unless because to me it feels much more intuitive that subsequent/dependent items are skipped when an action fails and I've been biten a couple of times with the current behaviour of unless.

…PPED

Currently, actions may only ever gain STATUS_FIXED, STATUS_SKIPPED or
STATUS_FAILED. This becomes an issue when there's a heavy action which shall
only be executed when necessary and other items depending on that action.

When the action succeeds, everything is fine.
Then the second time, the action is skipped because of an `unless`. And to not
skip all dependent items, `cascade_skip: False` is implied to the action
because of the `unless` attribute.
However, when the action fails, this is treated the same as an `unless`-skip
and since `cascade_skip` is still false, all dependent items don't care and
are executed nonetheless, despite on of their dependencies not being ready.

To solve this, a new `ok_when` attribute is introduced which works kinda like
`unless`, however instead of implying `cascade_skip` and letting the item be
skipped when nothing is to be done, the item just gains STATUS_OK if the
condition/test succeeds.
This is basically the `action` version of an item whose task is already
completed like a `file` which contains already the expected content or a
`svc_systemd` which is already running and enabled.
Same now goes for an `action` which just doesn't need to be run because its task
has already been fulfilled in the past, there is nothing to fix or do and so the
item can just report STATUS_OK.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

1 participant


Back | FazBrowse Home | New Git URL