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

Fix test evaluation in restrict-eval #50342

Closed
wants to merge 2 commits into from
Closed

Conversation

Ekleog
Copy link
Member

@Ekleog Ekleog commented Nov 14, 2018

This will be more easily reviewed commit-by-commit.

For the revCount reset, I'm not 100% sure of myself, but with shortRev being a placeholder and the previous value being 56789 I'm ~99% sure it was supposed to be a placeholder too.

I have checked that the --option restrict-eval true reproducers now appear to build correctly locally.

Commit messages for easier reading:

release: reset revCount to a dummy placeholder

Placeholder had been removed in 7e968a4.

Additionally, bumps the revCount from release-small.nix and
release-combined.nix so that it's more obvious it's a placeholder.

CC: @vcunat

release: do not cleanSource when evaluating in restrict-eval

The current behavior, breaking restrict-eval=true, had been introduced
in 209f8b1. See also [1].

This change uses a hack to identify whether we're evaluating in
restrict-eval, keeping the optimization when not and reverting to the
old behavior when evaluating in restrict-eval.

This should fix the issues that appeared at [2] and [3], that followed
the change making us actually use this nixpkgs argument for tests
since 83b27f6 [4].

CC: @roberth

[1] 209f8b1acd4c#commitcomment-28419462

[2] #50233 (comment)

[3] #50186

[4] #50233

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

Placeholder had been removed in 7e968a4.

Additionally, bumps the `revCount` from `release-small.nix` and
`release-combined.nix` so that it's more obvious it's a placeholder.

CC: @vcunat
The current behavior, breaking restrict-eval=true, had been introduced
in 209f8b1. See also [1].

This change uses a hack to identify whether we're evaluating in
restrict-eval, keeping the optimization when not and reverting to the
old behavior when evaluating in restrict-eval.

This should fix the issues that appeared at [2] and [3], that followed
the change making us actually use this `nixpkgs` argument for tests
since 83b27f6 [4].

CC: @roberth

[1] NixOS@209f8b1acd4c#commitcomment-28419462

[2] NixOS#50233 (comment)

[3] NixOS#50186

[4] NixOS#50233
@Ekleog
Copy link
Member Author

Ekleog commented Nov 14, 2018

Sanity-check: all four should eval & pass.

@GrahamcOfBorg build opensmtpd
@GrahamcOfBorg test opensmtpd
@GrahamcOfBorg build nixosTests.opensmtpd
@GrahamcOfBorg build opensmtpd.tests

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: opensmtpd

Partial log (click to expand)

these paths will be fetched (0.27 MiB download, 0.83 MiB unpacked):
  /nix/store/glgplaqzqf8qgggbyd2rx59sz3gkk3pr-libasr-1.0.2
  /nix/store/vyv90gc4i8yf5p3bdjihpms3fi0sk9y9-opensmtpd-6.4.0p2
copying path '/nix/store/glgplaqzqf8qgggbyd2rx59sz3gkk3pr-libasr-1.0.2' from 'https://cache.nixos.org'...
copying path '/nix/store/vyv90gc4i8yf5p3bdjihpms3fi0sk9y9-opensmtpd-6.4.0p2' from 'https://cache.nixos.org'...
/nix/store/vyv90gc4i8yf5p3bdjihpms3fi0sk9y9-opensmtpd-6.4.0p2

Ekleog referenced this pull request Nov 14, 2018
Currently, when building NixOS from a git clone, Nix has to copy
the entire repo at >1GB into the store by default. That is not
necessary and causes a dumping large path message.
If you need the old behaviour for some reason, you will have to
specify it by passing the path to your repo explicitly as the
nixpkgs argument like this:

  --arg nixpkgs '{outPath = ./.; revCount = 56789; shortRev = "gfedcba"; }'
@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: opensmtpd

Partial log (click to expand)

