Browse Source

Move datafile lock into the database folder and keep the rest of run files outside of the volume (since UNIX domain sockets can't be created on GlusterFS)

Suren A. Chilingaryan 4 years ago
parent
commit
22d3c280de

+ 7 - 7
Dockerfile

@@ -6,7 +6,7 @@ ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.
     SUPERCRONIC=supercronic-linux-amd64 \
     SUPERCRONIC_SHA1SUM=be43e64c45acd6ec4fce5831e03759c89676a0ea
 
-VOLUME /munin
+VOLUME /munin/db
 #Only small temporary files, doesn't need volume
 #VOLUME /var/lib/nginx
 
@@ -22,8 +22,7 @@ ADD ./munin.conf /etc/munin/munin.conf
 ADD ./nginx.conf /etc/nginx/nginx.conf
 ADD ./nginx-munin /etc/nginx/sites-enabled/munin
 ADD ./start-munin.sh /munin.sh
-ADD ./munin-graph-logging.patch /usr/lib/munin
-ADD ./munin-update-logging.patch /usr/lib/munin
+ADD ./patches /patches
 
 # rsyslog is not actually used, but I keep here configuration just in case
 # Nginx always creates error_log in /var/log/nginx, but doesn't write there if other locating is configured
@@ -41,16 +40,17 @@ RUN \
     rm -f /etc/nginx/sites-enabled/default && \
     \
     ln -s /usr/share/webapps/munin/cgi /usr/lib/munin/cgi && \
-    cd /usr/lib/munin && patch munin-graph < munin-graph-logging.patch && patch munin-update < munin-update-logging.patch && \
+    cd /usr/lib/munin && patch munin-graph < /patches/munin-graph-logging.patch && patch munin-update < /patches/munin-update-logging.patch && \
+    cd /usr/share/perl5/vendor_perl/Munin/Master/ && patch Update.pm < /patches/munin-ds-datalock.patch && \
     sed -re "/@[[:alnum:]]+/ d; s|munin if|if|" /etc/munin/munin.cron.sample > /etc/munin/munin.cron && \
     \
-    bash -c "mkdir -p /munin/{db,run,log,www/cache}" && \
+    bash -c "mkdir -p /munin/{db,log,www/cache}" && \
     ln -s ../www/cache /munin/db/cgi-tmp && \
     rm -rf /var/lib/munin/cgi-tmp && \
     ln -s /munin/www/cache /var/lib/munin/cgi-tmp && \
     \
-    chgrp -R root /munin /etc/munin/munin.conf /var/tmp/nginx /var/lib/nginx && \
-    chmod -R g+rw /munin /etc/munin/munin.conf /var/tmp/nginx  && \
+    chgrp -R root /munin /var/run/munin /etc/munin/munin.conf /var/tmp/nginx /var/lib/nginx && \
+    chmod -R g+rw /munin /var/run/munin /etc/munin/munin.conf /var/tmp/nginx  && \
     for name in "/var/tmp/nginx /munin/"; do find $name -type d -print0 | xargs -0 chmod g+x; done
 
 EXPOSE 8080

+ 1 - 1
munin.conf

@@ -1,5 +1,5 @@
 dbdir	        /munin/db
-rundir	        /munin/run
+rundir	        /var/run/munin
 htmldir         /munin/www
 logdir          /munin/log
 

+ 11 - 0
patches/munin-ds-datalock.patch

@@ -0,0 +1,11 @@
+--- Munin/Master/Update.pm
++++ Munin-ds/Master/Update.pm
+@@ -265,7 +265,7 @@
+ sub _write_new_service_configs_locked {
+     my ($self) = @_;
+ 
+-    my $lock_file = "$config->{rundir}/munin-datafile.lock";
++    my $lock_file = "$config->{dbdir}/datafile.lock";
+     munin_runlock($lock_file);
+ 
+     my $config_dump_file = $self->{config_dump_file};

+ 0 - 0
munin-graph-logging.patch → patches/munin-graph-logging.patch


+ 0 - 0
munin-update-logging.patch → patches/munin-update-logging.patch


+ 1 - 1
start-munin.sh

@@ -12,7 +12,7 @@ SMTP_MESSAGE_DEFAULT='[${var:group};${var:host}] -> ${var:graph_title} -> warnin
 SMTP_MESSAGE="${SMTP_MESSAGE:-$SMTP_MESSAGE_DEFAULT}"
 
 
-mkdir -p /munin/{db,run,log,www/cache}
+mkdir -p /munin/{db,log,www/cache}
 [ -a /munin/db/cgi-tmp ] || ln -s ../www/cache /munin/db/cgi-tmp 
 [ -a /var/lib/munin/cgi-tmp ] || ln -s /munin/www/cache /var/lib/munin/cgi-tmp
 [ -a /var/log/nginx ] || ln -s /tmp /var/log/nginx

+ 1 - 1
test/start_test.sh

@@ -10,6 +10,6 @@ basedir="$( cd -P "$( dirname "$0" )" && pwd )/munin"
 docker run -it \
   -u 1001 \
   -p 8080:8080 \
-  -v $basedir:/munin \
+  -v $basedir:/munin/db \
   -e NODES="styx:192.168.26.117" \
   "$@"