Skip to content

support byte-based storage watermark#141

Merged
detsch merged 3 commits into
mainfrom
detsch-bytes-watermark
Jun 19, 2026
Merged

support byte-based storage watermark#141
detsch merged 3 commits into
mainfrom
detsch-bytes-watermark

Conversation

@detsch

@detsch detsch commented Jun 17, 2026

Copy link
Copy Markdown
Member

Allow storage watermark to be set as bytes as well, for internal API, and CLI check and pull operations.

Re-use existing command line option. Interpret value as percentage as default (previous behavior), and as bytes if if has a suffix like "B" "GiB", etc.

GetUsageInfo only accepted a percentage watermark, so callers wanting to
keep a fixed amount of free space on large partitions had to derive and
apply the reserved bytes themselves. Add a watermarkInBytes flag so the
watermark is interpreted either as a percentage of total size or as an
absolute reserved free-space amount, keeping the available-space math in
one place.

Signed-off-by: Andre Detsch <andre.detsch@foundries.io>
Assisted-by: Claude Code:claude-opus-4-8
Comment thread cmd/composectl/cmd/pull.go Outdated
fmt.Fprintln(os.Stderr,
"warning: both --storage-usage-watermark and --reserved-storage are set; ignoring --storage-usage-watermark")
}
reserved, err := units.RAMInBytes(reservedStorage)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would be great if we support both formats "MiB" and "MB". I think if we add add a wrapper like the following then we'll get it:

func ParseSize(s string) (int64, error) {
    if strings.Contains(strings.ToLower(s), "ib") {
        return units.RAMInBytes(s)
    }
    return units.FromHumanSize(s)
}

@mike-sul mike-sul left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Just not critical suggestion to improve UX.

detsch added 2 commits June 19, 2026 14:08
The pull command only bounded storage usage via the percentage
--storage-usage-watermark, a clumsy way to reserve a fixed amount of
free space on large partitions. Add a separate --reserved-storage flag
that takes an absolute size (e.g. "2GiB") so the two meanings stay
unambiguous instead of overloading a single flag.

reserved-storage takes precedence over --storage-usage-watermark: when
both are set the percentage watermark is ignored and a warning is
printed. GetUsageInfo is unchanged; the flags are resolved into its
existing (watermark, inBytes) pair.

Signed-off-by: Andre Detsch <andre.detsch@foundries.io>
Assisted-by: Claude Code:claude-opus-4-8
Mirror the pull command so check exposes the same --reserved-storage
flag for an absolute reserved free space (e.g. "2GiB") alongside the
percentage --storage-usage-watermark, keeping the two commands
consistent.

reserved-storage takes precedence over --storage-usage-watermark; the
resolution (including the both-set warning) is shared via
resolveWatermark.

Signed-off-by: Andre Detsch <andre.detsch@foundries.io>
Assisted-by: Claude Code:claude-opus-4-8
@detsch detsch force-pushed the detsch-bytes-watermark branch from 4201e49 to a1b3a4b Compare June 19, 2026 17:27
@detsch detsch merged commit 3b95298 into main Jun 19, 2026
4 checks passed
@detsch detsch deleted the detsch-bytes-watermark branch June 19, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants