Open Gaming4LifeDE opened 3 years ago
This is expected behaviour - no change
applies when no commands are run, in this case apk upgrade
is being executed, which counts as a change - even if the command itself doesn't do anything.
There's a possibility of checking the output and pyinfra could potentially display Success (no change)
or similar...
That's what makes sense form a code perspective but if you read the execution log you'd expect "no change" to be no change and "successful" meaning it was successfully changed. I think this should be thought about again.
Offtopic: Is there a way to execute one operation with a different connector? I wonder if a terraform connector would be feasible. Then you could have a deploy which can first provision the host with terraform and then install stuff onto it via ssh.
I see this both ways; I think ultimately there's three valid results from an operation:
apk update
case)apk upgrade
second run case)The problem with 2 is detecting it - change/no change is decided during the fact gathering phase, before any commands are actually executed. To detect at this point whether any packages will upgrade requires some kind of apk fact/command to identify this. Potentially apk upgrade -s
could do this - but won't take into account any apk update calls beforehand.
So I agree I think it'd be great to highlight this different situation, however I can't currently think of a reasonable way to achieve it without changing how pyinfra executes. One option is the Success (no change)
flag which could highlight this specifically during the execution phase only.
Re: different connector - not currently! There an issue for a @terraform
connector implementation, however, which should make this possible. Currently I'd advise simply calling terraform within the inventory code, and parsing state to get the SSH details.
How about this: before actually running the upgrade command you check if there's available updates and change the state accordingly. Would this work?
Sort of - the problem is the fact gathering phase which determines if an operation us success or no change happens before any operations execute, ie any call to apt.update
would break any check. For your example of apk.update
followed by apk.upgrade
, the sequence of events is roughly:
Fact gathering phase:
apk update
command to be executed laterapk upgrade -s
immediately)No change
Execution phase:
apk update
is executed and the deploy exits
The problem here is that during execution any fact that identifies whether packages will be upgraded becomes invalid afterapk update
is called. This is a limitation of the two phase execution model, which makes it quite hard to fix/improve :/
So I think the only way to really make things like this work (or for example if you're provisioning with Terraform to be able to retrieve the ip) there needs to be a hook which forces pyinfra to check for certain facts only (which would keep the performance impact minimal)
Describe the bug
When running an upgrade through apk, it doesn't correctly detect if anything was actually updated.
Example deploy:
In this case, the server will always reboot. on the actual output it will also always say "success" instead of "no change". See the output below. I ran the deploy twice directly after each other. This is the output of the second run:
To Reproduce
See above
Expected behavior
I expect the operation to yield "no change" instead of "success". It might be neccessary to analyze stdout to make this happen. You could just check if there's more than one line...
Meta
Include output of
pyinfra --support
How was pyinfra installed (source/pip)?
pip
Consider including output with
-vv
and--debug
.