-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Added support for filesystem metrics on Docker #2768
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Hi @JohnnyG235711. Thanks for your PR. I'm waiting for a google member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@googlebot I signed it! |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
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.
@JohnnyG235711 you will have to sign CLA before this PR can be merged. I would appreciate taking look at my comments too :)
fs/fs.go
Outdated
@@ -483,6 +483,17 @@ func getDiskStatsMap(diskStatsFile string) (map[string]DiskStats, error) { | |||
return nil, error | |||
} | |||
} | |||
|
|||
major64, error := strconv.ParseUint(words[0], 10, 64) |
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.
Use err
instead of error
as error-storing variable, please.
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.
Sure, I have renamed to "err" in my latest commit.
fs/fs.go
Outdated
@@ -439,7 +439,7 @@ func (i *RealFsInfo) GetFsInfoForPath(mountSet map[string]struct{}) ([]Fs, error | |||
|
|||
var partitionRegex = regexp.MustCompile(`^(?:(?:s|v|xv)d[a-z]+\d*|dm-\d+)$`) | |||
|
|||
func getDiskStatsMap(diskStatsFile string) (map[string]DiskStats, error) { | |||
func GetDiskStatsMap(diskStatsFile string) (map[string]DiskStats, error) { |
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.
Do you think it would be possible to use RealFsInfo.GetFsInfoForPath()
rather than exporting yet another function? It would be great to limit public interfaces as much as possible.
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.
It was indeed possible and I have made getDiskStatsMap private again in my latest commit.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
1 similar comment
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@iwankgb Thanks for taking the time to look at this. I have changed my code to be inline with your code review comments and pushed the changes into my branch. Hopefully you can see them for the re-review. I have also updated my primary email address to match the one in the google CLA corporate agreement for my company, which is Syncsort Incorporated. Thanks. |
@JohnnyG235711 you probably need to talk to someone at your company to be added to an AD (or similar) group. The bot still claims you have not signed the CLA. |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
1 similar comment
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
3 similar comments
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
@googlebot I fixed it. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
@iwankgb I'm in the group now, but now getting a different error: "We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors." |
@JohnnyG235711 if I were you I would try to rebase against master and then squash all the commits. It might help. |
57f889b
to
9ac164d
Compare
@iwankgb Thank you, that worked. |
/ok-to-test |
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.
It segfaults on my RPi 4:
I0110 16:38:12.163674 88322 manager.go:987] Added container: "/user.slice" (aliases: [], namespace: "")
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x9fc39c]
goroutine 56 [running]:
github.com/google/cadvisor/container/docker.(*dockerContainerHandler).addDiskStats(0x40000dd2c0, 0x400086e7a8, 0x0)
/home/ubuntu/go/src/github.com/google/cadvisor/container/docker/handler.go:430 +0xa4
github.com/google/cadvisor/container/docker.(*dockerContainerHandler).getFsStats(0x40000dd2c0, 0x4000805800, 0x0, 0x0)
/home/ubuntu/go/src/github.com/google/cadvisor/container/docker/handler.go:418 +0x23c
github.com/google/cadvisor/container/docker.(*dockerContainerHandler).GetStats(0x40000dd2c0, 0x0, 0x0, 0x0)
/home/ubuntu/go/src/github.com/google/cadvisor/container/docker/handler.go:465 +0x68
github.com/google/cadvisor/manager.(*containerData).updateStats(0x4000788000, 0xbff6e93d09287079, 0xace62627)
/home/ubuntu/go/src/github.com/google/cadvisor/manager/container.go:637 +0x54
github.com/google/cadvisor/manager.(*containerData).housekeepingTick(0x4000788000, 0x400070a2a0, 0x5f5e100, 0x4000127100)
/home/ubuntu/go/src/github.com/google/cadvisor/manager/container.go:583 +0xf4
github.com/google/cadvisor/manager.(*containerData).housekeeping(0x4000788000)
/home/ubuntu/go/src/github.com/google/cadvisor/manager/container.go:531 +0x1bc
created by github.com/google/cadvisor/manager.(*containerData).Start
/home/ubuntu/go/src/github.com/google/cadvisor/manager/container.go:119 +0x3c
ubuntu@malyna4:~/go/src/github.com/google/cadvisor$ uname -a
Linux malyna4 5.4.0-1025-raspi #28-Ubuntu SMP PREEMPT Wed Dec 9 17:10:53 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux
ubuntu@malyna4:~/go/src/github.com/google/cadvisor$ go version
go version go1.13.8 linux/arm64
I think that we are missing an important test here: CI should not pass :/ |
I have added a failing test, which I then fixed by fixing the bug. |
@iwankgb Is my revised code OK? |
@JohnnyG235711 sorry for the delay, it's been hectic time at work. I will take another look at your code this week. |
@iwankgb No worries, and thanks for looking at it. |
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.
Few comments.
container/docker/handler.go
Outdated
@@ -384,7 +384,7 @@ func (h *dockerContainerHandler) getFsStats(stats *info.ContainerStats) error { | |||
case aufsStorageDriver, overlayStorageDriver, overlay2StorageDriver, vfsStorageDriver: | |||
deviceInfo, err := h.fsInfo.GetDirFsDevice(h.rootfsStorageDir) | |||
if err != nil { | |||
return fmt.Errorf("unable to determine device info for dir: %v: %v", h.rootfsStorageDir, err) | |||
return fmt.Errorf("Unable to determine device info for dir: %v: %v", h.rootfsStorageDir, err) |
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.
Errors shouldn't start with the capitalized words.
container/docker/handler.go
Outdated
if err == nil { | ||
addDiskStats(fileSystems, fsInfo, &fsStat) | ||
} else { | ||
klog.V(5).Infof("Unable to obtain diskstats for filesystem %s: %v", fsStat.Device, err) |
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 it be Errorf
?
fsStats.IoInProgress = fileSys.DiskStats.IoInProgress | ||
fsStats.IoTime = fileSys.DiskStats.IoTime | ||
fsStats.WeightedIoTime = fileSys.DiskStats.WeightedIoTime | ||
} |
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.
Please, break iteration after finding your device.
fs/fs_test.go
Outdated
@@ -44,7 +44,7 @@ func TestMountInfoFromDir(t *testing.T) { | |||
func TestGetDiskStatsMap(t *testing.T) { | |||
diskStatsMap, err := getDiskStatsMap("test_resources/diskstats") | |||
if err != nil { | |||
t.Errorf("Error calling getDiskStatMap %s", err) | |||
t.Errorf("Error calling GetDiskStatMap %s", err) |
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.
The function didn't change the name, so in my opinion, you shouldn't change this error.
@Creatone Thanks for your feedback. I have amended the code in line with your review. Could you re-review? |
@JohnnyG235711 please squash commits :) |
Added support for filesystem metrics on Docker Added support for filesystem metrics on Docker Added support for filesystem metrics on Docker Added support for filesystem metrics on Docker Added support for filesystem metrics on Docker Added support for filesystem metrics on Docker Added support for filesystem metrics on Docker Added support for filesystem metrics on Docker Added support for filesystem metrics on Docker Added support for filesystem metrics on Docker Added support for filesystem metrics on Docker
fbf699a
to
8c0666a
Compare
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.
LGTM
@CreateOne Thanks for looking at it |
LGTM |
@bobbypage I was wondering when this might be tested and then merged? Thanks very much. |
LGTM, thanks. |
First reported in issue #2609 (#2609)