Skip to content
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

Prevent loading config twice in K8S #3999

Merged
merged 1 commit into from
Apr 11, 2018

Conversation

jvassev
Copy link
Contributor

@jvassev jvassev commented Apr 10, 2018

When config dir is mounted from configmap, filepath.Walk() find the same
.conf file twice as 20-acme.conf is a link to
..data/20-acme.conf for example.

This patch skips all folder names starting with '..' which is pretty
uncommon and mainly used by Kubernetes mounts.

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

When config dir is mounted from configmap, filepath.Walk() find the same
.conf file twice as 20-acme.conf is a link to
..data/20-acme.conf for example.

This patch skips all folder names starting with '..' which is pretty
uncommon and mainly used by Kubernetes mounts.
@danielnelson
Copy link
Contributor

Can you give me a brief explanation of why you would have a file layout like this in k8s?

@jvassev
Copy link
Contributor Author

jvassev commented Apr 11, 2018

@danielnelson
When a confimap is mounted, K8S puts the contents in a ..data directory and creates links to the configmap entries. This is how a Prometheus configmap looks like when mounted from the point of view of the container:

ls -la /etc/config/
total 12
drwxrwxrwx    3 root     root          4096 Apr 11 10:57 .
drwxr-xr-x    1 root     root          4096 Mar 28 09:41 ..
drwxr-xr-x    2 root     root          4096 Apr 11 10:57 ..4984_11_04_10_57_03.191612861
lrwxrwxrwx    1 root     root            31 Apr 11 10:57 ..data -> ..4984_11_04_10_57_03.191612861
lrwxrwxrwx    1 root     root            18 Mar 28 09:41 alerts.yaml -> ..data/alerts.yaml
lrwxrwxrwx    1 root     root            21 Mar 28 09:41 prometheus.yml -> ..data/prometheus.yml
lrwxrwxrwx    1 root     root            17 Mar 28 09:41 rules.yaml -> ..data/rules.yaml

If you do a find for rules.yaml, you'll get two matches - something similar happens when telegraf scans the config folder:

find -name rules.yaml
./rules.yaml
./..4984_11_04_10_57_03.191612861/rules.yaml

@danielnelson danielnelson added this to the 1.7.0 milestone Apr 11, 2018
@danielnelson danielnelson added area/configuration feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin labels Apr 11, 2018
@danielnelson danielnelson merged commit 2c19d74 into influxdata:master Apr 11, 2018
@jvassev jvassev deleted the k8s-mounts branch April 12, 2018 13:08
maxunt pushed a commit that referenced this pull request Jun 26, 2018
When config dir is mounted from configmap, filepath.Walk() finds the same
.conf file twice as 20-acme.conf is a link to ..data/20-acme.conf for example.

This patch skips all folder names starting with '..' which is pretty
uncommon and mainly used by Kubernetes mounts.
otherpirate pushed a commit to otherpirate/telegraf that referenced this pull request Mar 15, 2019
When config dir is mounted from configmap, filepath.Walk() finds the same
.conf file twice as 20-acme.conf is a link to ..data/20-acme.conf for example.

This patch skips all folder names starting with '..' which is pretty
uncommon and mainly used by Kubernetes mounts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/configuration feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants