Example #1
0
def _os_is_bad_release(instance: EdenInstance, release: str) -> bool:
    known_bad_kernel_versions = instance.get_config_value(
        "doctor.known-bad-kernel-versions", default="")
    if not known_bad_kernel_versions:
        return False
    for regex in known_bad_kernel_versions.split(","):
        if re.search(regex, release):
            return True  # matched known bad release
    return False  # no match to bad release
Example #2
0
def _os_is_kernel_version_too_old(instance: EdenInstance,
                                  release: str) -> bool:
    min_kernel_version = instance.get_config_value(
        "doctor.minimum-kernel-version", default="")
    if not min_kernel_version:
        return False
    try:
        return _parse_os_kernel_version(release) < _parse_os_kernel_version(
            min_kernel_version)
    except ValueError:
        # If the kernel version failed to parse because one of the
        # components wasn't an int, whatever.
        return False
Example #3
0
def check_disk_usage(
    tracker: ProblemTracker,
    mount_paths: List[str],
    instance: EdenInstance,
    fs_util: FsUtil,
) -> None:
    prob_advice_space_used_ratio_threshold = 0.90
    prob_error_absolute_space_used_threshold = 1024 * 1024 * 1024  # 1GB

    eden_mount_pts_set = get_mount_pts_set(tracker, mount_paths, instance)

    for eden_mount_pt in eden_mount_pts_set:
        if eden_mount_pt and os.path.exists(eden_mount_pt):
            disk_status = fs_util.statvfs(eden_mount_pt)

            avail = disk_status.f_frsize * disk_status.f_bavail
            size = disk_status.f_frsize * disk_status.f_blocks
            if size == 0:
                continue

            used = size - avail
            used_percent = float(used) / size

            message = (
                "Eden lazily loads your files and needs enough disk space to "
                "store these files when loaded."
            )
            extra_message = instance.get_config_value(
                "doctor.low-disk-space-message", ""
            )
            if extra_message:
                message = f"{message} {extra_message}"

            if avail <= prob_error_absolute_space_used_threshold:
                tracker.add_problem(
                    Problem(
                        f"{eden_mount_pt} "
                        f"has only {str(avail)} bytes available. "
                        f"{message}",
                        severity=ProblemSeverity.ERROR,
                    )
                )
            elif used_percent >= prob_advice_space_used_ratio_threshold:
                tracker.add_problem(
                    Problem(
                        f"{eden_mount_pt} "
                        f"is {used_percent:.2%} full. "
                        f"{message}",
                        severity=ProblemSeverity.ADVICE,
                    )
                )