[docker-io] update and rename logrotate cron job

Lokesh Mandvekar lsm5 at fedoraproject.org
Fri Dec 19 04:01:18 UTC 2014


commit 50d98e6615e2c4952795f0554aab1e12785755ae
Author: Lokesh Mandvekar <lsm5 at fedoraproject.org>
Date:   Fri Dec 19 03:56:54 2014 +0000

    update and rename logrotate cron job
    
    NVR: docker-io-1.4.1-2
    
    also install /etc/sysconfig/docker-network
    
    Signed-off-by: Lokesh Mandvekar <lsm5 at fedoraproject.org>

 README.container-logrotate    |   14 --------------
 README.docker-logrotate       |   17 +++++++++++++++++
 docker-container-logrotate.sh |    6 ------
 docker-io.spec                |   39 ++++++++++++++++++++++++---------------
 docker-logrotate.sh           |   11 +++++++++++
 docker-network.sysconfig      |    1 +
 docker.sysconfig              |   10 ++++++++--
 7 files changed, 61 insertions(+), 37 deletions(-)
---
diff --git a/README.docker-logrotate b/README.docker-logrotate
new file mode 100644
index 0000000..e142ad1
--- /dev/null
+++ b/README.docker-logrotate
@@ -0,0 +1,17 @@
+This package will install the 'docker-logrotate' script to
+/etc/cron.daily. This script will run logrotate on all running
+containers and ignore all failures.
+
+This script is enabled by default. To disable it,
+uncomment the line "LOGROTATE=false" in /etc/sysconfig/docker.
+
+Possible issues:
+1. This assumes that logrotate is installed on containers to run
+successfully.
+
+2. A race condition occurs if a container exits before 'docker
+exec' run (though it's ignored)
+
+3. Not all containers may need this (whether logrotate is installed or not)
+
+Suggestions to improve this are welcome.
diff --git a/docker-io.spec b/docker-io.spec
index f3f9c8c..98bbf89 100644
--- a/docker-io.spec
+++ b/docker-io.spec
@@ -15,7 +15,7 @@
 
 Name:       %{repo}-io
 Version:    1.4.1
-Release:    1%{?dist}
+Release:    2%{?dist}
 Summary:    Automates deployment of containerized applications
 License:    ASL 2.0
 URL:        http://www.docker.com
@@ -26,8 +26,9 @@ Source0:    https://%{import_path}/archive/v%{version}.tar.gz
 Source1:    %{repo}.service
 Source2:    %{repo}.sysconfig
 Source3:    %{repo}-storage.sysconfig
-Source4:    %{repo}-container-logrotate.sh
-Source5:    README.container-logrotate
+Source4:    %{repo}-logrotate.sh
+Source5:    README.%{repo}-logrotate
+Source6:    %{repo}-network.sysconfig
 BuildRequires:  glibc-static
 BuildRequires:  golang >= 1.3.3
 # for gorilla/mux and kr/pty https://github.com/dotcloud/docker/pull/5950
@@ -82,7 +83,8 @@ servers, OpenStack clusters, public instances, or combinations of the above.
 %package devel
 BuildRequires:  golang >= 1.2.1-3
 Requires:   golang >= 1.2.1-3
-Requires:   docker-io-pkg-devel
+Requires:   %{name}-pkg-devel
+Provides:   %{repo}-devel
 Summary:    A golang registry for global request variables (source libraries)
 Provides:   golang(%{import_path}) = %{version}-%{release}
 Provides:   golang(%{import_path}/api) = %{version}-%{release}
@@ -135,6 +137,7 @@ This package provides the source libraries for docker.
 %package pkg-devel
 BuildRequires:  golang >= 1.2.1-3
 Requires:   golang >= 1.2.1-3
+Provides:   %{repo}-pkg-devel = %{version}-%{release}
 Summary:    A golang registry for global request variables (source libraries)
 Provides:   golang(%{import_path}/pkg/archive) = %{version}-%{release}
 Provides:   golang(%{import_path}/pkg/broadcastwriter) = %{version}-%{release}
@@ -186,17 +189,17 @@ The import paths of import_path/pkg/...
 
 %package fish-completion
 Summary:    fish completion files for docker
-Requires:   docker-io = %{version}-%{release}
+Requires:   %{name} = %{version}-%{release}
 Requires:   fish
-Provides:   docker-fish-completion = %{version}-%{release}
+Provides:   %{repo}-fish-completion = %{version}-%{release}
 
 %description fish-completion
 This package installs %{summary}.
 
 %package logrotate
 Summary:    cron job to run logrotate on docker containers
-Requires:   docker-io = %{version}-%{release}
-Provides:   docker-logrotate = %{version}-%{release}
+Requires:   %{name} = %{version}-%{release}
+Provides:   %{repo}-logrotate = %{version}-%{release}
 
 %description logrotate
 This package installs %{summary}. logrotate is assumed to be installed on
@@ -204,18 +207,18 @@ containers for this to work, failures are silently ignored.
 
 %package vim
 Summary:    vim syntax highlighting files for docker
-Requires:   docker-io = %{version}-%{release}
+Requires:   %{name} = %{version}-%{release}
 Requires:   vim
-Provides:   docker-vim = %{version}-%{release}
+Provides:   %{repo}-vim = %{version}-%{release}
 
 %description vim
 This package installs %{summary}.
 
 %package zsh-completion
 Summary:    zsh completion files for docker
-Requires:   docker-io = %{version}-%{release}
+Requires:   %{name} = %{version}-%{release}
 Requires:   zsh
-Provides:   docker-zsh-completion = %{version}-%{release}
+Provides:   %{repo}-zsh-completion = %{version}-%{release}
 
 %description zsh-completion
 This package installs %{summary}.
@@ -269,7 +272,7 @@ install -p -m 644 contrib/completion/fish/%{repo}.fish %{buildroot}%{_datadir}/f
 
 # install container logrotate cron script
 install -dp %{buildroot}%{_sysconfdir}/cron.daily/
-install -p -m 755 %{SOURCE4} %{buildroot}%{_sysconfdir}/cron.daily/%{repo}-container-logrotate
+install -p -m 755 %{SOURCE4} %{buildroot}%{_sysconfdir}/cron.daily/%{repo}-logrotate
 
 # install vim syntax highlighting
 install -d %{buildroot}%{_datadir}/vim/vimfiles/{doc,ftdetect,syntax}
@@ -296,6 +299,7 @@ install -p -m 644 contrib/init/systemd/%{repo}.socket %{buildroot}%{_unitdir}
 # for additional args
 install -d %{buildroot}%{_sysconfdir}/sysconfig/
 install -p -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/docker
+install -p -m 644 %{SOURCE6} %{buildroot}%{_sysconfdir}/sysconfig/docker-network
 install -p -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/sysconfig/docker-storage
 
 # sources
@@ -329,6 +333,7 @@ exit 0
 %doc AUTHORS CHANGELOG.md CONTRIBUTING.md LICENSE MAINTAINERS NOTICE README.md 
 %doc LICENSE-vim-syntax README-vim-syntax.md
 %config(noreplace) %{_sysconfdir}/sysconfig/docker
+%config(noreplace) %{_sysconfdir}/sysconfig/docker-network
 %config(noreplace) %{_sysconfdir}/sysconfig/docker-storage
 %{_mandir}/man1/docker*.1.gz
 %{_mandir}/man5/Dockerfile.5.gz
@@ -356,8 +361,8 @@ exit 0
 %{_datadir}/fish/vendor_completions.d/docker.fish
 
 %files logrotate
-%doc README.container-logrotate
-%{_sysconfdir}/cron.daily/%{repo}-container-logrotate
+%doc README.%{repo}-logrotate
+%{_sysconfdir}/cron.daily/%{repo}-logrotate
 
 %files vim
 %{_datadir}/vim/vimfiles/doc/dockerfile.txt
@@ -368,6 +373,10 @@ exit 0
 %{_datadir}/zsh/site-functions/_docker
 
 %changelog
+* Thu Dec 18 2014 Lokesh Mandvekar <lsm5 at fedoraproject.org> - 1.4.1-2
+- update and rename logrotate cron script
+- install /etc/sysconfig/docker-network
+
 * Wed Dec 17 2014 Lokesh Mandvekar <lsm5 at fedoraproject.org> - 1.4.1-1
 - Resolves: rhbz#1175144 - update to upstream v1.4.1
 - Resolves: rhbz#1175097, rhbz#1127570 - subpackages
diff --git a/docker-logrotate.sh b/docker-logrotate.sh
new file mode 100644
index 0000000..27fb979
--- /dev/null
+++ b/docker-logrotate.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+LOGROTATE=true
+[ -f /etc/sysconfig/docker ] && source /etc/sysconfig/docker
+
+if [ $LOGROTATE == true ]; then
+    for id in $(docker ps -q); do
+        exec $(docker exec $id logrotate -s /var/log/logstatus /etc/logrotate.conf > /dev/null 2&>1)
+    done
+fi
+exit 0
diff --git a/docker-network.sysconfig b/docker-network.sysconfig
new file mode 100644
index 0000000..51710bf
--- /dev/null
+++ b/docker-network.sysconfig
@@ -0,0 +1 @@
+# /etc/sysconfig/docker-network
diff --git a/docker.sysconfig b/docker.sysconfig
index 9a8aca7..a3e40f7 100644
--- a/docker.sysconfig
+++ b/docker.sysconfig
@@ -1,7 +1,13 @@
-OPTIONS=--selinux-enabled
-DOCKER_CERT_PATH=/etc/docker
+# /etc/sysconfig/docker
+
+# Modify these options if you want to change the way the docker daemon runs
+OPTIONS='--selinux-enabled'
 
 # Location used for temporary files, such as those created by
 # docker load and build operations. Default is /var/lib/docker/tmp
 # Can be overriden by setting the following environment variable.
 # DOCKER_TMPDIR=/var/tmp
+
+# Controls the /etc/cron.daily/docker-logrotate cron job status.
+# To disable, uncomment the line below.
+# LOGROTATE=false


More information about the scm-commits mailing list