672 Commits

Author SHA1 Message Date
Adrien Delle Cave
edc7ea6d3a Added capfirst in status check list 2018-03-24 08:31:22 +01:00
Adrien Delle Cave
a99798def6 Missed custom check plugins list in many views 2018-03-24 08:13:17 +01:00
Frank Hamand
20fada0aff 0.11.12 0.11.12 2018-03-21 11:22:36 +00:00
Frank Hamand
fd2befbf33 Update changelog 2018-03-21 11:22:35 +00:00
Jean-Fred Berthelot
9c3f4f9161 Debounce JenkinsCheck on the number of job failures
Debounce is “the number of successive failures
permitted before check will be marked as failed”.
It is very useful to avoid alerts on expected hiccups.

For checks whose retry logic lies in Cabot using `frequency`
(which is the case for Graphite, HTTP, and ICMP checks),
it makes sense that the debounce is about how often Cabot retried things.

For JenkinsChecks, however, we have no control over
how often Cabot checks the job. This means that even a
debounce of eg 5 can trigger an alert over 1 job failure.

A simpler implementation of this was to loop over the
recent results, count how many distinct jobs have failed,
(using the job number stored in the `status_check_result`),
and set the status to fail if this is higher than the debounce.
However, Cabot only considers the last 10 results (hardcoded value).
Since Cabot checks the job at fairly high frequency (or at least a
frequency higher than the Jenkins run frequency), this can mean
the status would switch to pass after 10 checks of a single check failure.

We thus need to enrich the StatusCheckResult data model
to store that information.

- Add field `consecutive_failures` to StatusCheckResult model
  (and associated migration).

- Retrieve from Jenkins the last good build, and compute from
  that the number of consecutive failures

- Also display the consecutive failures in the Check results page

Closes #537
2018-03-21 11:22:35 +00:00
Jean-Fred Berthelot
337e359130 Add unit tests for Jenkins
Add unit tests covering
- when there is no build of the job at all
- when there is no good build (ie, only failing builds)
2018-03-21 10:59:51 +00:00
Jean-Fred Berthelot
cbb3be5093 Move calculate_debounced_passing as StatusCheck method
We want to override `calculate_debounced_passing` for the JenkinsCheck.
2018-03-21 10:59:51 +00:00
Jean-Fred Berthelot
f2dfb21f2b Bump Django to 1.11.11
There are vulnerabilities for the intermediate versions.

Changelog: https://docs.djangoproject.com/en/2.0/releases/#id1
2018-03-21 10:59:51 +00:00
Frank Hamand
535e14463b 0.11.11 0.11.11 2018-03-09 17:12:32 +00:00
Frank Hamand
9a4a44a9fc Fix /api/oncall endpoint not working with basic auth 2018-03-09 17:12:16 +00:00
Frank Hamand
f6fd5aba03 0.11.10 0.11.10 2018-03-09 15:10:44 +00:00
Frank Hamand
ccadade420 Remove redundant python requirement
This was installed by django ldap anyway, and the version was clashing
2018-03-09 15:10:44 +00:00
Frank Hamand
e935cb9082 Add /api/oncall endpoint
A new endpoint to return the currently on call users

