Add option to specify log-opt max-size value for docker containers

Bug #1794249 reported by Eric Miller
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
kolla-ansible
Fix Released
Undecided
Doug Szumski

Bug Description

Using Rocky, 7.0.0.0rc1 release of Kolla Ansible...

This is really a wish list item, and maybe there is a way to do it already, so I thought I'd ask.

Docker logs will fill up disks pretty quickly, especially with fluentd and swift-object-server containers (from what we have seen so far).

There is an option "--log opt max-size=XXXX" as describe here:
https://docs.docker.com/config/containers/logging/json-file/

This would allow logs to roll and keep them at bay.

I think this we be added to the containers' configs at the kolla-build stage? Or is there an on-demand method for adding this option after completing a deployment?

Eric

Revision history for this message
Eric Miller (erickmiller) wrote :

I hadn't scrolled up to the top of that page, which indicates that Docker has a global option for enabling the JSON file logging driver by creating /etc/docker/daemon.json with:

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m",
    "max-file": "10"
  }
}

in it - so I am trying that now. If this works, I have answered my own question. :)

It doesn't seem to have taken effect on existing containers, after a container restart - so this may need to be added to the kolla-ansible baremetal bootstrap component here (before the "Start docker" task):
https://github.com/openstack/kolla-ansible/blob/master/ansible/roles/baremetal/tasks/post-install.yml

Eric

Revision history for this message
Eric Miller (erickmiller) wrote :

This worked perfectly, resulting in rotation of logs such as the json.log files found with:
find / | grep "\-json.log" | xargs ls -al

cat << EOF > /usr/share/kolla-ansible/ansible/roles/baremetal/templates/docker_daemon_config.j2
{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m",
    "max-file": "10"
  }
}
EOF

and this patch to:
/usr/share/kolla-ansible/ansible/roles/baremetal/tasks/post-install.yml

88a89,102
> - name: Ensure docker config directory exists
> file:
> path: /etc/docker
> state: directory
> recurse: yes
> become: True
>
> - name: Configure docker daemon
> become: True
> template:
> src: docker_daemon_config.j2
> dest: /etc/docker/daemon.json
> register: docker_configured
>

Eric

Doug Szumski (dszumski)
Changed in kolla-ansible:
assignee: nobody → Doug Szumski (dszumski)
Revision history for this message
Eric Miller (erickmiller) wrote :

Hi Doug, if you can tell me the proper procedure for creating a patch file for uploading to a ticket like this, I will use that from now on when submitting tickets where I have a fix.

Thanks!

Eric

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to kolla-ansible (master)

Fix proposed to branch: master
Review: https://review.openstack.org/609670

Changed in kolla-ansible:
status: New → In Progress
Revision history for this message
Doug Szumski (dszumski) wrote :

Hi Eric, nice job on the fix. Unfortunately I created a patch before I'd found your bug report which I've now submitted. Please feel free to comment on it. I think there are some merits to your approach as the config in the unit file is pretty long now.

https://review.openstack.org/#/c/609670/

Anyhow, in future, there are a couple of useful links, first the contributor guide (one of the things you will need to do is sign the contributor agreement):

https://docs.openstack.org/contributors/code-and-documentation/index.html

And secondly the first contact support list:

https://wiki.openstack.org/wiki/First_Contact_SIG

Hopefully that helps.

Cheers,
Doug

Revision history for this message
Eric Miller (erickmiller) wrote :

Thanks Doug! I'll read and sign and see how I can help! :)

Eric

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to kolla-ansible (master)

Reviewed: https://review.openstack.org/609670
Committed: https://git.openstack.org/cgit/openstack/kolla-ansible/commit/?id=bd54b99132d019b747dcd98af9371628625c8a1b
Submitter: Zuul
Branch: master

commit bd54b99132d019b747dcd98af9371628625c8a1b
Author: Doug Szumski <email address hidden>
Date: Thu Oct 11 10:12:41 2018 +0100

    Constrain the size of Docker logs

    Even though Kolla services are configured to log output to file rather than
    stdout, some stdout still occurs when for example the container re(starts).
    Since the Docker logs are not constrained in size, they can fill up the
    docker volumes drive and bring down the host. One example of when this is
    particularly problematic is when Fluentd cannot parse a log message. The
    warning output is written to the Docker log and in production we have seen
    it eat 100GB of disk space in less than a day. We could configure Fluentd
    not to do this, but the problem may still occur via another mechanism.

    Change-Id: Ia6d3935263a5909c71750b34eb69e72e6e558b7a
    Closes-Bug: #1794249

Changed in kolla-ansible:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/kolla-ansible 8.0.0.0b1

This issue was fixed in the openstack/kolla-ansible 8.0.0.0b1 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to kolla-ansible (stable/rocky)

Fix proposed to branch: stable/rocky
Review: https://review.opendev.org/659821

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to kolla-ansible (stable/rocky)

Reviewed: https://review.opendev.org/659821
Committed: https://git.openstack.org/cgit/openstack/kolla-ansible/commit/?id=354aa1d19b2b8fbeaeda35bed15626bab4acfa8b
Submitter: Zuul
Branch: stable/rocky

commit 354aa1d19b2b8fbeaeda35bed15626bab4acfa8b
Author: Doug Szumski <email address hidden>
Date: Thu Oct 11 10:12:41 2018 +0100

    Constrain the size of Docker logs

    Even though Kolla services are configured to log output to file rather than
    stdout, some stdout still occurs when for example the container re(starts).
    Since the Docker logs are not constrained in size, they can fill up the
    docker volumes drive and bring down the host. One example of when this is
    particularly problematic is when Fluentd cannot parse a log message. The
    warning output is written to the Docker log and in production we have seen
    it eat 100GB of disk space in less than a day. We could configure Fluentd
    not to do this, but the problem may still occur via another mechanism.

    Change-Id: Ia6d3935263a5909c71750b34eb69e72e6e558b7a
    Closes-Bug: #1794249
    (cherry picked from commit bd54b99132d019b747dcd98af9371628625c8a1b)

tags: added: in-stable-rocky
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/kolla-ansible 7.1.1

This issue was fixed in the openstack/kolla-ansible 7.1.1 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to kolla-ansible (stable/queens)

Fix proposed to branch: stable/queens
Review: https://review.opendev.org/678869

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to kolla-ansible (stable/queens)

Reviewed: https://review.opendev.org/678869
Committed: https://git.openstack.org/cgit/openstack/kolla-ansible/commit/?id=403cc371cfdc852c52abf44cb82bf1b0e15bcb53
Submitter: Zuul
Branch: stable/queens

commit 403cc371cfdc852c52abf44cb82bf1b0e15bcb53
Author: Doug Szumski <email address hidden>
Date: Thu Oct 11 10:12:41 2018 +0100

    Constrain the size of Docker logs

    Even though Kolla services are configured to log output to file rather than
    stdout, some stdout still occurs when for example the container re(starts).
    Since the Docker logs are not constrained in size, they can fill up the
    docker volumes drive and bring down the host. One example of when this is
    particularly problematic is when Fluentd cannot parse a log message. The
    warning output is written to the Docker log and in production we have seen
    it eat 100GB of disk space in less than a day. We could configure Fluentd
    not to do this, but the problem may still occur via another mechanism.

    Change-Id: Ia6d3935263a5909c71750b34eb69e72e6e558b7a
    Closes-Bug: #1794249
    (cherry picked from commit bd54b99132d019b747dcd98af9371628625c8a1b)

tags: added: in-stable-queens
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/kolla-ansible 6.2.2

This issue was fixed in the openstack/kolla-ansible 6.2.2 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.