Commit graph

30 commits

Author SHA1 Message Date
Ildar Iskhakov
61902d5889
Bump base image version (#5033)
# What this PR does

## Which issue(s) this PR closes

Related to [issue link here]

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-09-17 23:19:43 +00:00
Joey Orlando
65dd0a7d20
upgrade Docker base image from python:3.12.3-alpine3.18 to python:3.12.3-alpine3.20 (#4879)
# What this PR does

Fixes [many
CVEs](https://ops.grafana-ops.net/a/grafana-vulnerabilityobs-app/sources/9/version/5561?var-package=&var-cve=CVE-2023-42363&var-riskLevel=$__all)
currently present in our `latest` tagged Docker image:

**Before**
<img width="1250" alt="Screenshot 2024-08-20 at 16 33 14"
src="https://github.com/user-attachments/assets/8215cefe-0a4c-44a8-a817-47d5d9633ceb">

**After**
<img width="1245" alt="Screenshot 2024-08-20 at 16 30 09"
src="https://github.com/user-attachments/assets/2ddc9246-edbc-4801-8dc4-cdc962786ef8">

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-08-20 20:44:18 +00:00
Joey Orlando
535baf7fc8
Fix missing setuptools dep (#4799)
# What this PR does

_tldr;_ I think we should install `setuptools` into our engine
`Dockerfile` + in our CI env because Python 3.12 no longer installs
`distutils` by default. This should unblock us from being able to merge
#4656 and #4555.

**More details**

I would like to be able to merge #4656 and #4555. _However_, in both of
these PRs `setuptools` is being removed from `requirements-dev.txt`
([here](https://github.com/grafana/oncall/pull/4555/files#diff-d8146d0816a943b0fa69a20399d7bbdb58e1c84c8b7933b2ba6dea7c10c410f5L113-L116)
and
[here](https://github.com/grafana/oncall/pull/4656/files#diff-d8146d0816a943b0fa69a20399d7bbdb58e1c84c8b7933b2ba6dea7c10c410f5L113-L116)).
This leads to things breaking because of:
```bash
File "/opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/polymorphic/__init__.py", line 9, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
```

-
https://github.com/grafana/oncall/actions/runs/9865348392/job/27242117474?pr=4555#step:5:98
-
https://github.com/grafana/oncall/actions/runs/10078898966/job/27864920455?pr=4656#step:5:100

Python 3.12 made a change to no longer pre-install `distutils`
([relevant release
notes](https://docs.python.org/3/whatsnew/3.12.html#:~:text=The%20third%2Dparty%20Setuptools%20package%20continues%20to%20provide%20distutils%2C%20if%20you%20still%20require%20it%20in%20Python%203.12%20and%20beyond)):
> [PEP 632](https://peps.python.org/pep-0632/): Remove the distutils
package. See [the migration
guide](https://peps.python.org/pep-0632/#migration-advice) for advice
replacing the APIs it provided. The third-party
[Setuptools](https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html)
package continues to provide distutils, if you still require it in
Python 3.12 and beyond.
>
> [gh-95299](https://github.com/python/cpython/issues/95299): Do not
pre-install setuptools in virtual environments created with
[venv](https://docs.python.org/3/library/venv.html#module-venv). This
means that distutils, setuptools, pkg_resources, and easy_install will
no longer available by default; to access these run pip install
setuptools in the
[activated](https://docs.python.org/3/library/venv.html#venv-explanation)
virtual environment.

Additionally, `setuptools` is in `pip-tools` `UNSAFE_PACKAGES` list
([related GitHub
issue](https://github.com/pypa/pipenv/issues/1417#issuecomment-364795745)),
hence why I think Dependabot is removing it in #4656 and #4555.

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-08-09 20:09:47 +00:00
Joey Orlando
49d20f1a7e
bump uwsgi to 2.0.26 + Python to 3.12.3 (#4495)
# What this PR does

- bumps `uwsgi` to latest version (`2.0.26`), which unblocks us from
bumping Python to 3.12
- bumps Python to 3.12.3
- refactor the Snyk GitHub Actions workflow to use the composable
actions for installed frontend and backend dependencies
- fixes several `AttributeError`s in our tests that went from a warning
to an error in Python 3.12 (see
https://github.com/python/cpython/issues/100690)

# Which issue(s) this PR closes

Closes #4358
Closes https://github.com/grafana/oncall/issues/4387
2024-06-10 15:33:37 -04:00
Matias Bordese
242ace7724
Switch to uv Python package installer/resolver (#4005)
[uv](https://github.com/astral-sh/uv) is an extremely fast Python
package installer and resolver, written in Rust, and designed as a
drop-in replacement for pip and pip-tools workflows (see
[post](https://astral.sh/blog/uv))
2024-04-26 14:30:38 +00:00
Ildar Iskhakov
1101d8461b
Use local arm64 grpcio wheel to make local builds on arm64 faster (#4000)
This is the workaround to make local image build faster on arm64
machines
This commit can be reverted once
https://github.com/grpc/grpc/issues/34998 is resolved
2024-03-05 06:31:58 +00:00
Joey Orlando
9c0bc26680
Fix daily e2e tests GitHub Actions cron job (#3923)
# What this PR does

- fixes our e2e tests to work on all tested versions
- updates Grafana versions that we run the daily e2e tests against (bump
`10.0.2` to `10.0.11` + add `10.1.7` tags)
- updates the Slack status message format + change channel from
#irm-amixr-flux to #gops-oncall-dev

<img width="1479" alt="Screenshot 2024-02-24 at 08 30 06"
src="https://github.com/grafana/oncall/assets/9406895/f5cb91f8-12ce-4978-9c37-c72ee8a01e4b">


## NOTE
It looks like we have some e2e tests that fail under the following
circumstances:
- on Firefox or WebKit
- on Grafana 10.2 and 10.3 (once we fix these, we should [update our e2e
tests that run on all PR
builds](https://github.com/grafana/oncall/blob/dev/.github/workflows/linting-and-tests.yml#L325)
to run against `10.3.3` which is the current latest major version
available)

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2024-02-27 09:21:53 -05:00
Joey Orlando
76a88bc0c1
Revert "upgrade to Python 3.12 (#3456)" and "bump uwsgi version to latest #3466" (#3483)
# What this PR does

This reverts commits 7c4b40a046 and
cdb22285db.

See https://github.com/grafana/oncall-private/pull/2361 for more
details.
2023-12-01 09:56:26 -05:00
Joey Orlando
7c4b40a046
upgrade to Python 3.12 (#3456)
# What this PR does

Upgrade to Python 3.12 + fix several invalid test assertions that lead
to test failures in the latest version of `pytest`:
```
AttributeError: 'called_once_with' is not a valid assertion. Use a spec for the mock if 'called_once_with' is meant to be an attribute.. Did you mean: 'assert_called_once_with'?
```

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-11-30 13:47:41 +00:00
Ildar Iskhakov
549a379e98
Fix tilt file cache_from, optimise dockerfile (#3264)
# What this PR does

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-11-06 12:37:07 +08:00
Ildar Iskhakov
51014735aa
WIP: Direct paging improvements (#3064)
# What this PR does
* Create Direct Paging integration (with default route) when team is
created with bulk_update
* Create notification policies when user is created with bulk_update
* If user notification policies are empty change it to Email
* Minor markup and wording improvements
* Add grafana queue to helm chart
* Remove disabled commands for redis helm chart
* Improve Dockerfile caching

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-28 03:57:49 +00:00
Bob Cotton
6c8344a82d
Use Tilt for local development (#1396)
# What this PR does

PR adds Tilt for local development

## Which issue(s) this PR fixes

## Checklist

- [ ] Tests updated
- [ ] Documentation added
- [ ] `CHANGELOG.md` updated

---------

Co-authored-by: Joey Orlando <joseph.t.orlando@gmail.com>
Co-authored-by: Ildar Iskhakov <Ildar.iskhakov@grafana.com>
Co-authored-by: Michael Derynck <michael.derynck@grafana.com>
Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2023-09-07 19:38:19 +08:00
Ildar Iskhakov
69661f1986
Switch to alpine base image (#2872)
# What this PR does

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-08-29 15:03:32 +08:00
Vadim Stepanov
97757f570e
Fix alerts.0028 migration for SQLite (#2680)
# What this PR does

Fixes an issue with
[alerts.0028](f77a54b518/engine/apps/alerts/migrations/0028_drop_alertreceivechannel_restricted_at.py)
migration failing on SQLite with the following error:
`sqlite3.OperationalError: near "DROP": syntax error`.

The issue is fixed by updating the SQLite version from `3.27.2` to
`3.40.1` (SQLite `3.35.0` introduced native support for dropping columns
as per this [SO answer](https://stackoverflow.com/a/66399224)).

However, I couldn't find an easy way to independently update SQLite,
since it's bundled into Python's standard library.
Updating the Docker image to use the latest Debian stable release fixes
the issue as it already comes with SQLite `3.40.1` out of the box. So
this PR effectively bumps the Debian version from 10 to 12, and bumps
the Python version from `3.11.3` to `3.11.4`.

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-28 18:29:00 +01:00
Joey Orlando
75682517f1
install requirements-dev.txt dependencies oncall docker image dev target (#2284)
# What this PR does

install `requirements-dev.txt` dependencies oncall docker image dev
target to allow commands like `make test` to properly work. Otherwise
you currently get:
```bash
Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "pytest": executable file not found in $PATH: unknown
make: *** [test] Error 1
```

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-19 05:50:59 -04:00
Alexander Cherepanov
f67cfd0494
Run containers as a non-root user (#2053)
# What this PR does

Create a custom non-root user and use it to start an app. So uwsgi does
not require to use `setUid` and `setGid` system calls.

It handles errors while starting in Kubernetes with `runAsNonRoot: true`
check.

## Which issue(s) this PR fixes

closes https://github.com/grafana/oncall/issues/445

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
Co-authored-by: Joey Orlando <joseph.t.orlando@gmail.com>
2023-06-08 07:12:00 +00:00
Ildar Iskhakov
d8e42c731d
Add 413 for requests with content-length > 15Mb on uwsgi (#2095)
# What this PR does

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-05 16:43:10 +08:00
Vadim Stepanov
53d34164ef
Fix SQLite permission issue (#1984)
# What this PR does
Fixes https://github.com/grafana/oncall/issues/1960.

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-05-22 19:16:31 +00:00
Joey Orlando
bb3521b879
upgrade to python 3.11.3 (#1849)
# What this PR does

Upgrades the backend to Python 3.11.3 (latest stable release) + update
linting step on Drone builds to run **all** the linting steps, not just
the Python ones.

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated (N/A)
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required) (N/A)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-05-05 15:32:40 +00:00
Ildar Iskhakov
4a8011d236
Add silk setting to store .prof files in the specific folder and share it between uwsgi workers (#1228)
# What this PR does

## Which issue(s) this PR fixes

## Checklist

- [ ] Tests updated
- [ ] Documentation added
- [ ] `CHANGELOG.md` updated
2023-01-26 20:33:04 +08:00
Ildar Iskhakov
83b1f069d0
Optimize alertgroups endpoint (#1186)
# What this PR does

## Which issue(s) this PR fixes

## Checklist

- [ ] Tests updated
- [ ] Documentation added
- [ ] `CHANGELOG.md` updated
2023-01-21 21:59:20 +08:00
Joey Orlando
25998103cc
swap psycopg2-binary to psycopg2 in requirements.txt (#1062)
Fixes issue when running OnCall locally, on an M1 Mac, and using
PostgreSQL as the database. (ie. `COMPOSE_PROFILES=postgres...`).
Currently getting:
```bash
django.db.utils.OperationalError: SCRAM authentication requires libpq version 10 or above
```

I also tried simply adding `libpq-dev` to the `Dockerfile` but this
change alone does not solve the issue. See
[here](https://github.com/MobSF/Mobile-Security-Framework-MobSF/issues/1898)
for a similar reported issue on GitHub.

**Root Cause**
This issue is caused because `psycopg2-binary` 2.9.3 [doesn't
provide](https://pypi.org/project/psycopg2-binary/2.9.3/#files) binary
wheels for MacOS arm64; binary wheels for MacOS are only provided for
Intel x86 64 bits
([reference](https://stackoverflow.com/a/71653850/3902555)).
2023-01-03 13:47:03 +01:00
Joey Orlando
e1b798d586
add curl and bash to oncall engine docker image (#1034)
Currently unable to exec into a k8s pod. I believe this is because
`bash` is missing from the Docker image after switching from alpine to
debian buster. Debugging this by adding in `bash`.
2022-12-21 18:23:16 +01:00
Joey Orlando
7ebc9cbbf7
modify push notification settings + use fcm-django library (#998)
- swaps out `django-push-notifications` for
[`fcm-django`](https://github.com/grafana/fcm-django). Again.. this is a
fork of the parent repo for exactly the same reason.. the migrations
point to `auth_user` without letting us use our own user model, this has
been patched in the `grafana` fork. The reason why we are using
`fcm-django` vs `django-push-notifications` is that the latter does not
support the new FCM API, only the "legacy" API. The legacy FCM API does
not support certain push notification settings that we would like to
use.
- modifies the iOS/Android specific push notification settings
- adds a `flower` pod in the `docker-compose-developer.yml`, useful for
debugging tasks locally
- sets the mobile app verification token TTL to 5 minutes when
developing locally. The default of 1 minute makes working with device
emulators really tricky..

This PR also swaps out the base image in `engine/Dockerfile` from
`python:3.9-alpine3.16` to `python:3.9-slim-buster`.

As to why.. in short, with the introduction of the `fcm-django` library
there is now a peer-dependency on
[`grpcio`](https://github.com/grpc/grpc) (which is used by
`firebase_admin`.. which I am using in this PR to interact directly with
Firebase Cloud Messaging (FCM)). `grpcio` does not publish wheels (read:
compiled binaries) for the Alpine distro. It does publish wheels for
Debian and hence `pip install -r requirements.txt` does not need to
build this library from the source distribution.

This is a [known
"issue"](https://github.com/grpc/grpc/issues/22815#issuecomment-1107874367)
and the recommended solution in the community is to.. not use alpine.

These were the numbers, when building the image locally, in terms of
image size and build time:

| | Local image size (uncompressed | Build time (may differ based on
your network speed) |
| ------------------------- | -------------------------------------- |
---------- |
| `python:3.9-alpine3.16`   | 785MB  | 320s |
| `python:3.9-slim-buster` | 1.05GB  | 90s   |

Co-authored-by: Salvatore Giordano <salvatoregiordanoo@gmail.com>
2022-12-20 12:41:34 +01:00
Joey Orlando
c7c3aa823c
local dev setup - fixes for some minor issues (#821)
* use docker compose instead of docker-compose

the former is the newer version, latter is being deprecated

* default to using latest version of grafana, not main

main is "bleeding-edge" grafana, use the more stable "latest" tag

* support requirements-enterprise.txt for both docker/non-docker setups

* backend-bootstrap make command should install enterprise
requirements if the file is there

* only mount the sqlite db file in docker-compose if using sqlite as the DB
2022-11-10 16:04:30 +01:00
Joey Orlando
1177e44cc7
enterprise dev changes + few other small changes (#802)
* support enterprise development in docker

* fix flaky mysql healthcheck command

I was getting the mysql_to_create_grafana_db and oncall_db_migration prematurely starting up
this commit changes the healthcheck used here to
be the same as what is used in docker-compose-mysql-rabbitmq.yml

* upgrade docker-compose config files to 3.9

3.8 does not actually support the "long form" version of depends_on
see here for more info https://stackoverflow.com/a/54249757
https://docs.docker.com/compose/compose-file/compose-file-v3/#depends_on

* add make init command and update documentation

* cleanup gitignore files
2022-11-09 07:21:33 +01:00
Joey Orlando
78d01df864
One startup command to rule them all (#760)
* Modify `docker-compose-developer` configuration files, and `Makefile`
to support running everything in containers for local development

- Make use of the COMPOSE_PROFILES env var that is supported by
docker-compose to allow swapping-out/turning off certain docker-compose
services.
- add makefile cleanup command. Will remove all docker resources related
to running the project locally
- The "restart grafana container" issue, where users would need
to restart their grafana container when setting up the project for the
first time, is now fixed (make command now runs yarn build:dev before docker-compose startup;
this ensures grafana-plugin/dist is available for grafana container before it starts up)
- The DEVELOPER.md has been updated as well to reflect these new changes. It
has been moved to ./dev/README.md (and references to the old file have
been updated).
- The redis image that is referenced in the docker-compose files
has been pinned to v7.0.5 (latest version as of this commit) to avoid
any surprises w/ future releases.
- remove root .dockerignore in favour of individual .dockerignore files
in ./engine and ./grafana-plugin
2022-11-07 16:34:43 +01:00
Ildar Iskhakov
6d28fdf69a
Bump django version and alpine version (#778) 2022-11-04 17:34:49 +08:00
Vadim Stepanov
b84b174e20
Allow multiple database and celery broker types (#582)
* add libs for celery + redis

* move redis & cache config to settings/base.py

* move rmq & celery config to settings/base.py

* BROKER -> BROKER_TYPE

* allow multiple database types

* flake8

* add sqlite db creation to dockerfile

* fix ci

* fix ci

* debug

* remove some defaults

* remove prints

* use local memory as cache on ci

* debug

* add DATABASE_DEFAULTS

* add ci test for sqlite + redis

* add ci test for sqlite + redis

* add ci test for sqlite + redis

* debug

* add redis healthcheck

* fix sqlite

* fix dev settings

* refactor dev settings

* tweak ci settings

* clear cache properly between tests

* move db and broker types to constants

* add librabbitmq deps

* use amqp instead of librabbitmq
2022-10-04 09:25:53 +01:00
Michael Derynck
6b40f95033 World, meet OnCall!
Co-authored-by: Eve832 <eve.meelan@grafana.com>
    Co-authored-by: Francisco Montes de Oca <nevermind89x@gmail.com>
    Co-authored-by: Ildar Iskhakov <ildar.iskhakov@grafana.com>
    Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
    Co-authored-by: Julia <ferril.darkdiver@gmail.com>
    Co-authored-by: maskin25 <kengurek@gmail.com>
    Co-authored-by: Matias Bordese <mbordese@gmail.com>
    Co-authored-by: Matvey Kukuy <motakuk@gmail.com>
    Co-authored-by: Michael Derynck <michael.derynck@grafana.com>
    Co-authored-by: Richard Hartmann <richih@richih.org>
    Co-authored-by: Robby Milo <robbymilo@fastmail.com>
    Co-authored-by: Timur Olzhabayev <timur.olzhabayev@grafana.com>
    Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
    Co-authored-by: Yulia Shanyrova <yulia.shanyrova@grafana.com>
2022-06-03 08:09:47 -06:00