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

Return 503 when service has no ready endpoints #2696

Merged

Conversation

bjee19
Copy link
Contributor

@bjee19 bjee19 commented Oct 17, 2024

Return 503 when service has no ready endpoints.

Problem: With the new gateway api 1.2 version, it is recommended to return 503 when a HTTPBackendRef refers to a Service that has no ready endpoints.

Solution: Return 503 when service has no ready endpoints.

Testing: Updated unit tests. Manually tested the cafe-example, but when deploying the services/backends I modified the targeted image to something that did not exist: image: nginxdemos/nginx-hello:plain-text -> image: nginxdemos/nginx-hello:plain-text-does-not-exist such that after being deployed, the pod could not start up:

~/Code/nginx-gateway-fabric/examples/cafe-example chore/return…dy-endpoints *3 !4 ❯ kubectl get pods -A                                                                                             ⎈ kind-kind
NAMESPACE            NAME                                              READY   STATUS             RESTARTS   AGE
default              coffee-5689b688c9-47fwc                           0/1     ImagePullBackOff   0          30s
default              tea-7bfb48ffcf-gmrqs                              0/1     ImagePullBackOff   0          30s

When sending a request to the service, verified that a 503 error was returned:

~/Code/nginx-gateway-fabric/examples/cafe-example chore/return…dy-endpoints *3 !4 ❯ curl --resolve cafe.example.com:8080:127.0.0.1 http://cafe.example.com:8080/coffee
<html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body>
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>nginx</center>
</body>
</html>

Closes #2430

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Release notes

If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.


@bjee19 bjee19 requested review from a team as code owners October 17, 2024 18:23
@github-actions github-actions bot added documentation Improvements or additions to documentation chore Pull requests for routine tasks labels Oct 17, 2024
@bjee19 bjee19 changed the title Chore/return 503 when service has no ready endpoints Return 503 when service has no ready endpoints Oct 17, 2024
Copy link

codecov bot commented Oct 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.38%. Comparing base (9fb1d37) to head (36ff484).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2696   +/-   ##
=======================================
  Coverage   89.38%   89.38%           
=======================================
  Files         110      110           
  Lines       10913    10913           
  Branches       50       50           
=======================================
  Hits         9755     9755           
  Misses       1100     1100           
  Partials       58       58           

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

Copy link
Contributor

@salonichf5 salonichf5 left a comment

Choose a reason for hiding this comment

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

lgtm

@bjee19 bjee19 merged commit 431c4ae into nginx:main Oct 18, 2024
40 checks passed
miledxz added a commit to miledxz/nginx-gateway-fabric that referenced this pull request Jan 14, 2025
Return 503 when service has no ready endpoints.

Problem: With the new gateway api 1.2 version, it is recommended to return 503 when a HTTPBackendRef refers to a Service that has no ready endpoints.

Solution: Return 503 when service has no ready endpoints.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Pull requests for routine tasks documentation Improvements or additions to documentation
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Return 503 when service has no ready endpoints
4 participants