[PATCH 0/2] Improved ‘free disk space’ message + a question

  • Open
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Tobias Geerinckx-Rice
Owner
unassigned
Submitted by
Tobias Geerinckx-Rice
Severity
normal
T
T
Tobias Geerinckx-Rice wrote on 1 Sep 2021 21:05
[PATCH 0/2] Improved ‘free disk spa ce’ message + a question
(address . guix-patches@gnu.org)
875yvkaymg.fsf@nckx
Guix,

This improves the warning given when free space looks sus.

From:

note: build failure may have been caused by lack of free disk
space

to:

note: only 0.01 MiB available in ‘/gnu/store’
note: only 5.00 MiB available in ‘/tmp/guix-build-foo.drv-0’
note: build failure may have been caused by lack of free disk
space

It also raises the warning threshold from 8 to 64 MiB, which is a
much prettier arbitrary integer.

Question: shouldn't all of nix/ have licence headers added too?
As it stands, there are two very lonely ones in
nix/libstore/builtins.{cc,hh} and that's it.

Kind regards,

T G-R
-----BEGIN PGP SIGNATURE-----

iIMEARYKACsWIQT12iAyS4c9C3o4dnINsP+IT1VteQUCYS/TNw0cbWVAdG9iaWFz
LmdyAAoJEA2w/4hPVW15AToA/RzLjaZF0+AXwLi4kKPgZUpolZqgIIr68v4Aitss
z1vXAQCY8jx/CBUFuHqevIJtAWbLz7ZQvbD1Fv9uaJPFS1OQAA==
=VAsK
-----END PGP SIGNATURE-----

T
T
Tobias Geerinckx-Rice wrote on 1 Sep 2021 21:25
[PATCH 1/2] daemon: Print which disk(s) are how full.
(address . 50327@debbugs.gnu.org)
20210901192545.12347-1-me@tobias.gr
* nix/libstore/build.cc (pathFull): New function.
(DerivationGoal::buildDone): Use it.
---
nix/libstore/build.cc | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)

Toggle diff (51 lines)
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index 5697ae5a43..963cddb98b 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -1297,6 +1297,25 @@ void replaceValidPath(const Path & storePath, const Path tmpPath)
deletePath(oldPath);
}
+static bool pathFull(Path path)
+{
+#if HAVE_STATVFS
+ unsigned long long required = 8ULL * 1024 * 1024; // FIXME: make configurable
+ struct statvfs st;
+
+ if (statvfs(path.c_str(), &st) == 0) {
+ unsigned long long free = (unsigned long long) st.f_bavail * st.f_bsize;
+ if (free < required) {
+ printMsg(lvlError, format("note: only %1$.2f MiB available in ‘%2%’")
+ % (free / (1024.0 * 1024.0)) % path);
+ return true;
+ }
+ }
+#endif
+
+ return false;
+}
+
MakeError(NotDeterministic, BuildError)
@@ -1355,16 +1374,10 @@ void DerivationGoal::buildDone()
of knowing whether the build actually got an ENOSPC.
So instead, check if the disk is (nearly) full now. If
so, we don't mark this build as a permanent failure. */
-#if HAVE_STATVFS
- unsigned long long required = 8ULL * 1024 * 1024; // FIXME: make configurable
- struct statvfs st;
- if (statvfs(settings.nixStore.c_str(), &st) == 0 &&
- (unsigned long long) st.f_bavail * st.f_bsize < required)
+ if (pathFull(settings.nixStore))
diskFull = true;
- if (statvfs(tmpDir.c_str(), &st) == 0 &&
- (unsigned long long) st.f_bavail * st.f_bsize < required)
+ if (pathFull(tmpDir))
diskFull = true;
-#endif
deleteTmpDir(false);
--
2.32.0
T
T
Tobias Geerinckx-Rice wrote on 1 Sep 2021 21:25
[PATCH 2/2] daemon: Suspect low disk space sooner.
(address . 50327@debbugs.gnu.org)
20210901192545.12347-2-me@tobias.gr
* nix/libstore/build.cc (pathFull): Bump the required free space up to
a more 2021 amount of 64 MiB.
---
nix/libstore/build.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (15 lines)
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index 963cddb98b..f62704a107 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -1300,7 +1300,7 @@ void replaceValidPath(const Path & storePath, const Path tmpPath)
static bool pathFull(Path path)
{
#if HAVE_STATVFS
- unsigned long long required = 8ULL * 1024 * 1024; // FIXME: make configurable
+ unsigned long long required = 64ULL * 1024 * 1024; // FIXME: make configurable
struct statvfs st;
if (statvfs(path.c_str(), &st) == 0) {
--
2.32.0
L
L
Ludovic Courtès wrote on 18 Sep 2021 11:53
Re: bug#50327: [PATCH 0/2] Improved ‘free disk space’ message + a question
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)(address . 50327@debbugs.gnu.org)
87ilyyus4u.fsf_-_@gnu.org
Tobias Geerinckx-Rice <me@tobias.gr> skribis:

Toggle quote (3 lines)
> * nix/libstore/build.cc (pathFull): New function.
> (DerivationGoal::buildDone): Use it.

I’d call it ‘directoryFull’ or ‘partitionFull’. Otherwise LGTM!

Ludo’.
L
L
Ludovic Courtès wrote on 18 Sep 2021 11:55
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)(address . 50327@debbugs.gnu.org)
87ee9mus1x.fsf@gnu.org
Hi,

Tobias Geerinckx-Rice <me@tobias.gr> skribis:

Toggle quote (15 lines)
> This improves the warning given when free space looks sus.
>
> From:
>
> note: build failure may have been caused by lack of free disk space
>
> to:
>
> note: only 0.01 MiB available in ‘/gnu/store’
> note: only 5.00 MiB available in ‘/tmp/guix-build-foo.drv-0’
> note: build failure may have been caused by lack of free disk space
>
> It also raises the warning threshold from 8 to 64 MiB, which is a much
> prettier arbitrary integer.

LGTM. :-)

Eventually we should i18n messages coming from the daemon.

Toggle quote (4 lines)
> Question: shouldn't all of nix/ have licence headers added too? As it
> stands, there are two very lonely ones in
> nix/libstore/builtins.{cc,hh} and that's it.

Yeah well, they were taken as-is from Nix. I wouldn’t bother,
especially since we wouldn’t what copyright holders to list in there.

Thanks!

Ludo’.
?