-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Conversation
Labelling this PR as size/L |
GCE e2e build/test failed for commit ff684565a889a1d613549c2e7fa52f2241e7dd2e. |
cc @thockin |
const unknownSize = -1 | ||
|
||
type Accounting struct { | ||
BytesUsed int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about capacity?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Just a few comments. Overall structure LGTM. |
GCE e2e test build/test passed for commit 05d85465bb1a97c364aae9b9f90405fec1b149b3. |
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()) |
There was a problem hiding this comment.
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()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
GCE e2e build/test failed for commit f19f299ba6a4b6b1250823e100d4aab8d12bcf53. |
GCE e2e test build/test passed for commit 3629ffac03d42a10ec1c55886ce8a770154da029. |
I agree will all of the comments, and believe I have addressed them.
|
@@ -133,6 +136,7 @@ type emptyDir struct { | |||
mountDetector mountDetector | |||
plugin *emptyDirPlugin | |||
rootContext string | |||
volume.MetricsDu |
There was a problem hiding this comment.
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)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@pwittrock: Just a few nits. Otherwise LGTM. This is no longer a WIP :) |
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.
CLAs look good, thanks! |
Comments addressed. PTAL. I squashed all of the commits into 1. |
@k8s-bot test this |
GCE e2e build/test failed for commit c67ce88. |
GCE e2e test build/test passed for commit c67ce88. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e test build/test passed for commit c67ce88. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e test build/test passed for commit c67ce88. |
Automatic merge from submit-queue |
Auto commit by PR queue bot
if err != nil { | ||
t.Errorf("Unexpected error when calling GetMetrics %v", err) | ||
} | ||
if metrics.Used.Value() != 4096 { |
There was a problem hiding this comment.
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
Auto commit by PR queue bot
WIP / RFC for methods to add Volume accounting support.