Skip to content

fix: os.Stat returns ENOENT when checking the symlink file's stat of …#508

Open
z0brk wants to merge 1 commit intobytedance:mainfrom
z0brk:main
Open

fix: os.Stat returns ENOENT when checking the symlink file's stat of …#508
z0brk wants to merge 1 commit intobytedance:mainfrom
z0brk:main

Conversation

@z0brk
Copy link

@z0brk z0brk commented Jun 15, 2023

fixed os.Stat returns ENOENT when checking the symlink file's stat of a container using /proc/*/root.

Summary

This PR fixes/implements the following bugs/features

  • Bug os.Stat returns ENOENT when checking the symlink file's stat of a container using /proc/*/root

Test plan (required)

  1. run mysql:5.7.31 image on host with collector running
docker run -e MYSQL_ROOT_PASSWORD=abc12345 mysql@sha256:b3dc8d10307ab7b9ca1a7981b1601a67e176408be618fc4216d137be37dae10b
  1. Collector's AppRule of mysql checking file /etc/mysql/my.cnf symlinked to /etc/alternatives/my.cnf
root@601d2bfcb7e3:~# stat /etc/mysql/my.cnf
  File: /etc/mysql/my.cnf -> /etc/alternatives/my.cnf
  Size: 24              Blocks: 0          IO Block: 4096   symbolic link
Device: 40h/64d Inode: 4748407     Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-10-13 08:03:29.000000000 +0000
Modify: 2020-10-13 08:03:29.000000000 +0000
Change: 2023-06-15 08:19:26.938384681 +0000
 Birth: -
root@601d2bfcb7e3:~# 
  1. check file's stat using os.Stat will return ENOENT, should be use os.Lstat to check symlink file in container, because file /etc/alternatives/my.cnf not available on host, see https://pkg.go.dev/os#Lstat for more infos.

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.

1 participant