Skip to main content

Docker Shaper

This is a spin-off package for the docker-shaper tool, which can be used to monitor Docker stuff like containers, images and volumes and automatically enforce certain cleanup-rules.

Installation

[<PYTHON> -m] pip[3] install [--user] [--upgrade] docker-shaper

Usage

The tool will start an interactive terminal UI (TUI).

poetry run docker-shaper

Attach to build nodes

The application is running in a tmux on the build nodes. The following command can be used to attach to the session:

ssh -t <build node> "su jenkins -Pc 'tmux attach-session -t docker-shaper'"

Development & Contribution

Setup

For active development you need to have poetry and pre-commit installed

python3 -m pip install --upgrade --user poetry pre-commit
git clone ssh://review.lan.tribe29.com:29418/docker_shaper
cd docker_shaper
pre-commit install
# if you need a specific version of Python inside your dev environment
poetry env use ~/.pyenv/versions/3.8.10/bin/python3
poetry install

Workflow

Create a new changelog snippet. If no new snippets is found on a merged change no new release will be built and published.

If the change is based on a Jira ticket, use the Jira ticket name as snippet name otherwise use a unique name.

poetry run \
    changelog-generator \
    create .snippets/CMK-21130.md

After committing the snippet a changelog can be generated locally. For CI usage the --in-place flag is recommended to use as it will update the existing changelog with the collected snippets. For local usage remember to reset the changelog file before a second run, as the version would be updated recursively due to the way the changelog generator is working. It extracts the latest version from the changelog file and puts the found snippets on top.

Future changes to the changelog are ignored by

git update-index --assume-unchanged changelog.md
poetry run \
    changelog-generator \
    changelog changelog.md \
    --snippets=.snippets \
    --in-place \
    --version-reference="https://review.lan.tribe29.com/gitweb?p=docker_shaper.git;a=tag;h=refs/tags/"

Update the version of the project in all required files by calling

poetry run \
    changelog2version \
    --changelog_file changelog.md \
    --version_file cmk_dev/version.py \
    --version_file_type py \
    --additional_version_info="-rc42+$(git rev-parse HEAD)" \
    --print \
    | jq -r .info.version
  • modify and check commits via pre-commit run --all-files

  • after work is done locally:

    • update dependencies before/with a new release
poetry lock
  • build and check package locally
poetry build && \
twine check dist/* &&
python3 -m pip uninstall -y docker-shaper && \
python3 -m pip install --user dist/docker_shaper-$(grep -E "^version.?=" pyproject.toml | cut -d '"' -f 2)-py3-none-any.whl
  • commit, push, review and merge the changes, see docker_shaper/+/92759/
git add ...
git commit -m "bump version, update dependencies"
# merge
  • test deployed packages from test.pypi.org. The extra index URL is required to get those dependencies from pypi.org which are not available from test.pypi.org
pip install --no-cache-dir \
    -i https://test.pypi.org/simple/ \
    --extra-index-url https://pypi.org/simple \
    docker-shaper==<VERSION_WITH_RC>
  • finally merge the changes and let Jenkins create the release tag and deployment

Troubleshooting

Publishing fails with HTTP Error 403

As a workaround which uses the token directly, you can do something like this:

poetry publish --username __token__ --password=<token here>

Todo

  • Fix: stuck auto-reload: was: postpone=True + monitoring log

  • Fix: crawl-images should fix parents not having them listed

  • [-] Fix: stuck crawl images (too many async requests, does not happen in production)

  • Fix: '677aff0727' could not be removed: DockerError(404, 'No such image: 677aff0727:latest')

  • Fix: tried to remove container 4f5fb0848c unknown to us

  • Fix: Crashes (see runlog)

  • Image update message only if needed

  • New TUI

    • make ongoing progress visible
  • review log levels (too verbose)

  • answer https://stackoverflow.com/questions/32723111

  • installable via pip install

  • Quart interface (instead of flask)

  • auto-apply changes to source and configuration files

  • outsourced config file

  • bring in features of former dgcd

  • bring in features of former dockermon

  • untag certain tags

  • container cleanup

  • Fix none image lookup

  • Exceptions to messages

  • Clip

  • Increase/decrease logging via web / signal

  • Link: cleanup (images/containers) now

  • Add volumes list (with recent owners)

  • Containers: Store CPU / Memory usage over time

  • Containers: store history

  • Persist messages

  • Remove old message/container logs

  • Show different color for unmatched images

  • Warn about use of unpinned / upstream images

  • Handle 'build cache objects' (found on system prune)

  • Bring in volume monitoring: which volumes have been created and used by which containers?

  • Containers: show total CPU usage

  • Containers: list volumes

  • Images: list parents / children

  • Volumes: list usage

  • Instructions to readme

  • List unmatched / overmatched tags

  • Links to delete / remove

  • Links to jobs

  • Link: inspect

  • Graph: cpu / containers (idle/up)

  • Authenticate (at least if we can modify behavior, like stopping/removing images/containers)

Knowledge

(just misc links to articles that helped me out)

Logging

Metadata

Release files for docker-shaper 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for docker-shaper 2.1.0
File Size Uploaded Provenance
docker_shaper-2.1.0.tar.gz 35.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for docker-shaper 2.1.0
File Interpreter ABI Platform
docker_shaper-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 72.5 kB

Release files / docker_shaper-2.1.0.tar.gz

Download URL docker_shaper-2.1.0.tar.gz
Size 35.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c3ce0be766bc90e495b471d662bbc29ccd023d0ea24ed766a9f8a698af884ed4
BLAKE2b-256 checksum
How to use checksums
20c6d38852e82621b50409170916386f5d6eb9ca071fc9454e5faa58b36c8457
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.11.6 Linux/5.15.0-130-generic

Release files / docker_shaper-2.1.0-py3-none-any.whl

Download URL docker_shaper-2.1.0-py3-none-any.whl
Size 37.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb70a28662fe2b3f742373be733153aea5c66b33c84cff385e20507f26917258
BLAKE2b-256 checksum
How to use checksums
50c623cda8888753165abee43cafc07750ac23478419deb3e85525b0b00aec9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.11.6 Linux/5.15.0-130-generic

Security for docker-shaper 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page