-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
Fix assumptions about tmpfs in metrics du tests #18580
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,14 @@ package volume | |
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"os/exec" | ||
"path" | ||
"strings" | ||
|
||
"k8s.io/kubernetes/pkg/api" | ||
"k8s.io/kubernetes/pkg/api/resource" | ||
client "k8s.io/kubernetes/pkg/client/unversioned" | ||
"k8s.io/kubernetes/pkg/cloudprovider" | ||
"k8s.io/kubernetes/pkg/types" | ||
|
@@ -267,3 +271,22 @@ func (fc *FakeProvisioner) NewPersistentVolumeTemplate() (*api.PersistentVolume, | |
func (fc *FakeProvisioner) Provision(pv *api.PersistentVolume) error { | ||
return nil | ||
} | ||
|
||
// FindEmptyDirectoryUsageOnTmpfs finds the expected usage of an empty directory existing on | ||
// a tmpfs filesystem on this system. | ||
func FindEmptyDirectoryUsageOnTmpfs() (*resource.Quantity, error) { | ||
tmpDir, err := ioutil.TempDir(os.TempDir(), "metrics_du_test") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what makes you think this is on tmpfs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose you're right though, it's really expected usage of an empty temporary directory however that might be defined on your system. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this method is not working around a tmpfs issue, but rather a GCE ext4 issue. Should we rename the method appropriately? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'll rename the method to be what it represents. The issue isn't with any filesystem, really, it's with the assumptions baked into the test. |
||
if err != nil { | ||
return nil, err | ||
} | ||
out, err := exec.Command("nice", "-n", "19", "du", "-s", "-B", "1", tmpDir).CombinedOutput() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we reuse existing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vissh under the debian flavor in GCE, directories in /tmp report 4096 under du. :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vishh you're right:
|
||
if err != nil { | ||
return nil, fmt.Errorf("failed command 'du' on %s with error %v", tmpDir, err) | ||
} | ||
used, err := resource.ParseQuantity(strings.Fields(string(out))[0]) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to parse 'du' output %s due to error %v", out, err) | ||
} | ||
used.Format = resource.BinarySI | ||
return used, nil | ||
} |
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.
while VERY usually correct, not all blocks are 4k. should the test get the block size from stat info and just accept either 0 or 1 blocks in size? maybe that doesn't help either...
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.
See if my comment can help.
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.
Thanks, @rootfs, I'll work this in.