Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume Accounting Interface methods #18232

Merged
merged 1 commit into from
Dec 11, 2015

Conversation

pwittrock
Copy link
Member

WIP / RFC for methods to add Volume accounting support.

@pwittrock
Copy link
Member Author

@vishh

@k8s-github-robot
Copy link

Labelling this PR as size/L

@k8s-github-robot k8s-github-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 4, 2015
@k8s-bot
Copy link

k8s-bot commented Dec 4, 2015

GCE e2e build/test failed for commit ff684565a889a1d613549c2e7fa52f2241e7dd2e.

@vishh
Copy link
Contributor

vishh commented Dec 4, 2015

cc @thockin

const unknownSize = -1

type Accounting struct {
BytesUsed int
Copy link
Contributor

Choose a reason for hiding this comment

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

What about capacity?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should the units be uint64?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@vishh
Copy link
Contributor

vishh commented Dec 4, 2015

Just a few comments. Overall structure LGTM.
ping @saad-ali

@k8s-bot
Copy link

k8s-bot commented Dec 5, 2015

GCE e2e test build/test passed for commit 05d85465bb1a97c364aae9b9f90405fec1b149b3.

@k8s-bot
Copy link

k8s-bot commented Dec 5, 2015

GCE e2e test build/test passed for commit 06f32b14a1f7ae88e2311b23e1116aaf574415d2.

@@ -103,6 +105,7 @@ func (plugin *emptyDirPlugin) newCleanerInternal(volName string, podUID types.UI
mountDetector: mountDetector,
plugin: plugin,
}
ed.AccountingDu.Init(ed.GetPath())
Copy link
Member

Choose a reason for hiding this comment

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

embedding when you have a really generic name like Init() exposed is bound to cause problems. Maybe InitAccounting()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@k8s-bot
Copy link

k8s-bot commented Dec 8, 2015

GCE e2e build/test failed for commit f19f299ba6a4b6b1250823e100d4aab8d12bcf53.

@k8s-bot
Copy link

k8s-bot commented Dec 8, 2015

GCE e2e test build/test passed for commit 3629ffac03d42a10ec1c55886ce8a770154da029.

@pwittrock
Copy link
Member Author

I agree will all of the comments, and believe I have addressed them.
Other changes:

  • Changed the names of several structs / interfaces / functions to be what I hope are more descriptive. Open to suggestions on what these should be.
  • Added testing for the Metrics implementations
  • Changed secret to use MetricsNil until we know that using MetricsDu is the correct thing to do.

@@ -133,6 +136,7 @@ type emptyDir struct {
mountDetector mountDetector
plugin *emptyDirPlugin
rootContext string
volume.MetricsDu
Copy link
Member

Choose a reason for hiding this comment

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

minor idea: rather than embedding MetricsDu and then calling Init(), why not embed MetricsProvider and initialize it in the struct definition as MetricsProvider: volume.NewMetricsDu(path) ?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Performed some refactoring to get the path value without an initialized emptyDir. Also made metricsDu unexported so that it cannot be directly created. Let me know if you prefer unexported metricsDu, or as it was before.

// See MetricsProvider.GetMetrics
// GetMetrics returns an empty Metrics and an error.
func (*MetricsNil) GetMetrics() (*Metrics, error) {
return &Metrics{}, errors.New("metrics are not supported for MetricsNil Volumes")
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect we might have to expose this error message as a special variable to differentiate between metrics errors vs unsupported scenarios. This code is Ok for this PR though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good. The correct behavior may become more clear once these are actually used.

@vishh
Copy link
Contributor

vishh commented Dec 9, 2015

@pwittrock: Just a few nits. Otherwise LGTM. This is no longer a WIP :)

@pwittrock pwittrock changed the title WIP: Volume Accounting Interface methods Volume Accounting Interface methods Dec 9, 2015
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

- Add volume.MetricsProvider function to Volume interface.
- Add volume.MetricsDu for providing metrics via executing "du".
- Add volulme.MetricsNil for unsupported Volumes.
@googlebot
Copy link

CLAs look good, thanks!

@pwittrock
Copy link
Member Author

Comments addressed. PTAL. I squashed all of the commits into 1.

@pwittrock
Copy link
Member Author

@k8s-bot test this

@pwittrock pwittrock assigned vishh and unassigned saad-ali Dec 10, 2015
@k8s-bot
Copy link

k8s-bot commented Dec 10, 2015

GCE e2e build/test failed for commit c67ce88.

@k8s-bot
Copy link

k8s-bot commented Dec 10, 2015

GCE e2e test build/test passed for commit c67ce88.

@vishh vishh added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 10, 2015
@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Dec 10, 2015

GCE e2e test build/test passed for commit c67ce88.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Dec 11, 2015

GCE e2e test build/test passed for commit c67ce88.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

k8s-github-robot pushed a commit that referenced this pull request Dec 11, 2015
Auto commit by PR queue bot
@k8s-github-robot k8s-github-robot merged commit 23baca8 into kubernetes:master Dec 11, 2015
if err != nil {
t.Errorf("Unexpected error when calling GetMetrics %v", err)
}
if metrics.Used.Value() != 4096 {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is very fs type dependent. In tmpfs, directory size is 0, and thus we'd expect != 4096 is correct. A fs can also have block size more than 4096, see stat(2) . The formula should probably be metrics.Used.Value() == st.st_blksize * st.st_blocks

dims pushed a commit to dims/kubernetes that referenced this pull request Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants