Skip to content
This repository has been archived by the owner on Sep 22, 2020. It is now read-only.

Allow size as a percent for torusd. Fixes #175 #278

Merged
merged 3 commits into from
Sep 8, 2016

Conversation

beh9540
Copy link
Contributor

@beh9540 beh9540 commented Jun 17, 2016

No description provided.

@beh9540 beh9540 force-pushed the bhowell/percent_size branch 3 times, most recently from 2d56731 to 05a3806 Compare June 17, 2016 11:45
fmt.Fprintf(os.Stderr, "error parsing size: %s\n", err)
os.Exit(1)
if strings.Contains(sizeStr, "%") {
var stat syscall.Statfs_t
Copy link
Contributor

Choose a reason for hiding this comment

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

we probably should separate this into two different funcs: parsePercentage and getDiskSize.

for getDiskSize, do we want to be portable? current solution only works on unix i think.

not sure if it worth to introduce a dependency to handle it: https://github.com/StalkR/goircbot/tree/master/lib/disk

or we can use os.FileInfo and get os dependent field in Sys() https://golang.org/pkg/os/#FileInfo

Copy link
Contributor Author

@beh9540 beh9540 Jun 17, 2016

Choose a reason for hiding this comment

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

@xiang90 splitting it makes sense, I'll do that.

Yeah the current solution only would work on unix, not sure how wide spread torus is targeting for portability - the windows solution I saw was pretty shady, requiring linking the kernel32.dll.

I don't think we can use Sys() to get portability, looks like that was un-implemented for windows according to https://github.com/golang/go/issues/9611, I could be wrong on that though, I don't have a windows machine to test at this moment.

I'll look a the dependency, if we want Windows portability it may be worth it.

Copy link
Contributor

Choose a reason for hiding this comment

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

@beh9540 At least it can build and probably just throwing unsupported on windows is fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Eh, the dependency is fine, and does the equivalent of dlopen() on Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's actually probably a better dependency here https://github.com/ricochet2200/go-disk-usage which does the same thing but brings less with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@barakmich
Copy link
Contributor

This is correct; though the Config struct should change slightly after this because there's a subtlety between storage-size presented to the cluster and storage size used (backends might need a little space for its own bookkeeping). Right now the flag is the former, and this refers to the latter.

It's an easy calculation, and this can go in first, but it spawns a tiny followup issue.

@beh9540
Copy link
Contributor Author

beh9540 commented Jun 18, 2016

One thing I noticed while testing this is that it's really easy to get a percent of the drive that isn't an even multiple of the torus blocksize.

It's easy enough to make the blocksize line up, but it seems like it's currently not easy to get the torus blocksize, as it seems to be set in two different places depending on which MDS is being used. I can hard code the values in, but that feels like a sub-optimal solution. Another idea would be to adjust the size in storage/mmap_file.go after the blocksize has been determined.

Any thoughts on which way would be the better approach?

@beh9540 beh9540 force-pushed the bhowell/percent_size branch 2 times, most recently from f9c2e65 to c75900b Compare June 18, 2016 22:51
@beh9540 beh9540 force-pushed the bhowell/percent_size branch from c75900b to bdd79d3 Compare June 18, 2016 22:52
@barakmich
Copy link
Contributor

barakmich commented Jun 23, 2016

Better approach is to always follow the blocksize from the MDS; if it's over, just shrink it a bit smaller to align to the blocksize. You have to initialize the MDS anyway before torusd can come up, so that's not a problem.

@beh9540
Copy link
Contributor Author

beh9540 commented Jun 27, 2016

@barakmich I added resizing to bring the volume down to the closet even multiple. That should complete this, assuming everything checks out okay.

@barakmich barakmich merged commit f2e57b6 into coreos:master Sep 8, 2016
@barakmich
Copy link
Contributor

Merged! Sorry about the delay.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants