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 support for variable graphql host #566

Closed
carvalhovitor2 opened this issue Dec 27, 2024 · 4 comments
Closed

Add support for variable graphql host #566

carvalhovitor2 opened this issue Dec 27, 2024 · 4 comments

Comments

@carvalhovitor2
Copy link

Is your feature request related to a problem? Please describe.
When deploying ghostwriter to kubernetes, there is no way to expose the graphql endpoint as graphql_engine (as it is not RFC1035 preferred syntax ). Being so, the check_status method of the HasuraBackend class always fails, causing an error in the UI even though graphql is UP.

Describe the solution you'd like
I would like to allow a variable GRAPHQL_HOST variable to be passed (without changing its default to graphql_engine) so that the health check picks up whatever value is passed to it.

Describe alternatives you've considered
I can bypass that by fiddling with kubernetes coredns or manually changing the address in the health status module, but these are not ideal.

Additional context
I see os is not used to get env vars, would you suggest a better approach instead? I can hammer it on the entrypoint, but doesnt seem quite ideal...

@carvalhovitor2
Copy link
Author

As a suggestion:

+import os

 # Django Imports
 from django.conf import settings
@@ -32,11 +33,15 @@ class HasuraBackend(BaseHealthCheckBackend):
     """

     critical_service = True
+    @property
+    def graphql_host(self):
+        """Retrieve the GraphQL host from the environment variable or use the default."""
+        return os.getenv("GRAPHQL_HOST", "graphql_engine")

     def check_status(self):
         """Check the status of the backend service."""
         try:
-            response = requests.get("http://graphql_engine:8080/healthz")
+            response = requests.get(f"http://{graphql_host}:8080/healthz")

@chrismaddalena
Copy link
Collaborator

Thanks for mentioning this. I'll look into making the necessary adjustments.

@carvalhovitor2
Copy link
Author

Sure, let me know if you would like me to open a PR with such adjustments.

@chrismaddalena
Copy link
Collaborator

The changes are included in v4.3.10 that just released.

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

No branches or pull requests

2 participants