Skip to content

Commit

Permalink
storage: Detect unused space in Stratis pools in general
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer committed Jul 7, 2023
1 parent 75ac0ca commit 1232dad
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/storaged/stratis-details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import cockpit from "cockpit";
import React from "react";

import { Alert } from "@patternfly/react-core/dist/esm/components/Alert/index.js";
import { Card, CardBody, CardHeader, CardTitle } from '@patternfly/react-core/dist/esm/components/Card/index.js';
import { DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm } from "@patternfly/react-core/dist/esm/components/DescriptionList/index.js";
import { List, ListItem } from "@patternfly/react-core/dist/esm/components/List/index.js";
Expand Down Expand Up @@ -53,6 +54,14 @@ import { std_reply, with_keydesc, with_stored_passphrase } from "./stratis-utils

const _ = cockpit.gettext;

export function check_stratis_warnings(client, enter_warning) {
for (const p in client.stratis_pools) {
const blockdevs = client.stratis_pool_blockdevs[p] || [];
if (blockdevs.some(bd => bd.NewPhysicalSize[0] && Number(bd.NewPhysicalSize[1]) > Number(bd.TotalPhysicalSize)))
enter_warning(p, { warning: "unused-blockdevs" });
}
}

function teardown_block(block) {
return for_each_async(block.Configuration, c => block.RemoveConfigurationItem(c, {}));
}
Expand Down Expand Up @@ -171,9 +180,27 @@ export function validate_pool_name(client, pool, name) {

export const StratisPoolDetails = ({ client, pool }) => {
const filesystems = client.stratis_pool_filesystems[pool.path];
const blockdevs = client.stratis_pool_blockdevs[pool.path] || [];

const forced_options = ["x-systemd.requires=stratis-fstab-setup@" + pool.Uuid + ".service"];

function grow_blockdevs() {
return for_each_async(blockdevs, bd => pool.GrowPhysicalDevice(bd.Uuid));
}

let alert = null;
if (blockdevs.some(bd => bd.NewPhysicalSize[0] && Number(bd.NewPhysicalSize[1]) > Number(bd.TotalPhysicalSize))) {
alert = (<Alert key="unused-space"
isInline
variant="warning"
title={_("This pool does not use all the space on its block devices.")}>
{_("Some block devices of this pool have grown in size after the pool was created. The pool can be safely grown to use the newly available space.")}
<div className="storage_alert_action_buttons">
<StorageButton onClick={grow_blockdevs}>{_("Grow the pool to take all space")}</StorageButton>
</div>
</Alert>);
}

function delete_() {
const location = cockpit.location;
const usage = get_active_usage(client, pool.path, _("delete"));
Expand Down Expand Up @@ -640,6 +667,7 @@ export const StratisPoolDetails = ({ client, pool }) => {
</Card>);

return <StdDetailsLayout client={client}
alerts={[alert]}
header={header}
sidebar={sidebar}
content={content} />;
Expand Down
3 changes: 3 additions & 0 deletions pkg/storaged/warnings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { get_parent } from "./utils.js";
import { check_mismounted_fsys } from "./fsys-tab.jsx";
import { check_stratis_warnings } from "./stratis-details.jsx";

export function find_warnings(client) {
const path_warnings = { };
Expand Down Expand Up @@ -104,5 +105,7 @@ export function find_warnings(client) {
check_mismounted_fsys(client, path, enter_warning);
}

check_stratis_warnings(client, enter_warning);

return path_warnings;
}

0 comments on commit 1232dad

Please sign in to comment.