diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3ec1345 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.py[ocd] + +.idea/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..30fba74 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM fedora:25 + +MAINTAINER "Petr Hracek" + +LABEL summary="Provides a minimal set of packages used for debugging." +LABEL description="The Fedora Debugging Tools Container is a docker-formatted image that includes a minimal set of tools for troubleshooting and investigating a Fedora Host. Designed to run as a privileged container." +LABEL io.k8s.display-name="Fedora Debugging Tools Base" + +RUN dnf install -y --setopt=tsflags=nodocs \ + iputils \ + iproute \ + lsof \ + net-tools \ + passwd \ + strace \ + valgrind && \ + dnf -y clean all + +CMD ["/usr/bin/bash"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c848573 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +.PHONY: build run default + +IMAGE_NAME = debugging-tools +MODULEMDURL=file://debugging-tools.yaml + +all: run +default: run + +build: + docker build --tag=$(IMAGE_NAME) . + +run: build + docker run -it --name $(IMAGE_NAME) --privileged --ipc=host --net=host --pid=host -e HOST=/host -e NAME=$(IMAGE_NAME) -e IMAGE=$(IMAGE_NAME) -v /run:/run -v /var/log:/var/log -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -v /:/host $(IMAGE_NAME) + +test: build + cd tests; MODULE=docker MODULEMD=$(MODULEMDURL) URL="docker=$(IMAGE_NAME)" make all + cd tests; MODULE=rpm MODULEMD=$(MODULEMDURL) URL="docker=$(IMAGE_NAME)" make all diff --git a/README.md b/README.md new file mode 100644 index 0000000..af3385b --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# debugging-tools-base +A minimal set of debugging tools so I can troubleshoot my running server. + +The list of packages available in container is: + + * iproute - Advanced IP routing and network device configuration tools + * iputils - Network monitoring tools including ping + * lsof - A utility which lists open files on a Linux/UNIX system + * net-tools - Basic networking tools + * passwd - An utility for setting or changing passwords using PAM - YES (no if we're not making container) + * strace - Tracks and displays system calls associated with a running process + * valgrind - Tool for finding memory management bugs in programs + + +## How to run the container for debugging + +Pull container from DockerHub: + +```bash +docker pull modularitycontainers/debugging-tools-base +``` + +For running the container, use command: + +```bash +docker run -it --name NAME --privileged --ipc=host --net=host --pid=host -e HOST=/host -e NAME=NAME -e IMAGE=IMAGE -v /run:/run -v /var/log:/var/log -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -v /:/host debugging-tools-base +``` + + +## How to extent the container with you set of tools for debugging + +Write a Dockerfile: + +```bash +FROM modularitycontainers/debugging-tool-base:latest + +MAINTAINTER YOUR_NAME + +RUN INSTALL_PKSG=" " && \ + dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ + dnf -y clean all +CMD ["/usr/bin/bash"] + +``` \ No newline at end of file diff --git a/dead.package b/dead.package deleted file mode 100644 index cfb6fca..0000000 --- a/dead.package +++ /dev/null @@ -1 +0,0 @@ -Unsupported diff --git a/debugging-tools.yaml b/debugging-tools.yaml new file mode 100644 index 0000000..f9f5c9a --- /dev/null +++ b/debugging-tools.yaml @@ -0,0 +1,103 @@ +document: modulemd +version: 1 +data: + summary: Set of debugging tools so I can troubleshoot my running server + description: The list of minimal set of debugging tools except base-runtime. + license: + module: [ MIT ] + dependencies: + buildrequires: + base-runtime: master + # add common-build-dependencies + common-build-dependencies-bootstrap: f26 + common-build-dependencies: f26 + shared-userspace: f26 + requires: + base-runtime: master + shared-userspace: f26 + references: + community: https://fedoraproject.org/wiki/Modularity + documentation: https://fedoraproject.org/wiki/Fedora_Packaging_Guidelines_for_Modules + profiles: + default: + rpms: + - iproute + - iputils + # No dependencies + - lsof + - net-tools + - passwd + - strace + - valgrind + api: + rpms: + - iproute + - iputils + - lsof + - net-tools + - passwd + - strace + - valgrind + components: + rpms: + iproute: + rationale: A dependency of tangerine. + ref: master + buildorder: 10 + iputils: + rationale: A dependency of tangerine. + ref: master + buildorder: 10 + lsof: + rationale: A dependency of tangerine. + ref: master + buildorder: 10 + net-tools: + rationale: A dependency of tangerine. + ref: master + buildorder: 10 + passwd: + rationale: A dependency of tangerine. + ref: master + buildorder: 10 + strace: + rationale: A dependency of tangerine. + ref: master + buildorder: 10 + valgrind: + rationale: A dependency of tangerine. + ref: master + buildorder: 10 + libmnl: + rationale: A dependency of iproute. + ref: master + linux-atm: + rationale: A dependency of iproute. + ref: master + linuxdoc-tools: + rationale: A dependency of iproute. + ref: master + psutils: + rationale: A dependency of iproute. + ref: master + texlive: + rationale: A dependency of iproute. + ref: master + docbook-utils: + rationale: A dependency of iputils. + ref: master + perl-SGMLSpm: + rationale: A dependency of iputils. + ref: master + bluez: + rationale: A dependency of net-tools. + ref: master + libuser: + rationale: A dependency of passwd. + ref: master + libunwind: + rationale: A dependency of strace. + ref: master + openmpi: + rationale: A dependency of valgrind. + ref: master diff --git a/sources b/sources new file mode 100644 index 0000000..e69de29 diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..8fd8ae7 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,6 @@ +MODULE_LINT=/usr/share/moduleframework/tools/modulelint.py +CMD=python -m avocado run --filter-by-tags=-WIP $(MODULE_LINT) *.py + +# +all: + $(CMD) diff --git a/tests/config.yaml b/tests/config.yaml new file mode 100644 index 0000000..3343ad4 --- /dev/null +++ b/tests/config.yaml @@ -0,0 +1,19 @@ +document: modularity-testing +version: 1 +name: debugging-tools +modulemd-url: http://raw.githubusercontent.com/container-images/debugging-tools-base/master/debugging-tools-base.yaml +source: https://github.com/container-images/debugging-tools-base +packages: + rpms: + - iproute + - iputils + - lsof + - net-tools + - passwd + - strace + - valgrind +module: + docker: + source: https://github.com/container-images/debugging-tools-base.git + container: docker.io/modularitycontainers/debugging-tools-base + rpm: diff --git a/tests/simpleTest.py b/tests/simpleTest.py new file mode 100644 index 0000000..c61193e --- /dev/null +++ b/tests/simpleTest.py @@ -0,0 +1,69 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# This Modularity Testing Framework helps you to write tests for modules +# Copyright (C) 2017 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# he Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Authors: Petr Sklenar +# + +from moduleframework import module_framework +import os +import time + + +class simpleTests(module_framework.AvocadoTest): + """ + :avocado: enable + """ + + def test_iputils(self): + self.start() + self.run('ls -al /usr/bin/ping') + self.run('ls -al /usr/bin/tracepath') + self.run('lsof /') + + def test_iproute(self): + self.start() + self.run('ls -al /usr/sbin/ip') + self.run('ls -al /usr/sbin/ifcfg') + x = self.run('/usr/sbin/ifcfg', ignore_status=True) + self.assertEqual(1, x.exit_status) + self.run('ls -al /usr/sbin/ifstat') + self.run('/usr/sbin/ifstat') + + def test_lsof(self): + self.run('lsof /') + + def test_net_tools(self): + self.run('ls -al /usr/sbin/route') + self.run('route') + self.run('ls -al /usr/bin/netstat') + self.run('netstat') + + def test_passwd(self): + self.run('ls -al /usr/bin/passwd') + self.run('passwd --help') + + def test_strace(self): + self.run('ls -al /usr/bin/strace') + self.run('strace -h') + + def test_valgrind(self): + self.run('ls -al /usr/bin/valgrind') + self.run('valgrind -h') +