DataDog / kvexpress

## Auto-archived due to inactivity. ## Go program to move data in and out of Consul's KV store.
Apache License 2.0
128 stars 13 forks source link

Doesn't force the file mode if it differs #78

Closed darron closed 8 years ago

darron commented 8 years ago

It's currently 640:

-rw-r-----   1 root root 15790 Jan 13 20:46 hosts.consul
[staging]root@i-16259ea7:/etc/datadog# kvexpress out -k hosts -f /etc/datadog/hosts.consul -l 100 -c 00644 -d true -e 'sudo pkill -HUP dnsmasq' --verbose
2016-01-13T22:17:55Z: out: Checking cli flags.
2016-01-13T22:17:55Z: out: Required cli flags present.
2016-01-13T22:17:55Z: out: username='root'
2016-01-13T22:17:55Z: out: Enabling Dogstatsd metrics.
2016-01-13T22:17:55Z: out: path='data' fullPath='kvexpress/hosts/data'
2016-01-13T22:17:55Z: out: path='checksum' fullPath='kvexpress/hosts/checksum'
2016-01-13T22:17:55Z: out: path='stop' fullPath='kvexpress/hosts/stop'
2016-01-13T22:17:55Z: out: path='kvexpress/locks/fba4f4f80fd22d7f7c26b00ad0a6c92d38c5f860870446eed4105ab170db2a9e/i-16259ea7'
2016-01-13T22:17:55Z: out: server='localhost:8500' token='anonymous'
2016-01-13T22:17:55Z: out: action='consulGet' key='kvexpress/locks/fba4f4f80fd22d7f7c26b00ad0a6c92d38c5f860870446eed4105ab170db2a9e/i-16259ea7'
2016-01-13T22:17:55Z: out: action='consulGet' key='kvexpress/hosts/stop'
2016-01-13T22:17:55Z: out: Stop Key is NOT present - continuing.
2016-01-13T22:17:55Z: out: action='consulGet' key='kvexpress/hosts/data'
2016-01-13T22:17:55Z: out: action='consulGet' key='kvexpress/hosts/checksum'
2016-01-13T22:17:55Z: out: length='321' minLength='100'
2016-01-13T22:17:55Z: out: longEnough='true'
2016-01-13T22:17:55Z: out: computedChecksum='8a2e3468ae39fca1e93e3f5a01cc6f1db6f5a7a2dd1bb86b3dd338cba8bac145'
2016-01-13T22:17:55Z: out: checksum='8a2e3468ae39fca1e93e3f5a01cc6f1db6f5a7a2dd1bb86b3dd338cba8bac145' computedChecksum='8a2e3468ae39fca1e93e3f5a01cc6f1db6f5a7a2dd1bb86b3dd338cba8bac145'
2016-01-13T22:17:55Z: out: checksumMatch='true'
2016-01-13T22:17:55Z: out: computedChecksum='138917ce8da70968f93920a13b915e7bdbb438f7c9c12289a46aef45af9b5dfb'
2016-01-13T22:17:55Z: out: owner='root' status='found' uid='0'
2016-01-13T22:17:55Z: out: owner='root' status='found' gid='0'
2016-01-13T22:17:55Z: out: file_wrote='true' location='/etc/datadog/hosts.consul' permissions='644'
2016-01-13T22:17:55Z: out: file_chown='true' location='/etc/datadog/hosts.consul' owner='0' group='0'
2016-01-13T22:17:55Z: out: dogstatsd='true' key='hosts' stats='out'
2016-01-13T22:17:55Z: out: exec='sudo pkill -HUP dnsmasq'
2016-01-13T22:17:55Z: out: dogstatsd='true' key='hosts' location='complete' msec='51'
2016-01-13T22:17:55Z: out: location='complete', elapsed='51.121096ms'
[staging]root@i-16259ea7:/etc/datadog# ls -al
total 28
drwxr-xr-x   2 root root  4096 Dec 21 19:44 .
drwxr-xr-x 109 root root  4096 Jan 12 22:03 ..
-rw-r--r--   1 dog  dog    107 Dec 21 19:44 dogrc
-rw-r-----   1 root root 15790 Jan 13 22:17 hosts.consul
darron commented 8 years ago

New files that are created - no problem at all.

Existing files keep the same perms.

Which is why this never showed up in testing.

darron commented 8 years ago

I tried to do the test in bash using stat, but OS X and Linux have different versions with different flags.

Seems the best way to make sure this is fixed.