shrinking /nix/store/xq5cnzxfw4ad6cmljkfffvs5s134qif0-opensmtpd-6.4.0p2/libexec/opensmtpd/mail.lmtp
shrinking /nix/store/xq5cnzxfw4ad6cmljkfffvs5s134qif0-opensmtpd-6.4.0p2/sbin/smtpctl
shrinking /nix/store/xq5cnzxfw4ad6cmljkfffvs5s134qif0-opensmtpd-6.4.0p2/sbin/smtpd
gzipping man pages under /nix/store/xq5cnzxfw4ad6cmljkfffvs5s134qif0-opensmtpd-6.4.0p2/share/man/
strip is /nix/store/p9akxn2sfy4wkhqdqa3li97pc6jaz3r1-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/xq5cnzxfw4ad6cmljkfffvs5s134qif0-opensmtpd-6.4.0p2/libexec  /nix/store/xq5cnzxfw4ad6cmljkfffvs5s134qif0-opensmtpd-6.4.0p2/bin  /nix/store/xq5cnzxfw4ad6cmljkfffvs5s134qif0-opensmtpd-6.4.0p2/sbin
patching script interpreter paths in /nix/store/xq5cnzxfw4ad6cmljkfffvs5s134qif0-opensmtpd-6.4.0p2
checking for references to /build in /nix/store/xq5cnzxfw4ad6cmljkfffvs5s134qif0-opensmtpd-6.4.0p2...
moving /nix/store/xq5cnzxfw4ad6cmljkfffvs5s134qif0-opensmtpd-6.4.0p2/sbin/* to /nix/store/xq5cnzxfw4ad6cmljkfffvs5s134qif0-opensmtpd-6.4.0p2/bin
/nix/store/xq5cnzxfw4ad6cmljkfffvs5s134qif0-opensmtpd-6.4.0p2

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: nixosTests.opensmtpd

Partial log (click to expand)

smtp2: running command: sync
smtp2: exit status 0
test script finished in 35.89s
cleaning up
killing smtp1 (pid 597)
killing client (pid 609)
killing smtp2 (pid 621)
vde_switch: EOF on stdin, cleaning up and exiting
vde_switch: Could not remove ctl dir '/build/vde1.ctl': Directory not empty
/nix/store/j1c7vdfn4ij602lqck7594q94p5adfgh-vm-test-run-opensmtpd

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: tests.opensmtpd

Partial log (click to expand)

smtp2: running command: sync
smtp2: exit status 0
test script finished in 19.19s
cleaning up
killing smtp1 (pid 597)
killing client (pid 609)
killing smtp2 (pid 621)
vde_switch: EOF on stdin, cleaning up and exiting
vde_switch: Could not remove ctl dir '/build/vde1.ctl': Directory not empty
/nix/store/j1c7vdfn4ij602lqck7594q94p5adfgh-vm-test-run-opensmtpd

@Ekleog Ekleog mentioned this pull request Nov 14, 2018
@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: opensmtpd.tests

Partial log (click to expand)

/nix/store/j1c7vdfn4ij602lqck7594q94p5adfgh-vm-test-run-opensmtpd

@GrahamcOfBorg
Copy link

Unexpected error: command failed with exit code 1 on aarch64-linux (full log)

Attempted: opensmtpd.tests

Partial log (click to expand)

cannot build derivation '/nix/store/lj3mw0h813c2qi7kswwm9z3isvcdhqgw-closure-info.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/bdbqnna8pf6zvpn7dl5b6jz3dm88839a-run-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/j49rlrh6wx06rj06h9q8j9ly7cdksihf-run-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/nf8icilsjfadbnq02x7qj3iz5b66yyp3-run-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/0rxfqy5kvpjafl5ryn53qdjs1p13w2vw-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/1sdlvq13780aib6bg66ipb4jlxv6b0qk-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/nr6x4wfz32vqwj3l2flw51a5bh5ccnx0-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/2d5w2kqrnym0gkdmbi44m9s954ch570d-nixos-test-driver-opensmtpd.drv': 3 dependencies couldn't be built
cannot build derivation '/nix/store/30ydhy2dn50bjfvqgji4plrmbbx12svh-vm-test-run-opensmtpd.drv': 1 dependencies couldn't be built
error: build of '/nix/store/30ydhy2dn50bjfvqgji4plrmbbx12svh-vm-test-run-opensmtpd.drv' failed

@GrahamcOfBorg
Copy link

Unexpected error: command failed with exit code 1 on aarch64-linux (full log)

Attempted: nixosTests.opensmtpd

Partial log (click to expand)

cannot build derivation '/nix/store/lj3mw0h813c2qi7kswwm9z3isvcdhqgw-closure-info.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/bdbqnna8pf6zvpn7dl5b6jz3dm88839a-run-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/j49rlrh6wx06rj06h9q8j9ly7cdksihf-run-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/nf8icilsjfadbnq02x7qj3iz5b66yyp3-run-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/0rxfqy5kvpjafl5ryn53qdjs1p13w2vw-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/1sdlvq13780aib6bg66ipb4jlxv6b0qk-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/nr6x4wfz32vqwj3l2flw51a5bh5ccnx0-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/2d5w2kqrnym0gkdmbi44m9s954ch570d-nixos-test-driver-opensmtpd.drv': 3 dependencies couldn't be built
cannot build derivation '/nix/store/30ydhy2dn50bjfvqgji4plrmbbx12svh-vm-test-run-opensmtpd.drv': 1 dependencies couldn't be built
error: build of '/nix/store/30ydhy2dn50bjfvqgji4plrmbbx12svh-vm-test-run-opensmtpd.drv' failed

@Ekleog
Copy link
Member Author

Ekleog commented Nov 14, 2018

Well… these unexpected errors sure are weird (esp. as they usually appear as “Failure on […]”), but it appears to eval correctly, so I'd guess it's unrelated to the problem addressed here.

@GrahamcOfBorg
Copy link

Unexpected error: command failed with exit code 1 on aarch64-linux (full log)

Attempted: tests.opensmtpd

Partial log (click to expand)

cannot build derivation '/nix/store/lj3mw0h813c2qi7kswwm9z3isvcdhqgw-closure-info.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/bdbqnna8pf6zvpn7dl5b6jz3dm88839a-run-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/j49rlrh6wx06rj06h9q8j9ly7cdksihf-run-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/nf8icilsjfadbnq02x7qj3iz5b66yyp3-run-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/0rxfqy5kvpjafl5ryn53qdjs1p13w2vw-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/1sdlvq13780aib6bg66ipb4jlxv6b0qk-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/nr6x4wfz32vqwj3l2flw51a5bh5ccnx0-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/2d5w2kqrnym0gkdmbi44m9s954ch570d-nixos-test-driver-opensmtpd.drv': 3 dependencies couldn't be built
cannot build derivation '/nix/store/30ydhy2dn50bjfvqgji4plrmbbx12svh-vm-test-run-opensmtpd.drv': 1 dependencies couldn't be built
error: build of '/nix/store/30ydhy2dn50bjfvqgji4plrmbbx12svh-vm-test-run-opensmtpd.drv' failed

@edolstra
Copy link
Member

Ideally we would use fetchGit ./.. That ensures a tree without untracked files and sets revCount properly. There could be a fallback for the case when we're not building from a Git repository (e.g. if pathExists ./.git then ./. else fetchGit ./.).

@edolstra
Copy link
Member

BTW I don't understand the motivation for this change. In Hydra evaluations, we should not need the default value for the nixpkgs argument since nixpkgs is passed in by Hydra.

@Ekleog
Copy link
Member Author

Ekleog commented Nov 14, 2018

@edolstra The reason for this change is at least for ofborg, that appears not to pass a value for nixpkgs (see the ofborg failures of #50186, that no longer reproduced once tested here). It has also independently been reported at 209f8b1acd4c#commitcomment-28419462 and #50233.

Now, I hoped it was the reason why hydra appears to have no evaluations in the last 3 days on nixos-unstable. If that's not it, then I don't see how it can be related to #50233, so maybe it isn't? I can't reproduce locally any of the issues linked above with this change, at least.

As for fetchGit, wouldn't that result in IFD just like cleanSource does (before this PR)? Also, I'd think users would actually expect their local (uncommitted) nixpkgs patches to be taken into account when they build it locally.

(by the way, just in case: I noticed hydra didn't have a successful evaluation in 3 days just earlier today, otherwise I'd likely have asked someone to backout #50233 if it took me 3 days to come up with this fix)

@LnL7
Copy link
Member

LnL7 commented Nov 14, 2018

I guess it kind of depends on what we consider more important for ofborg to test. If it's hydra then doing the same (eg. NixOS/ofborg#189) is the proper solution.

@edolstra
Copy link
Member

Yeah, it's probably best if ofborg does what Hydra does (i.e. pass a nixpkgs argument).

@LnL7
Copy link
Member

LnL7 commented Nov 14, 2018

Using --arg doesn't influence imports right? one thing we do want to verify is that expressions don't depend on <nixpkgs> in unexpected places. Since that's usually available while testing but can lead to unexpected behaviour.

@edolstra
Copy link
Member

@LnL7 It doesn't. Actually Hydra does add jobset inputs to NIX_PATH, but probably it's better not to emulate that behaviour.

@Ekleog
Copy link
Member Author

Ekleog commented Nov 15, 2018

Semi-relatedly: this change also unbreaks evaluation when manually running nix-build --option restrict-eval true nixos/release.nix -A tests.env, as well as being a hotfix for the current ofborg issue :)

Also, it looks like this was not actually the cause of hydra not advancing, so for hydra the point here is moot.

{ nixpkgs ? { outPath = cleanSource ./..; revCount = 130979; shortRev = "gfedcba"; }
# `revCount` and `shortRev` are placeholders, that should be filled
# automatically for releases by passing the `nixpkgs` argument
{ nixpkgs ? { outPath = cleanSourceForImport ./..; revCount = 654321; shortRev = "gfedcba"; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This revcount isn't a placeholder, it is updated when new channels are cut.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grahamc Are you sure about that? I ran git log -p nixos/release.nix before writing this comment, and it was set to 56789 since May 2014 before 18.03 cut-off (and before that it was set to 5678 since Oct 2013, and before that to a mix of 1234 for nixosSrc and 5678 for nixpkgs), and it hasn't been updated when cutting out 18.09. This is the reason why I thought @vcunat's updating it when 18.03 was cut was potentially a mistake, but…?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grahamc I'd like to try and move this forward. Could you either confirm, infirm or say you don't have time to evaluate my statement above? :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have time to dive deeper, however, I thought:

Update versionSuffix in nixos/release.nix, use git log --format=%an|wc -l to get the commit count

was supposed to include updating this count. (https://nixos.org/nixos/manual/index.html#at-beta-release-time)

Maybe I'm wrong, and I trust you to do the digging, and I don't feel like I need to be part of making the decision if this is true.

@mmahut
Copy link
Member

mmahut commented Aug 12, 2019

Are there any updates on this pull request, please?

@stale
Copy link

stale bot commented Jun 1, 2020

Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the
    related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse. 3. Ask on the #nixos channel on
    irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 1, 2020
@Ekleog
Copy link
Member Author

Ekleog commented Jan 2, 2021

Well… I've been unable to reproduce the problem listed in the top post on current master, with either of:

sudo nix-build -I nixpkgs=. --option restrict-eval true nixos/release.nix -A tests.env           
sudo nix-build -I nixpkgs=. --option restrict-eval true nixos/release.nix -A nixosTests.opensmtpd

As such, I guess this has been done again by someone in the meantime while I had completely forgotten about this PR, and I'll close this.

If the original issue wasn't actually closed in the meantime, feel free to poke me and/or reopen this as a custom PR, it looks like it doesn't have too many merge conflicts even nowadays 2 years after the initial opening, so hopefully it'll stay easily un-merge-conflict-able! :)

@Ekleog Ekleog closed this Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: nixos 10.rebuild-darwin: 0 10.rebuild-linux: 0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants