Skip to content

Commit

Permalink
Merge pull request #13 from riotkit-org/release_2.0
Browse files Browse the repository at this point in the history
Release 2.0
  • Loading branch information
blackandred committed Nov 28, 2020
2 parents 8535fb6 + 72332e9 commit afa8c99
Show file tree
Hide file tree
Showing 31 changed files with 1,118 additions and 296 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*__pycache__*
/.venv
.venv-setup.log
/build/
33 changes: 11 additions & 22 deletions .infrastructure/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
#!/bin/bash

# shellcheck disable=SC2001
CHECK_INTERVAL=$(echo "${CHECK_INTERVAL}" | sed "s/\"//g")

get_common_args () {
echo " --directory=/data --db-path=/database/db.sqlite3 "
}

prepare_data_directory () {
#
# Database is outside of "data" directory, as the database contains dynamic data, that could be considered
Expand All @@ -17,34 +10,30 @@ prepare_data_directory () {
touch /database/db.sqlite3
}

prepare_crontab () {
# depending on operating system, create an entrypoint for cron
echo "#!/bin/bash" > /entrypoint.cron.sh
echo "crond -d 2 -f" >> /entrypoint.cron.sh

# check interval can be configured using environment variables
echo "${CHECK_INTERVAL} infracheck --force --wait=${WAIT_TIME} $(get_common_args) " > /etc/crontabs/root

chmod +x /entrypoint.cron.sh
}

prepare_entrypoint () {
ARGS=""

if [[ ${LAZY} == "true" ]] || [[ ${LAZY} == "1" ]]; then
ARGS="${ARGS} --lazy "
if [[ ${REFRESH_TIME} ]]; then
ARGS="${ARGS} --refresh-time=${REFRESH_TIME} "
fi

if [[ ${CHECK_TIMEOUT} ]]; then
ARGS="${ARGS} --timeout=${CHECK_TIMEOUT} "
fi

if [[ ${WAIT_TIME} ]]; then
ARGS="${ARGS} --wait${WAIT_TIME} "
fi

# allow to pass custom arguments from docker run command
echo "#!/bin/bash" > /entrypoint.cmd.sh
echo "infracheck --server --server-port 8000 ${ARGS} $(get_common_args) $@" >> /entrypoint.cmd.sh
echo "infracheck --server-port 8000 ${ARGS} --directory=/data --db-path=/database/db.sqlite3 $@" >> /entrypoint.cmd.sh

cat /entrypoint.cmd.sh
chmod +x /entrypoint.cmd.sh
}

prepare_data_directory
prepare_crontab
prepare_entrypoint "$@"

exec supervisord -c /etc/supervisord.conf
166 changes: 166 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,172 @@
CHANGES
=======

* Fixed "AttributeError: 'str' object has no attribute 'decode'"
* Fixed "AttributeError: 'str' object has no attribute 'decode'"
* #12: Temporarily point to RKD beta version
* #12: Improve RKD integration by using simpler switch \`--imports\`
* #12: Added integration with RiotKit-Do
* #9, #10, #11: Extracted few exceptions into exceptions.py module, moved http layer to the lower level (it should be next to cli), added versioning endpoint
* #9, #10: Update docker image
* #9, #10: Logic extraction from controller into more layers, added model, using pickle instead of json in database cache, the application now is working in two threads - one is server, second is background worker (replaces crontab calls)

v1.10
-----

* #8: Fix issue with missing "msgpack"

v1.10.0.0b3
-----------

* #8: Add missing package "msgpack"

v1.10.0.0b2
-----------

* #8: Add hashbang
* #8: Update docs
* #8: Update docs
* #8: Fix deprecations, update docs

v1.10.0.0b1
-----------

* #8: Update docs formatting
* #8: Covered influxdb-query with tests
* #8: Refactor container test utils
* Docs: Add example to the disk-space
* Docs: Add example to the ovh-expiration
* Docs: Add example to the ovh-expiration
* Docs: Add example to the docker-container-log
* #8: Initially added influxdb-query check

v1.9.1
------

* #7: Added missing ARCH in docker tag
* Updated badges

v1.9
----

* #7: Clean up
* #7: Build on ARM
* #7: Set almost final pipelines
* #7: Enable ARM build
* #7: Attempt to keep the git tag in PBR build
* #7: Attempting to resolve git tag retrieving
* #7: Attempting to resolve git tag retrieving
* #7: add missing wheel package
* #7: add missing wheel package
* #7: add missing hashbang
* #7: return a value in :image task
* #7: Compat
* #7: Add login to registry
* #7: Release job
* #7: Release job
* #7: Fixes related to GH Actions
* #7: Fixes related to GH Actions
* #7: Fixes related to GH Actions
* #7: Fixes related to GH Actions
* #7: Fixes related to GH Actions
* #7: Moving to Github Actions
* #7: Moving to Github Actions
* Build on Python 3.7
* #6: Implement "docker-container-log" check
* Remove unused, nonsense check
* Create index also on existing databases
* Correct: sqlite3.Warning: You can only execute one statement at a time
* Add index for better performance of the SQLite3

v1.8
----

* Refactor: Moved docs to Python files
* Postgres support: Included "postgres" check in docs
* Postgres support: Added simple PostgreSQL check if the DB is up

v1.8.rc1
--------

* Postgres support: Corrected one typo, and added distinction between no rights and no data
* ARM: Correct package name
* Fixed problem with building Docker image - after enforcing regeneration of requirements.txt
* Postgres support: Added missing postgresql-devel required for building/installing psycopg2
* Building: Always re-generate requirements.txt
* Postgres support: Switch from psycopg2 to psycopg2-binary
* Postgres support: Switch from psycopg2 to psycopg2-binary
* Postgres support: Added psycopg2 as dependency
* Postgres support: chmod +x
* Docs: Added PostgreSQL replication checks
* Added PostgreSQL replication checks

v1.7
----

* Docs: Added passwords deploying strategy
* Docs: Added templating documentation

v1.7.rc5
--------

* Runner: Added a simple templating in input variables. Example: ${ENV.USER} to see current user. Use this mechanism to pass credentials securely
* Runner: Added some default timeout for safety reasons

v1.7.rc4
--------

* SSH: Added creation of .ssh directory and known\_hosts file if not present
* SSH: Added support for adding to known\_hosts first time
* Tests: Increased SSH container timeout to avoid random failures
* Load avg checks: Corrected invalid casting in timeout parameter and extracted code into the checklib
* Formatting
* Docker: Added required packages
* Reminder check: Correct a misleading message
* Docs: Deleted development-only information

v1.7.rc3
--------

* Docker: Fixed containers - added missing gcc after adding dependency that requires compilation
* Added correct requirements.txt
* Tests: Corrected paths in tests
* Checks: Add swap-usage-max-percent
* Checks: Added load-average and load-average-auto

v1.7.rc2
--------

* CI: Increased timeout for SSH container
* CI: Added missing make task
* CI: debug
* CI: Fix build by allowing running in venv
* CI: Fix build by allowing running in venv
* Docs: Added all new checks to docs
* Docs: Fixed errors in the docs
* Added new check - \`ssh-files-checksum\`: \`Calls remote process using SSH and expects: the listed files and checksums will be matching\`
* SSH-based checks are now sharing the same code by using a library, simplified imports and made them more safe
* Runner: Added support for lists and dicts in parameters
* Add \`ssh-fingerprint\` check: \`Verifies if remote host fingerprint matches. Helps detecting man-in-the-middle and server takeover attacks.\`
* Tests: Close the docker socket to avoid warnings in tests
* Tests: Separate unit tests from functional tests, improve pipeline - correct mistake
* Tests: Separate unit tests from functional tests, improve pipeline

v1.7.rc1
--------

* Tests: Improved tests that uses SSH container - the container is setup one for a class
* Tests: Collecting output from SSH container
* Refactored "replication-running" check syntax and added additional status information
* CI: Attempt to run unit tests on travis
* CI: Trying to bring up the unit tests
* Covered "reminder" check with tests
* CI: Fixing Python 3.7 build
* CI: Add missing pipenv
* Add compatibility with Python 3.7 stage
* Downgrade packages for Python 3.6 compatibility
* No longer require strict Python version, correct Docker builds
* Corrected mistake in travis configuration
* Changing the way the application is deployed. Introducing pipenv
* Enabled docker in travis builds as it is required for testing
* Covered "ssh-command" with tests and fixed all spotted bugs
* Preparation for the Pipenv support
Expand Down
24 changes: 12 additions & 12 deletions docs/source/first-steps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ The image will by default expose a HTTP endpoint.
List of supported environment variables:

- CHECK_INTERVAL="\*/1 \* \* \* \*"
- REFRESH_TIME=120
- CHECK_TIMEOUT=120
- WAIT_TIME=0
- LAZY=false

**Without Docker**

Expand All @@ -120,13 +120,11 @@ List of supported environment variables:
rkd :install
# run checks in the shell
infracheck --directory=/your-project-directory-path-there
infracheck --directory=/your-project-directory-path-there --no-server
# run a webserver
infracheck --directory=/your-project-directory-path-there --server --server-port=7422 --lazy
# run the application with webserver and background worker
infracheck --directory=/your-project-directory-path-there --server-port=7422 --refresh-time=120 --log-level=info
# set up a scheduled checking
echo "*/1 * * * * infracheck --directory=/your-project-directory-path-there --force" >> /etc/crontabs/root
**Using PIP**

Expand All @@ -135,11 +133,13 @@ List of supported environment variables:
sudo pip install infracheck
# run checks in the shell
infracheck --directory=/your-project-directory-path-there
infracheck --directory=/your-project-directory-path-there --no-server
# run a webserver
infracheck --directory=/your-project-directory-path-there --server --server-port=7422
# run the application with webserver and background worker
infracheck --directory=/your-project-directory-path-there --server-port=7422 --refresh-time=120 --log-level=info
# set up a scheduled checking
echo "*/1 * * * * infracheck --directory=/your-project-directory-path-there --force" >> /etc/crontabs/root
Advanced
--------

**Setting timeout per check:** Set :code:`INFRACHECK_TIMEOUT` environment variable in json file to adjust timeout for given check.
6 changes: 6 additions & 0 deletions example/healthchecks/configured/rkd-sh.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "rkd://rkd.standardlib.shell:sh",
"input": {
"-c": "ls -la"
}
}
2 changes: 1 addition & 1 deletion infracheck/infracheck/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

__author__ = 'RiotKit'
__email__ = 'riotkit_org@riseup.net'
__email__ = 'riotkit@riseup.net'

0 comments on commit afa8c99

Please sign in to comment.