opencontainers / opencontainers/runc

Failed to mount the hostPath /proc/net/ correctly

Open
#3,886 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
13.5k
Forks
2.3k
Avg merge
2d 8h
Merged PRs (30d)
30

Description

Description

I want to deploy a pod in my cluster to monitor NIC information on nodes. I mount /proc/net/ of the host directory to my pod in hostPath mode.
However, when I enter the container, I find that the owner of the mount point is incorrect, and the content in the corresponding directory is not the content of /proc/net/dev on the host, but the content of /proc/net/dev in the container.
What's even more amazing is that when I remove the "/" at the end of the host directory (/proc/net) and go back to the container, the directory and content are correct.
I don't know if this is a problem of k8s or runc.

Can anyone helps? Thanks a lot.

Steps to reproduce the issue

1.Start up a local k8s cluster with Kubernetes v1.25.3 by hack/local-up-cluster.sh;

2.Apply a Pod with busybox with hotsPath /proc/net/ to /app/proc/net/ of container;

apiVersion: v1
kind: Pod
metadata:
  name: busybox
  namespace: default
spec:
  containers:
  - name: busybox
    image: registry.k8s.io/e2e-test-images/busybox:1.29-2
    command: ["/bin/sh","-c","sleep 3600;"]
    imagePullPolicy: IfNotPresent
    volumeMounts:
    - mountPath: /app/proc/net
      name: net
  volumes:
  - hostPath:
      path: /proc/net/
      type: ""
    name: net
  securityContext:
    runAsGroup: 2000
    runAsUser: 3001

3.Run the Kubectl exec command to access the busybox container and check whether the content of /app/proc/net/dev is the same as that of /proc/net/dev on the host;
image

4.When I change the hotsPath from /proc/net/ to /proc/net, it works as what I want.
image

Describe the results you received and expected

The content of /app/proc/net/dev in the container is the same as that on the host.

What version of runc are you using?

runc version 1.1.3
image

Host OS information

No response

Host kernel information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the provided Kubernetes Pod manifest on Kubernetes v1.25.3 and runc 1.1.3, comparing hostPath values /proc/net/ and /proc/net. Inspect the resulting mount contents and ownership in the container, then determine whether the discrepancy is in runc or Kubernetes; done means the trailing-slash form exposes the host's /proc/net/dev correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes
Domain
infrastructure, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.