-
Notifications
You must be signed in to change notification settings - Fork 612
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
[RFC] inspect: show mounts info from CRI/ctr containers #2939
Conversation
test crictl container pod.json container.json
|
Can we have a test? |
OK. |
Signed-off-by: baijia <baijia.wr@antgroup.com>
if mount.Destination == "/etc/resolv.conf" { | ||
c.ResolvConfPath = mount.Source | ||
} | ||
if mount.Destination == "/etc/hostname" { | ||
c.HostnamePath = mount.Source | ||
} |
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.
nit: we can use else if
at line 241 to save an unnecessary if
.
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.
Fixed.
Fix containerd#2934 Containers created by CRI or ctr with bind mounts don't have label "nerdct/mounts". However, 'inspect' with dockercompat mode only parses mounts from label "nerdct/mounts". After this patch, 'inspect' with dockercompat mode can show CRI and ctr container bind mounts. ResolvConfPath, HostnamePath and Hostname are taken to the same consideration. Signed-off-by: baijia <baijia.wr@antgroup.com>
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 other than some minor comments, thanks
|
||
// TODO: add more internal labels testcases | ||
labelMount := lbs[labels.Mounts] | ||
expectedLabelMount := "[{\"Type\":\"bind\",\"Source\":\"/tmp\",\"Destination\":\"/app\",\"Mode\":\"rprivate,rbind\",\"RW\":true,\"Propagation\":\"rprivate\"}]" |
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.
nit: it'll be easier to visualize if you use raw string, eg.
expectedLabelMount := `[{"Type":"bind","Source":"/tmp",...}]`
inspect := base.InspectContainer(testContainer) | ||
lbs := inspect.Config.Labels | ||
|
||
// TODO: add more internal labels testcases |
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 still have more tests to add?
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 still have more tests to add?
No.
There were never tests for internal labels, such as “containerd.io/restart.status” and "nerdctl/hostname", that are beyond the scope of this commit.
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, thanks
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
Fix #2934
Containers created by CRI or ctr with bind mounts
don't have label
nerdct/mounts
.However, 'inspect' with dockercompat mode only parses mounts from label "nerdct/mounts".
After this patch, 'inspect' with dockercompat mode can show CRI and ctr container bind mounts.
ResolvConfPath, HostnamePath and Hostname are taken to the same consideration.
Further comments:
nerdctl/mounts
in label has higher priority. So donerdctl/hostname
andnerdctl/state-dir
. CRI/ctr mounts and label "nerdct/mounts" are not merged. It shouldn't happen that container created by nerdctl with bind mount doesn't inject mount info to label nerdctl/mountsHow to test:
ctr:
Before this patch
After this patch
We can also test ResolvConf and hostname by crictl pod