You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a couple of questions on handling idempotent commands, that is commands that when run on the host already are idempotent (at least when they succeed). Specifically the case of package repository updates.
For example xbps-install -S (docs, code) will, when executed, make the local copy of the repodata updated. It only downloads the new repodata if the version on the mirror is newer (it uses etags and modifications dates). xbps-install -S is "idempotent" in itself. But there is no sane way to do the same checks via some custom fact gathering and xbps does not have a working "dry-run" for this case.
The only reasonable thing to do is to execute the command and see what happens.
But here are my questions:
Is there a way to communicate the fact that an operation did not change anything?
It looks to me that the fact that an operation changes anything is derived from whether it yields some commands.
In case of inherently idempotent commands, this makes it impossible to communicate the fact something changed or not, which in turn means that other operations can not be made conditional on that operation. They will always count as changed.
It seems that idempotent operations are called multiple times. Which is kind of weird. What's the difference to operations that set idempotent = False other than the notice in the docs?
I haven't tried it yet, but maybe one solution is to only execute the command when host.in_op is Trueand to execute the command via host.run_shell_command, capturing the output. Depending on the output, either signal a noop or yield an an empty shell command like : (unless there is a direct way to set did_change etc.)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have a couple of questions on handling idempotent commands, that is commands that when run on the host already are idempotent (at least when they succeed). Specifically the case of package repository updates.
For example
xbps-install -S
(docs, code) will, when executed, make the local copy of the repodata updated. It only downloads the new repodata if the version on the mirror is newer (it uses etags and modifications dates).xbps-install -S
is "idempotent" in itself. But there is no sane way to do the same checks via some custom fact gathering and xbps does not have a working "dry-run" for this case.The only reasonable thing to do is to execute the command and see what happens.
But here are my questions:
changed
.idempotent = False
other than the notice in the docs?I haven't tried it yet, but maybe one solution is to only execute the command when
host.in_op
isTrue
and to execute the command viahost.run_shell_command
, capturing the output. Depending on the output, either signal anoop
or yield an an empty shell command like:
(unless there is a direct way to setdid_change
etc.)Beta Was this translation helpful? Give feedback.
All reactions