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 a healthcheck to the companion #5634

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

trashhalo
Copy link

This will let me set a readiness probe for the pods

Copy link
Contributor

github-actions bot commented Feb 1, 2025

Diff output files
diff --git a/packages/@uppy/companion/lib/companion.js b/packages/@uppy/companion/lib/companion.js
index 055c7ec..5da3e96 100644
--- a/packages/@uppy/companion/lib/companion.js
+++ b/packages/@uppy/companion/lib/companion.js
@@ -84,6 +84,7 @@ module.exports.app = (optionsArg = {}) => {
     app.use(middlewares.metrics({ path: options.server.path }));
   }
   app.use(cookieParser()); // server tokens are added to cookies
+  app.get("/health", (req, res) => res.send("OK"));
   app.use(interceptGrantErrorResponse);
   // override provider credentials at request time
   // Making `POST` request to the `/connect/:provider/:override?` route requires a form body parser middleware:

Copy link
Member

@kvz kvz left a comment

Choose a reason for hiding this comment

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

What about using the /metrics endpoint for this?

@trashhalo
Copy link
Author

What about using the /metrics endpoint for this?

I disabled /metrics because I didn't want server metrics to be publicly available.

@kvz
Copy link
Member

kvz commented Feb 5, 2025

It's a better health indicator imho tho because

  • more things need to work in order for it to give a 200
  • you ensure that observability works if /metrics is also your health check

@trashhalo
Copy link
Author

Okay do you want me to remove the new endpoint and just update the kube docs to use /metrics as the readiness probe?

@Murderlon Murderlon requested a review from mifi February 6, 2025 13:06
@kvz
Copy link
Member

kvz commented Feb 6, 2025

Yeah that would be good!

@@ -98,6 +98,7 @@ module.exports.app = (optionsArg = {}) => {
}

app.use(cookieParser()) // server tokens are added to cookies
app.get('/health', (req, res) => res.send('OK'))
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe in the future we want to send some json data here. so users should not expect an "OK" text here.

Suggested change
app.get('/health', (req, res) => res.send('OK'))
app.get('/health', (req, res) => res.end())

Copy link
Member

Choose a reason for hiding this comment

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

Was leaning towards just using /metrics for this Mikael, it’s a more trustworthy check, end we don’t need to introduce a second health-y endoint then

Copy link
Contributor

Choose a reason for hiding this comment

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

that sounds good to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants