kelseyhightower / confd

Manage local application configuration files using templates and data from etcd or consul
MIT License
8.35k stars 1.41k forks source link

confd is not updating the mode #334

Closed dmcnaught closed 8 years ago

dmcnaught commented 9 years ago

output from confd - each time it runs it says it's fixing the mode: Sep 10 19:18:58 ip-172-31-29-203.ec2.internal docker[26415]: 2015-09-10T19:18:58Z ecdce67d049b confd[1]: INFO /etc/confd/output/freeipa.pem has mode -rw-r--r-- should be -rw------- Sep 10 19:18:58 ip-172-31-29-203.ec2.internal docker[26415]: 2015-09-10T19:18:58Z ecdce67d049b confd[1]: INFO Target config /etc/confd/output/freeipa.pem out of sync Sep 10 19:18:58 ip-172-31-29-203.ec2.internal docker[26415]: 2015-09-10T19:18:58Z ecdce67d049b confd[1]: INFO Target config /etc/confd/output/freeipa.pem has been updated Sep 10 19:19:18 ip-172-31-29-203.ec2.internal docker[26415]: 2015-09-10T19:19:18Z ecdce67d049b confd[1]: INFO /etc/confd/output/freeipa.pem has mode -rw-r--r-- should be -rw------- Sep 10 19:19:18 ip-172-31-29-203.ec2.internal docker[26415]: 2015-09-10T19:19:18Z ecdce67d049b confd[1]: INFO Target config /etc/confd/output/freeipa.pem out of sync Sep 10 19:19:18 ip-172-31-29-203.ec2.internal docker[26415]: 2015-09-10T19:19:18Z ecdce67d049b confd[1]: INFO Target config /etc/confd/output/freeipa.pem has been updated

Spec: [template] prefix = "/bitnet.io/ssh/private" keys = [ "/freeipa.pem" ]

owner = "root" mode = "0600" src = "freeipapem.tmpl" dest = "/etc/confd/output/freeipa.pem"

dmcnaught commented 9 years ago

This is happening when I'm writing to a mounted file (docker run ... -v /root/freeipa.pem:/etc/confd/output/freeipa.pem)

elsonrodriguez commented 8 years ago

Looked into this, but wasn't able to reproduce. It could be the case that there were bugs present that are gone now.

Here's how I tried to reproduce:

Environment

Docker

$ docker version
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      linux/amd64

Docker Commandline

docker run -it --rm  --net=host -v /root/conffiles:/tmp confd

Confd (built from HEAD)

$ confd version
confd 0.12.0-dev

Confd config/templates

[template]
src = "myconfig.conf.tmpl"
dest = "/tmp/myconfig.conf"
keys = [
  "/myapp/database/url",
    "/myapp/database/user",
    ]

owner = "root"
mode = "0600"
# This a comment
[myconfig]
database_url = {{ getv "/myapp/database/url" }}
database_user = {{ getv "/myapp/database/user" }}

Before etcd triggered confd change

 $ ls -lash ~/conffiles/myconfig.conf 
4.0K -rwxrwxrwx 1 root root 75 Feb 22 23:00 /root/conffiles/myconfig.conf

After confd change

$ ls -lash ~/conffiles/myconfig.conf 
4.0K -rw------- 1 root root 80 Feb 22 23:24 /root/conffiles/myconfig.conf

Confd Output

2016-02-23T04:24:46Z test /confd[12]: INFO /tmp/myconfig.conf has mode -rwxrwxrwx should be -rw-------
2016-02-23T04:24:46Z test /confd[12]: INFO /tmp/myconfig.conf has md5sum 3a177041dab7f872cb21e1ce76b09406 should be 93756e744ff7dd9cc06fd7581567957a
2016-02-23T04:24:46Z test /confd[12]: INFO Target config /tmp/myconfig.conf out of sync
2016-02-23T04:24:46Z test /confd[12]: INFO Target config /tmp/myconfig.conf has been updated

Could you try recreating this bug with the latest and greatest? (newer Docker, confd, et al)

kelseyhightower commented 8 years ago

@elsonrodriguez Thanks for taking a look at this. I was not able to repo this issue as well, but my guess is that the later version of Docker or golang make this work.

dmcnaught commented 8 years ago

Thanks, That project finished a while ago for me, so it's not still an outstanding issue on my side.