Skip to content

Commit

Permalink
Merge pull request dbca-wa#105 from ropable/master
Browse files Browse the repository at this point in the history
Update HealthCheckMiddleware, poetry package versions
  • Loading branch information
ropable authored Oct 11, 2023
2 parents fbfb4e8 + 9d4525e commit b2a0553
Show file tree
Hide file tree
Showing 3 changed files with 246 additions and 210 deletions.
15 changes: 7 additions & 8 deletions ibms_project/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging


LOGGER = logging.getLogger("healthcheck")
LOGGER = logging.getLogger("ibms")


class HealthCheckMiddleware(object):
Expand Down Expand Up @@ -30,14 +30,13 @@ def readiness(self, request):
"""
try:
from django.db import connections
for name in connections:
cursor = connections[name].cursor()
cursor.execute("SELECT 1;")
row = cursor.fetchone()
if row is None:
return HttpResponseServerError("db: invalid response")
cursor = connections["default"].cursor()
cursor.execute("SELECT 1;")
row = cursor.fetchone()
if row is None:
return HttpResponseServerError("Database: invalid response")
except Exception as e:
LOGGER.exception(e)
return HttpResponseServerError("db: cannot connect to database.")
return HttpResponseServerError("Database: unable to connect")

return HttpResponse("OK")
8 changes: 7 additions & 1 deletion kustomize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ values in the format KEY=value (i.e. `overlays/uat/.env`). Required values:
DATABASE_URL=value
SECRET_KEY=value

Review the built resource output using `kustomize`:

```bash
kustomize build kustomize/overlays/uat/ | less
```

Run `kubectl` with the `-k` flag to generate resources for a given overlay:

```bash
kubectl apply -k overlays/uat
kubectl apply -k kustomize/overlays/uat --namespace ibms --dry-run=client
```

# References:
Expand Down
Loading

0 comments on commit b2a0553

Please sign in to comment.