Project

General

Profile

Development guidelines

Back to main page

Please read the Development section of official documentation before contributing any code into this project. This wiki page now focuses only on the guidelines regarding submitting issues and related workflow.

Submitting issues

  • For new issues use english language
  • Fill in as many issue meta information as possible
  • Use issue references in Git commits to assign them to appropriate issues

Issue workflow

  • Current workflow requires either email notifications to be turned on, or frequent checking of the Redmine interface.
  • Assignee owns the issue and it is the person, that is currently supposed to work on that.
  • When work of another person is required, change the assignee to that person.
  • When feedback of another person is required, change status to feedback and the assignee to that person.
  • When the issue is resolved, change status to resolved and the assignee to Pavel Kácha.
  • Only the project manager may use statuses closed or rejected.
  • Issue priority has following meaning:
    • low - Things, that are planned for particular version, but can be dealt with at proper time.
    • normal - Things, that are planned for particular version and should be considered every time next work is being planed.
    • high - Without regard to actual issue severity, all issues that are currently really being worked on should have this priority.
    • urgent - This priority should be used for bugs, that are showing on production system and should be resolved quickly (it is worth stopping current work).
    • immediate - Immediate action must be taken, production system is burning and turning into ruins.
  • Issues, that will not be currently worked on and are being put aside for a moment, must be commented enough to enable continuation and moved to version Future.

Development cheat sheet

How to start development

Please follow the documentation for installation of prerequisites first. Now fetch the project git repository and make it work locally:

sudo apt install sudo adduser make build-essential python3 python3-venv libpython3-dev libpq-dev rrdtool librrd-dev libdb5.3 libdb5.3-dev

mkdir Workspace
cd Workspace
git clone --recurse-submodules [user]@homeproj.cesnet.cz:mentat-ng
cd mentat-ng
git checkout --track origin/release
git checkout --track origin/devel
git fetch --tags

make deps-prerequisites
. venv/bin/activate
make develop
./scripts/sqldb-init.sh

mkdir temp
cd temp
scp root@mentat-hub.cesnet.cz:/var/mentat/backups/mentat_psqldb_latest.tar.gz .
tar -xzvf mentat_psqldb_latest.tar.gz
pg_restore --verbose --if-exists --clean --create --dbname mentat_main ./var/mentat/tmp/mentat_psqldb_daily_XXXXXX/main/

cd ..
psql mentat_events
\copy events (id, detecttime, category, description, source_ip, target_ip, source_port, target_port, source_type, target_type, protocol, node_name, node_type, cesnet_storagetime, cesnet_resolvedabuses, cesnet_eventclass, cesnet_eventseverity, cesnet_inspectionerrors, event, source_ip_aggr_ip4, target_ip_aggr_ip4, source_ip_aggr_ip6, target_ip_aggr_ip6) from ./temp/var/mentat/tmp/mentat_psqldb_daily_XXXXXX/events.dat
mentat-dbmngr.py --command init
hawat-cli db stamp head
cd migrations-events
alembic stamp head
cd ..

Usefull Git commands

# Number of commits between two commits/versions:
$ git rev-list --count v2.2.0..v2.3.0
110

# Total changes between two commits/versions:
$ git log --numstat --pretty="%H" v2.2.0..v2.3.0 | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}'
+16114, -13074

# Total changes in last week:
$ git log --numstat --pretty="%H" --since=1.weeks | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}'
+5827, -1622

Remove unwanted files from repository

Use case: There are files or directories in the Git repository (either by mistake, or because of some legacy policy), that should definitely not be there.
Resources: link

  1. Make sure your local repository copy is up to date, in case anything goes south
  2. Use different local copy of remote repository to make actual changes

Now execute following commands from within git repository:

# Remove DIRECTORY_NAME from all commits, then remove the refs to the old commits
# (repeat these two commands for as many directories that you want to remove)
git filter-branch --tree-filter 'rm -rf DIRECTORY_NAME' --prune-empty HEAD
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d

# Now make sure this does not happen again
echo DIRECTORY_NAME/ >> .gitignore
git add .gitignore
git commit -m 'Removing DIRECTORY_NAME from git history'

# Clean garbage and rewrite upstream repository
git gc
git push origin master --force

Back to main page