diff --git a/devenv/checks/diskfree.py b/devenv/checks/diskfree.py new file mode 100644 index 00000000..51e2b705 --- /dev/null +++ b/devenv/checks/diskfree.py @@ -0,0 +1,38 @@ +from __future__ import annotations + +import shutil + +from devenv.lib_check.types import checker +from devenv.lib_check.types import fixer + +tags: set[str] = {"builtin"} +name = "there should be sufficient host disk space" + + +@checker +def check() -> tuple[bool, str]: + disk_total, disk_used, disk_free = shutil.disk_usage("/") + disk_gib_free = disk_free / (1024**3) + + if disk_gib_free < 10000: + return ( + False, + f"You have less than 10 GiB disk free ({disk_gib_free} GiB free). " + "You might start to encounter various problems when using colima.", + ) + + return True, "" + + +@fixer +def fix() -> tuple[bool, str]: + return ( + False, + """ + +We can't autofix this, only you can clean up your own disk. + +You might want to try cleaning up unused Docker resources: + docker system prune -a +""", + ) diff --git a/devenv/checks/test.py b/devenv/checks/test.py deleted file mode 100644 index 0a7a6ba2..00000000 --- a/devenv/checks/test.py +++ /dev/null @@ -1,36 +0,0 @@ -from __future__ import annotations - -import os - -from devenv.lib import fs -from devenv.lib import proc -from devenv.lib_check.types import checker -from devenv.lib_check.types import fixer - -tags: set[str] = set() -name = "foo" - - -@checker -def check() -> tuple[bool, str]: - if os.path.exists(f"{fs.gitroot()}/foo"): - return True, "" - return False, f"{fs.gitroot()}/foo doesn't exist" - - -@fixer -def fix() -> tuple[bool, str]: - try: - proc.run( - ( - "/bin/bash", - "-c", - """ -echo blah > foo -""", - ), - cwd=fs.gitroot(), - ) - return True, "" - except RuntimeError as e: - return False, f"{e}" diff --git a/devenv/lib/colima.py b/devenv/lib/colima.py index f9c9e680..2f7715da 100644 --- a/devenv/lib/colima.py +++ b/devenv/lib/colima.py @@ -186,6 +186,10 @@ def start(restart: bool = False) -> ColimaStatus: "colima", "start", "--verbose", + # we're overprovisioning a 512 GiB disk here which is fine because + # the disk doesn't reserve space and is copy-on-write + "--disk", + "512", # this effectively makes the vm's resolvectl status use: # DNS Servers: 8.8.8.8 1.1.1.1 192.168.5.2 # https://lima-vm.io/docs/config/network/user/