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

md5sum never matches #338

Closed nicholasvmoore closed 9 years ago

nicholasvmoore commented 9 years ago

I have confd configured to watch an etcd2 cluster for key changes and the config gets written every 10 seconds and never end. But what seems to be the most strange is that the MD5SUM reported is always one permutation behind.

LOG:

2015-09-17T20:46:03Z 80c1c3ca67d5 confd[35]: INFO /etc/nginx/conf.d/app.conf has md5sum b9dcaa8318b66ff3475f09cd6319e2eb should be 3ff74082d372c68c2f91eaa55e87d0f4
2015-09-17T20:46:03Z 80c1c3ca67d5 confd[35]: INFO Target config /etc/nginx/conf.d/app.conf out of sync
2015-09-17T20:46:03Z 80c1c3ca67d5 confd[35]: INFO Target config /etc/nginx/conf.d/app.conf has been updated
2015-09-17T20:46:13Z 80c1c3ca67d5 confd[35]: INFO /etc/nginx/conf.d/app.conf has md5sum 3ff74082d372c68c2f91eaa55e87d0f4 should be b6a5f7c28f5b3d16ef227a964311ad90
2015-09-17T20:46:13Z 80c1c3ca67d5 confd[35]: INFO Target config /etc/nginx/conf.d/app.conf out of sync
2015-09-17T20:46:13Z 80c1c3ca67d5 confd[35]: INFO Target config /etc/nginx/conf.d/app.conf has been updated
2015-09-17T20:46:23Z 80c1c3ca67d5 confd[35]: INFO /etc/nginx/conf.d/app.conf has md5sum b6a5f7c28f5b3d16ef227a964311ad90 should be e38aa87af449d44b27cb63a063c57428
2015-09-17T20:46:23Z 80c1c3ca67d5 confd[35]: INFO Target config /etc/nginx/conf.d/app.conf out of sync
2015-09-17T20:46:23Z 80c1c3ca67d5 confd[35]: INFO Target config /etc/nginx/conf.d/app.conf has been updated
2015-09-17T20:46:33Z 80c1c3ca67d5 confd[35]: INFO /etc/nginx/conf.d/app.conf has md5sum e38aa87af449d44b27cb63a063c57428 should be a414d17a0c8ac7cc4887e058ad9ac63e
2015-09-17T20:46:33Z 80c1c3ca67d5 confd[35]: INFO Target config /etc/nginx/conf.d/app.conf out of sync
2015-09-17T20:46:33Z 80c1c3ca67d5 confd[35]: INFO Target config /etc/nginx/conf.d/app.conf has been updated
2015-09-17T20:46:43Z 80c1c3ca67d5 confd[35]: INFO /etc/nginx/conf.d/app.conf has md5sum a414d17a0c8ac7cc4887e058ad9ac63e should be 1b57910cc9b3debc16e2e7e6b3bb68e0
2015-09-17T20:46:43Z 80c1c3ca67d5 confd[35]: INFO Target config /etc/nginx/conf.d/app.conf out of sync
2015-09-17T20:46:46Z 80c1c3ca67d5 confd[35]: INFO Target config /etc/nginx/conf.d/app.conf has been updated
2015-09-17T20:46:56Z 80c1c3ca67d5 confd[35]: INFO /etc/nginx/conf.d/app.conf has md5sum 1b57910cc9b3debc16e2e7e6b3bb68e0 should be 4a95cf02d75dae4dfcd78a28815e1968
2015-09-17T20:46:56Z 80c1c3ca67d5 confd[35]: INFO Target config /etc/nginx/conf.d/app.conf out of sync
2015-09-17T20:46:56Z 80c1c3ca67d5 confd[35]: INFO Target config /etc/nginx/conf.d/app.conf has been updated

TOML

[template]

# The name of the template that will be used to render the application's configuration file
# Confd will look in `/etc/conf.d/templates` for these files by default
src = "nginx.tmpl"

# The location to place the rendered configuration file
dest = "/etc/nginx/conf.d/app.conf"

# The etcd keys or directory to watch.  This is where the information to fill in
# the template will come from.
keys = [ "/services/dev/phpfpm/" ]

# File ownership and mode information
owner = "root"
mode = "0644"

# These are the commands that will be used to check whether the rendered config is
# valid and to reload the actual service once the new config is in place
check_cmd = "/usr/sbin/nginx -t"

# reload http://wiki.nginx.org/CommandLine#Stopping_or_Restarting_Nginx
reload_cmd = "kill -HUP $( cat /var/run/nginx.pid )"

TMPL

# Generated by confd {{datetime}}

upstream php {
  {{ range gets "/services/dev/phpfpm/*" }}
  {{ $server := split (.Value) "," }}
  server {{index $server 0}}:{{index $server 1}};
  {{end}}
}

server {
  server_name _;

  ## Your only path reference.
  root /php;
  ## This should be in your http block and if it is, it's not needed here.
  index index.php;

  location = /favicon.ico {
    log_not_found off;
    access_log off;
    }

  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
    }

   location / {
     # This is cool because no php is touched for static content.
     # include the "?$args" part so non-default permalinks doesn't break when using query string
     try_files $uri $uri/ /index.php?$args;
     }

   location ~ \.php$ {
     #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
     include fastcgi.conf;
     fastcgi_intercept_errors on;
     fastcgi_pass php;
     }

   location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
     expires max;
     log_not_found off;
     }
}
cloudnautique commented 9 years ago

Could be the datetime will always change on the polling interval? Which will change the MD5SUM. I'd try removing that to see what happens.

bacongobbler commented 9 years ago

Yes, its the date time feature. I think this is a duplicate issue

nicholasvmoore commented 9 years ago

That was it! Thanks guys