Also added a serialize method to plugins to allow plugin data (e.g.
slack alias) to get returned with the method.
2018-03-09 15:10:44 +00:00
Frank Hamand
b5dca88ef9 0.11.9 2018-03-09 15:10:43 +00:00
Frank Hamand
b1bc576595 Fix issue where Jenkins variables were required on first launch 2017-11-22 09:58:36 +00:00
Jean-Frédéric
ead3f98487
Pass-through SOCIAL_AUTH_REDIRECT_IS_HTTPS from environment variables (#578)
This is needed when running behind a reverse proxy,
otherwise we get redirected to plain HTTP which does
not match the expected URL in the provider.

Per the python-social-auth documentation:
```
On projects behind a reverse proxy that uses HTTPS, the redirect
URIs can have the wrong schema (http:// instead of https://) if
the request lacks the appropriate headers, which might cause
errors during the auth process.
To force HTTPS in the final URIs set this setting to True
```
https://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html
2017-11-10 10:57:00 +00:00
Jean-Fred Berthelot
7baede72a6 Ignore Flake8 E722
E722 is "do not use bare except", of which we have four violations
in `models/base.py`.

Let's ignore these for now to get the build working again.
2017-11-09 15:01:38 +00:00
Jean-Fred Berthelot
af66cc806d Add test for graphite.parse_metric when exception is raised
Add test for when the API call to Graphite throws an exception.
2017-10-17 17:45:07 +01:00
Jean-Fred Berthelot
bc58675cd5 Add tests for public view page
In cb2fc2e8 was added a public page, which lists services
marked as public.

This adds tests for this page, covering all cases.
2017-10-17 17:35:55 +01:00
Jean-Fred Berthelot
62e8c4b5cd Bump Django to latest 1.11.6
Django 1.11.6 was released on October 5, 2017.
We are still using 1.11 released on April 4, 2017.

Also bump all Django-related dependencies.
2017-10-17 16:43:55 +01:00
Jean-Fred Berthelot
5040c55443 Refactor ICMPStatusCheck run method
The ICMPStatusCheck was performed by shelling out
to the `ping` executable, by building a string for the
command and supplying it to `subprocess.Popen`.

This is dangerous because it allows for shell injections,
as the content of the command is partly user controlled:
one could set the instance address to `8.8.8.8; rm -rf /`,
which would be happily executed.

This is avoided by passing a list of strings to subprocess,
so that the arguments are all passed to ping. The above example
then results in `ping: bad address '8.8.8.8 ; rm -rf /'`

The issue was detected by the Bandit linter:
`B602:subprocess_popen_with_shell_equals_true`

Additionnally, we can simplify the flow by using `check_output`
while redirecting `stderr` to `STDOUT`, and catching the
`CalledProcessError` when the command fails.

This also adds some unit tests for this check.

See also: https://security.openstack.org/guidelines/dg_use-subprocess-securely.html
2017-10-02 15:24:28 +01:00
Jean-Frédéric
2e52785e6b Use sudo to install pip package in Travis-CI (#572)
This has started failing with variations on:
```
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pytz-2017.2.dist-info'
```

Executing under sudo is hardly a solution, but a suggested workaround
per https://github.com/travis-ci/travis-ci/issues/1705
(and we are doing it already to install tox)
2017-10-02 14:33:19 +01:00
Jean-Frédéric
6a9eff8f64 Add Bash linting using bashate (#566)
bashate is "a pep8 equivalent for bash scripts" by OpenStack.
https://docs.openstack.org/bashate/latest/

- Add tox target running bashate on the entire code-base
- Fix docker-entrypoint script accordingly
2017-09-28 11:15:50 +01:00
Jean-Frédéric
12d054efeb Better error message when Jenkins job has no build (#567)
If a job has no build yet, then the check result was
`'NoneType' object has no attribute '__getitem__'`,
making it hard to understand what is going on.

Now we catch that issue early-on and raise an Exception.

All in all this is not great code - we should decide once and for all
if get_job_status is supposed to bubble up issues as return_codes
or if we can use Exceptions.
2017-09-21 18:06:42 +01:00
Jean-Fred Berthelot
b9ceea48a4 0.11.8 2017-09-20 15:19:56 +01:00
Jean-Fred Berthelot
274eaf19da Bump cabot-alert-slack to 0.8.2 2017-09-20 15:19:01 +01:00
Frank Hamand
ab9ff79783 Update ldap dependencies
To fix: https://github.com/cabotapp/docker-cabot/issues/7
2017-09-19 12:23:47 +01:00
Frank Hamand
f19774f16a Update changes 2017-09-19 12:23:47 +01:00
Maks Y
b861c8ce3b Ensure HttpStatusCheck works with unicode contents (#556)
When using the HttpStatusCheck with a Cyrillic website, the match check was not working.

This is because by default Django represent model fields as UTF-8 unicode .
The library "content" is represented as string. (in python 2).

* Extract method `_check_content_pattern` from HttpStatusCheck `_run` method
* Add content conversion to unicode if needed
* Add unit tests for the new method
2017-09-19 11:28:38 +01:00
Frank Hamand
edba32aa82 Merge pull request #562 from iPalash/develop
Option to enable/disable subscription & duty pages
2017-09-15 11:00:28 +01:00
Swapnil Palash
3ae07bb7ce Changing defaults of ENABLE_SUBSCRIPTION & ENABLE_DUTY_ROTA to True 2017-09-14 22:43:07 +05:30
Swapnil Palash
c2bbce7053 Added option to remove subscription page and duty rota from main page, also made the user's to modify into a select multiple box for better usability 2017-09-14 19:50:18 +05:30
Frank Hamand
3e2e1d4200 0.11.7 0.11.7 2017-09-14 15:05:28 +01:00
Frank Hamand
8450b0b466 Fix check plugins not displaying checks correctly on service details 2017-09-14 15:05:16 +01:00
Frank Hamand
09793356de 0.11.6 0.11.6 2017-09-14 14:45:36 +01:00
Frank Hamand
0e92f3ff43 Merge pull request #560 from arachnys/add-autocomplete
Add cloudwatch check plugin to default plugins
2017-09-14 14:44:27 +01:00
Frank Hamand
22ba9b5e41 Add custom checks to service list 2017-09-14 14:34:29 +01:00
Frank Hamand
3ab0c67ed8 Bump cloudwatch plugin 0.11.6b3 2017-09-14 12:30:00 +01:00
Frank Hamand
f5be35ac23 Remove form media from compress
Compress doesn't work properly as form media is dynamic
0.11.6b2
2017-09-14 12:17:22 +01:00
Frank Hamand
30451d6ddf Add cloudwatch check plugin to default plugins
The cloudwatch check plugin needs django autocomplete light -
eventually we can use this for other plugins too (e.g. getting
the available jenkins jobs for jenkins check)
0.11.6b1
2017-09-14 11:05:22 +01:00
Frank Hamand
ae00284b3b Merge pull request #558 from arachnys/refactor-check-plugin-architecture
Refactor check plugin architecture
2017-09-14 10:47:48 +01:00
Frank Hamand
26712a40bf Remove failing plugin tests 2017-09-13 17:59:41 +01:00
Frank Hamand
0f9c94d1f9 Enable custom icons for custom checks 2017-09-13 17:59:41 +01:00
Frank Hamand
5b732cfac2 Refactor custom check plugin architecture
Change to not have separate check plugins and other plugin env variable,
also revert changes to the initial migration - migrations should be
created in the plugins themselves.
2017-09-13 17:59:41 +01:00
Frank Hamand
1afc97b65a 0.11.5 0.11.5 2017-09-11 14:07:51 +01:00
Frank Hamand
6b4645382f Fix multiple jenkins configs not working properly 2017-09-11 13:58:26 +01:00
Frank Hamand
290f798da5 0.11.4 0.11.4 2017-09-07 16:04:01 +01:00
Frank Hamand
46df071d0f Update CHANGES to include jenkinsapi switch 2017-09-07 16:03:52 +01:00
Frank Hamand
13cb71213e Merge pull request #553 from arachnys/switch-jenkins-api
Switch from jenkinsapi to python-jenkins
2017-09-07 16:02:55 +01:00
Frank Hamand
e0498b5c15 Fix linting error 2017-09-07 15:54:59 +01:00