Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add service_health view function #2097

Merged
merged 10 commits into from
Jun 8, 2021
Merged

Conversation

DavisRayM
Copy link
Contributor

@DavisRayM DavisRayM commented Jun 2, 2021

Changes / Features implemented

  • Add service_health view function
  • Register new /health endpoint
  • Modify docker-compose file
Add `notification` service & Configure the service as a notification backend; Users of the docker compose file can now subscribe to the service via mosquitto pub or any other mqtt client and listen to the notification
  • Add django-redis as a requirement

Steps taken to verify this change does what is intended

Side effects of implementing this change

N/A

Before submitting this PR for review, please make sure you have:

  • Included tests
  • Updated documentation

Closes #2053

@DavisRayM DavisRayM changed the title [WIP] Add service_health view function Add service_health view function Jun 2, 2021
- Add `notification` service
- Update docker settings to include `NOTIFICATION_BACKENDS`
- Switch `queue` service to redis
# Check if cache is accessible
try:
cache.set('ping', 'pong')
service_degraded = not (cache.get('ping') == 'pong')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to restart a pod or create a new pod when we don't have access to the cache?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe so; most of the processing intensive functionalities like user permission generation & other project calculations are stored and tracked using the cache. I think if their down we'd experience some impact on the service... though this is just an assumption

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to have a degraded service than not to have one all. Because if we lose the cache we will lose the whole application, kubernetes will mark all the pod unhealthy

re_path(r'^static/(?P<path>.*)$', staticfiles_views.serve),

# Health check
re_path(r'^service_health$', main_views.service_health)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just use /health endpoint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed in the latest commit

Do not return 500 response codes if the cache service is degraded
@DavisRayM DavisRayM merged commit 4db58e4 into master Jun 8, 2021
@DavisRayM DavisRayM deleted the 2053-health-check-endpoint branch June 8, 2021 07:48
@WinnyTroy WinnyTroy mentioned this pull request Jun 14, 2021
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a health check endpoint
2 participants