Skip to content

feat: TCP health check integration + ECS health checks on staging #5377

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

Merged
merged 12 commits into from
Apr 25, 2025

Conversation

khvn26
Copy link
Member

@khvn26 khvn26 commented Apr 23, 2025

Thanks for submitting a PR! Please check the boxes below:

  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

This picks the flagsmith healthcheck command implemented in Flagsmith/flagsmith-common#60 and adds it to ECS task definitions on staging. This is required for service discovery (and metric collection) to work.

How did you test this code?

Tasks now show up as healthy in ECS console:

image

@khvn26 khvn26 requested a review from a team as a code owner April 23, 2025 20:10
@khvn26 khvn26 requested review from gagantrivedi and removed request for a team April 23, 2025 20:10
Copy link

vercel bot commented Apr 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Apr 25, 2025 3:44pm
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Visit Preview Apr 25, 2025 3:44pm
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview Apr 25, 2025 3:44pm

@khvn26 khvn26 requested a review from rolodato April 23, 2025 20:10
@github-actions github-actions bot added api Issue related to the REST API infrastructure feature New feature or request and removed infrastructure labels Apr 23, 2025
Copy link
Contributor

github-actions bot commented Apr 23, 2025

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-5377 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-5377 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-5377 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-5377 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-5377 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-5377 Finished ✅ Results

Copy link
Contributor

github-actions bot commented Apr 23, 2025

Uffizzi Preview deployment-63070 was deleted.

Copy link

codecov bot commented Apr 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.61%. Comparing base (8dc92c3) to head (97351c9).
Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5377   +/-   ##
=======================================
  Coverage   97.61%   97.61%           
=======================================
  Files        1237     1237           
  Lines       42975    42975           
=======================================
  Hits        41952    41952           
  Misses       1023     1023           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

logger.error(f"Health check failed with status {status_code}")

sys.exit(0 if 200 >= status_code < 300 else 1)
args = parser.parse_args()
Copy link
Member

Choose a reason for hiding this comment

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

Are these TCP health checks only used for service discovery, and only in SaaS environments?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Re https://flagsmith.slack.com/archives/C07G7UAKPNH/p1745340333442389

Does AWS alb support exec health checks? Think it only supports http?

Copy link
Member Author

Choose a reason for hiding this comment

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

The health checks added here are for Cloud Map only, and are expected to be run by ECS, which does not support HTTP.

"healthCheck": {
"command": [
"CMD-SHELL",
"python scripts/healthcheck.py"
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest adding an entrypoint command to run-docker.sh such as healthcheck, to abstract ECS/k8s/etc away from needing to know about Python or the path to the healthcheck.py file. That way we can change the healthcheck implementation easily without needing to modify how we're calling it.

Copy link
Member Author

@khvn26 khvn26 Apr 24, 2025

Choose a reason for hiding this comment

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

This is done in 711218a .

As discussed offline, we are now using flagsmith healthcheck commands.

Co-authored-by: Rodrigo López Dato <rodrigo.lopezdato@flagsmith.com>
@github-actions github-actions bot added infrastructure feature New feature or request and removed feature New feature or request infrastructure labels Apr 25, 2025
@github-actions github-actions bot added infrastructure feature New feature or request and removed feature New feature or request infrastructure labels Apr 25, 2025
@github-actions github-actions bot added infrastructure feature New feature or request and removed feature New feature or request infrastructure labels Apr 25, 2025
@github-actions github-actions bot added infrastructure feature New feature or request and removed feature New feature or request infrastructure labels Apr 25, 2025
@khvn26 khvn26 changed the title feat: TCP health check script + ECS health checks on staging feat: TCP health check integration + ECS health checks on staging Apr 25, 2025
Comment on lines +19 to +28
"healthCheck": {
"command": [
"CMD-SHELL",
"flagsmith healthcheck tcp"
],
"interval": 10,
"timeout": 2,
"retries": 5,
"startPeriod": 5
},
Copy link
Contributor

Choose a reason for hiding this comment

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

@khvn26 Were you able to test this health check in ECS before this reaches production? Sorry I'm late to the party.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, see screenshot evidence in the PR description + Grafana dashboard wouldn't work without these health checks.

Copy link
Contributor

@emyller emyller left a comment

Choose a reason for hiding this comment

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

LGTM if the ECS health check works.

@khvn26 khvn26 merged commit d4b5d6a into main Apr 25, 2025
38 checks passed
@khvn26 khvn26 deleted the feat/ecs-health-checks branch April 25, 2025 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants