Skip to content

Fixes looking up mountinfo corresponds to path#1584

Merged
mlaventure merged 1 commit intocontainerd:masterfrom
miaoyq:fix-mount-lookup-err
Oct 9, 2017
Merged

Fixes looking up mountinfo corresponds to path#1584
mlaventure merged 1 commit intocontainerd:masterfrom
miaoyq:fix-mount-lookup-err

Conversation

@miaoyq
Copy link
Copy Markdown
Member

@miaoyq miaoyq commented Oct 3, 2017

Signed-off-by: Yanqiang Miao [email protected]

I execute the mount comment like:

$ mount --bind /tmp /tmp

Then look up the mount info through mount.Lookiup("/tmp"), and get the result like:

65 0 253:0 / / rw,relatime shared:1 - xfs /dev/mapper/cl-root rw,seclabel,attr2,inode64,noquota

But I expect getting the mount info like:

124 65 253:0 /tmp /tmp rw,relatime shared:1 - xfs /dev/mapper/cl-root rw,seclabel,attr2,inode64,noquota

This PR ensure getting the correct mountinfo corresponds to path.

/cc @Random-Liu

@codecov-io
Copy link
Copy Markdown

codecov-io commented Oct 3, 2017

Codecov Report

Merging #1584 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1584   +/-   ##
=======================================
  Coverage   46.44%   46.44%           
=======================================
  Files          26       26           
  Lines        3542     3542           
=======================================
  Hits         1645     1645           
  Misses       1519     1519           
  Partials      378      378

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a8426ed...d7c4611. Read the comment docs.

@AkihiroSuda
Copy link
Copy Markdown
Member

Thank you for PR, please add UT?

Comment thread mount/lookup_unix.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@mlaventure Yes, it's fine, will do 🙂

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

@Random-Liu
Copy link
Copy Markdown
Member

@miaoyq Thanks for fixing this!

@crosbymichael crosbymichael added this to the 1.0.0 milestone Oct 3, 2017
@crosbymichael
Copy link
Copy Markdown
Member

LGTM

@crosbymichael
Copy link
Copy Markdown
Member

If you have time can you write a quick unit test for this?

We already have mountinfo output as a const in the tests files that you could use for parsing and output:

https://github.com/containerd/containerd/blob/master/mount/mountinfo_linux_test.go#L11

@Random-Liu
Copy link
Copy Markdown
Member

I think it's national holiday in China this week, let's give @miaoyq some time. :)

@miaoyq
Copy link
Copy Markdown
Member Author

miaoyq commented Oct 5, 2017

If you have time can you write a quick unit test for this?
We already have mountinfo output as a const in the tests files that you could use for parsing and output:
https://github.com/containerd/containerd/blob/master/mount/mountinfo_linux_test.go#L11

@crosbymichael I'm sorry for delay, I have tried to test this with the const, but seems not feasible, because mountinfo in Lookup() is get from /proc/self/mountinfo by Self().

I think maybe we could add unit test for this in testLookup.

I think it's national holiday in China this week, let's give @miaoyq some time. :)

@Random-Liu Thanks for your understanding. 🙂

@crosbymichael
Copy link
Copy Markdown
Member

@miaoyq ya, we can breakout the logic into an internal func that takes a io.Reader so that it can be unit tested.

func Lookup() {
f, err := os.Open("/proc/sefl/mountinfo")
    lookupMounts(f)
}

@miaoyq
Copy link
Copy Markdown
Member Author

miaoyq commented Oct 8, 2017

@crosbymichael Seems to still can not add unit test for this,because dir must be a real directory in host, we need to get the syscall.Stat_t of dir through syscall.Stat(), info.MountPoint also.

@miaoyq miaoyq force-pushed the fix-mount-lookup-err branch 2 times, most recently from 7a98cae to d7c4611 Compare October 8, 2017 09:14
@miaoyq
Copy link
Copy Markdown
Member Author

miaoyq commented Oct 8, 2017

@crosbymichael I have added unit test for this in testLookup.

@crosbymichael
Copy link
Copy Markdown
Member

LGTM

ping @mlaventure

Copy link
Copy Markdown
Contributor

@mlaventure mlaventure left a comment

Choose a reason for hiding this comment

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

LGTM

@mlaventure mlaventure merged commit b2e3482 into containerd:master Oct 9, 2017
@miaoyq miaoyq mentioned this pull request Feb 1, 2018
mauriciovasquezbernal pushed a commit to kinvolk/containerd that referenced this pull request Nov 13, 2020
…c-for-runtime-options

Revert "Fix doc for runtime specific options"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants