Open dcarosone opened 11 months ago
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
Hm, not all errors are getting squashed. From an earlier run, where I hadn't set the ?ref=branchname
argument in the flake config:
Dec 12 17:02:02 rocinante systemd[1]: Starting NixOS Upgrade...
Dec 12 17:02:02 rocinante nixos-upgrade-start[27669]: [12B blob data]
Dec 12 17:02:02 rocinante nixos-upgrade-start[27683]: fatal: couldn't find remote ref refs/heads/0d0e27dfa3c393811ea9d2fc6f538e7f17b8772c
Dec 12 17:02:02 rocinante nixos-upgrade-start[27669]: [10B blob data]
Dec 12 17:02:02 rocinante nixos-upgrade-start[27669]: … while fetching the input 'git+ssh://rocinante@soft-serve:23231/geek/nixos'
Dec 12 17:02:02 rocinante nixos-upgrade-start[27669]: error: program 'git' failed with exit code 128
Dec 12 17:02:02 rocinante systemd[1]: nixos-upgrade.service: Main process exited, code=exited, status=1/FAILURE
Dec 12 17:02:02 rocinante systemd[1]: nixos-upgrade.service: Failed with result 'exit-code'.
Dec 12 17:02:02 rocinante systemd[1]: Failed to start NixOS Upgrade.
Dec 12 17:02:02 rocinante systemd[1]: nixos-upgrade.service: Consumed 82ms CPU time, received 3.1K IP traffic, sent 4.2K IP traffic.
So.. uhh..
is the automatic offline detection causing errors to be ignored from network-using tasks? If so that's terribly counterproductive in at least this case, and should either be fixed or warrants the --require-online
reverse option.
After pondering on this for a while, I'm becoming more convinced that the issue is nix itself:
--offline
had been passed explicitly, based on some auto-detection of connectivity--refresh
that was passed explicitlyI have masked this with a service preStart
that checks ssh connectivity to the git repo server, which will fail and allow systemd retries. But that should not be necessary and these errors should be returned.
Describe the bug
autoUpgrade service doesn't fail when steps within the process have errors. nixos-rebuild seems to be swallowing them.
As well as simply not doing the intended job of upgrading, this can actually cause configuration to go backwards.
Steps To Reproduce
Steps to reproduce the behaviour:
network-online.target
but this is not meaningful after a resume, unfortunately.--refresh
argument is given with a flake, it will use the previously-cached fetch from the last run, which should be considered stale and invalid. The build proceeds anyway./etc/nixos/flake.nix
for example), the autoupgrade service will build and switch to the older revision, effectively rolling back unexpectedly.Expected behaviour
Issues and errors, such as lack of network connectivity for an upgrade, should be considered as errors for the rebuild, and cause the service to fail (so it can optionally then be configured to retry with a delay).
The
--refresh
argument should consider cached copies of the flake source as invalid (as documented) and refuse to use them.Screenshots
In the below log, wifi was disabled. The autoUpgrade service is configures with a
git+ssh://
flake repo.Without
--refresh
in theoptions
list, the ssh errors don't appear, presumably because the 'network-dependent features' have been disabled. With--refresh
they're tried anyway but the errors are ignored.Additional context
It also seems to rebuild and switch when there's full network connectivity but no new revisions are fetched, regardless of whether this is because (without
--refresh
) the content is still within TTL, or simply no new revisions are found on the git repo. I don't think this is necessary.It might be helpful to have an option that's the inverse of
--offline
that seems to be getting detected.. something like--require-online
such that it can bail directly from this autodetection before even getting to the other steps. But it should still bail on those other errors, and it should very-definitely not roll back by building and switching to a stale revision.See also:
261495, #73945
Notify maintainers
Metadata
"x86_64-linux"
Linux 6.1.67, NixOS, 24.05 (Uakari), 24.05.20231211.a9bf124
yes
yes
nix-env (Nix) 2.18.1
""
nixpkgs:
/nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source
Add a :+1: reaction to issues you find important.