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

helm-chart: prevent Traefik from ignoring the backend ingress rule #7859

Merged
merged 1 commit into from
May 13, 2024

Conversation

SpecLad
Copy link
Contributor

@SpecLad SpecLad commented May 7, 2024

Motivation and context

There is a condition that may occur during Kubernetes deployment, where the frontend service already has an endpoint (i.e. the frontend pod), but the backend service does not. For example, the backend pod may not have started yet or the service controller may not have had time to react to the backend pod.

In this case, when Traefik serves a request with an /api/... path, it will see that it matches the /api rule, but since the corresponding service has no endpoints, it will skip that rule and try other rules. And since the / rule matches everything, it will then route the request to the frontend.

This is confusing and unhelpful, and more importantly, it makes health checks return the wrong result. Since the frontend will serve index.html to every request, a request to /api/server/health/ or /api/server/about will return a 200 code, even though the server isn't actually up.

Because of this bug, I have observed weird failures in the Helm workflow, where the "Wait for CVAT to be ready" step completes, but CVAT is not actually ready. (FYI: The failures I've seen are actually in a private repo, but the failure condition could occur in this repo too. It's just more likely in a private repo, because GitHub uses smaller runners in private repos.)

The fix is simple: use the allowEmptyServices Traefik setting, which disables the rule skipping behavior. With this setting on, Traefik will return a 503 response for backend URLs until the backend service gains an endpoint.

How has this been tested?

I deployed the Helm chart, then ran a kubectl delete deployments.apps cvat-backend-server to simulate the server being unavailable. Then I curled the /api/server/health/ endpoint.

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • [ ] I have updated the documentation accordingly
  • [ ] I have added tests to cover my changes
  • [ ] I have linked related issues (see GitHub docs)
  • [ ] I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue to prevent incorrect 200 OK responses from API endpoints before backend readiness.
  • New Features

    • Updated Helm chart to support configurations that allow empty services in the Kubernetes Ingress provider.
  • Documentation

    • Updated version in Helm chart documentation from 0.12.0 to 0.12.1.

Copy link
Contributor

coderabbitai bot commented May 7, 2024

Walkthrough

The update enhances the Helm chart by introducing a fix to prevent premature 200 OK responses from API endpoints before backend readiness. It increments the chart version from 0.12.0 to 0.12.1 and adds a new configuration under the traefik provider in values.yaml to allow empty services.

Changes

File Path Change Summary
.../Chart.yaml Updated version from 0.12.0 to 0.12.1.
.../values.yaml Added allowEmptyServices: true under traefik.
changelog.d/... Introduced fix for spurious 200 OK responses.

🐰✨
Oh, helm the charts of change, my dear,
From 0.12.0 to .1, we cheer!
No more false OKs to hear,
With empty services, we persevere!
Hop, hop, hurray for the backend clear!
🌟🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

There is a condition that may occur during Kubernetes deployment, where the
frontend service already has an endpoint (i.e. the frontend pod), but the
backend service does not. For example, the backend pod may not have started
yet or the service controller may not have had time to react to the backend
pod.

In this case, when Traefik serves a request with an `/api/...` path, it will
see that it matches the `/api` rule, but since the corresponding service has
no endpoints, it will _skip_ that rule and try other rules. And since the
`/` rule matches everything, it will then route the request to the frontend.

This is confusing and unhelpful, and more importantly, it makes health
checks return the wrong result. Since the frontend will serve `index.html`
to every request, a request to `/api/server/health/` or `/api/server/about`
will return a 200 code, even though the server isn't actually up.

Because of this bug, I have observed weird failures in the Helm workflow,
where the "Wait for CVAT to be ready" step completes, but CVAT is not
actually ready. (FYI: The failures I've seen are actually in a private repo,
but the failure condition could occur in this repo too. It's just more
likely in a private repo, because GitHub uses smaller runners in private
repos.)

The fix is simple: use the `allowEmptyServices` Traefik setting, which
disables the rule skipping behavior. With this setting on, Traefik will
return a 503 response for backend URLs until the backend service gains an
endpoint.
@SpecLad SpecLad marked this pull request as ready for review May 7, 2024 11:13
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between e6037af and 17c8d7b.
Files selected for processing (3)
  • changelog.d/20240507_140615_roman_allow_empty_services.md (1 hunks)
  • helm-chart/Chart.yaml (1 hunks)
  • helm-chart/values.yaml (1 hunks)
Files skipped from review due to trivial changes (3)
  • changelog.d/20240507_140615_roman_allow_empty_services.md
  • helm-chart/Chart.yaml
  • helm-chart/values.yaml

@azhavoro azhavoro merged commit 5252983 into cvat-ai:develop May 13, 2024
40 of 41 checks passed
@cvat-bot cvat-bot bot mentioned this pull request May 21, 2024
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.

None yet

2 participants