Skip to content

Commit

Permalink
feat: accept up to 2 decimals of precision for check % and prune % po…
Browse files Browse the repository at this point in the history
…licies
  • Loading branch information
garethgeorge committed Aug 15, 2024
1 parent a67c29b commit 5374273
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
6 changes: 3 additions & 3 deletions gen/go/v1/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/orchestrator/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (r *RepoOrchestrator) Check(ctx context.Context, output io.Writer) error {
switch m := r.repoConfig.CheckPolicy.Mode.(type) {
case *v1.CheckPolicy_ReadDataSubsetPercent:
if m.ReadDataSubsetPercent > 0 {
opts = append(opts, restic.WithFlags(fmt.Sprintf("--read-data-subset=%v%%", m.ReadDataSubsetPercent)))
opts = append(opts, restic.WithFlags(fmt.Sprintf("--read-data-subset=%.4f%%", m.ReadDataSubsetPercent)))
}
case *v1.CheckPolicy_StructureOnly:
default:
Expand Down
2 changes: 1 addition & 1 deletion proto/v1/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ message CheckPolicy {

oneof mode {
bool structure_only = 100 [json_name="structureOnly"]; // only check the structure of the repo. No pack data is read.
int32 read_data_subset_percent = 101 [json_name="readDataSubsetPercent"]; // check a percentage of pack data.
double read_data_subset_percent = 101 [json_name="readDataSubsetPercent"]; // check a percentage of pack data.
}
}

Expand Down
4 changes: 2 additions & 2 deletions webui/gen/ts/v1/config_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ export class CheckPolicy extends Message<CheckPolicy> {
/**
* check a percentage of pack data.
*
* @generated from field: int32 read_data_subset_percent = 101;
* @generated from field: double read_data_subset_percent = 101;
*/
value: number;
case: "readDataSubsetPercent";
Expand All @@ -789,7 +789,7 @@ export class CheckPolicy extends Message<CheckPolicy> {
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "schedule", kind: "message", T: Schedule },
{ no: 100, name: "structure_only", kind: "scalar", T: 8 /* ScalarType.BOOL */, oneof: "mode" },
{ no: 101, name: "read_data_subset_percent", kind: "scalar", T: 5 /* ScalarType.INT32 */, oneof: "mode" },
{ no: 101, name: "read_data_subset_percent", kind: "scalar", T: 1 /* ScalarType.DOUBLE */, oneof: "mode" },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CheckPolicy {
Expand Down
24 changes: 19 additions & 5 deletions webui/src/views/AddRepoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -465,13 +465,13 @@ export const AddRepoModal = ({ template }: { template: Repo | null }) => {
>
<Form.Item
name={["prunePolicy", "maxUnusedPercent"]}
initialValue={25}
initialValue={10}
required={false}
>
<InputNumber
<InputPercent
addonBefore={
<Tooltip title="The maximum percentage of the repo size that may be unused after a prune operation completes. High values reduce copying at the expense of storage.">
<div style={{ width: "12" }}>Max Unused % After Prune</div>
<div style={{ width: "12" }}>Max Unused After Prune</div>
</Tooltip>
}
/>
Expand Down Expand Up @@ -504,10 +504,10 @@ export const AddRepoModal = ({ template }: { template: Repo | null }) => {
initialValue={0}
required={false}
>
<InputNumber
<InputPercent
addonBefore={
<Tooltip title="The percentage of pack data in this repository that will be read and verified. Higher values will use more bandwidth (e.g. 100% will re-read the entire repository on each check).">
<div style={{ width: "12" }}>Read Pack Data %</div>
<div style={{ width: "12" }}>Read Data %</div>
</Tooltip>
}
/>
Expand Down Expand Up @@ -785,3 +785,17 @@ const formatMissingEnvVars = (partialMatches: string[][]): string => {
})
.join(" or ");
};

const InputPercent = ({ ...props }) => {
return (
<InputNumber
step={1}
min={0}
max={100}
precision={2}
controls={false}
suffix="%"
{...props}
/>
);
};

0 comments on commit 5374273

Please sign in to comment.