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

Investigation of using multiple domain names for grafana, and deployer referencing one specific #2304

Open
1 task
consideRatio opened this issue Mar 5, 2023 · 0 comments

Comments

@consideRatio
Copy link
Member

consideRatio commented Mar 5, 2023

The deployer script reads grafana.ingress.tls[0].hosts[0], selecting out hosts[0] specifically as a host to return for a cluster. If a redirect is setup, maybe there won't be issues, maybe there will be - I'm wasn't sure so I investigated.

Conclusion

I think we should be fine. urllib.request.urlopen follows redirects, and so does requests.get it seems. As long as GET and POST are similar, we'll be fine.

Action points

  • Perhaps update docstring of get_grafana_url to mention all existing usage of the returnvalue makes it acceptable to pick one single.

Investigation

get_grafana_url hardcodes to hosts[0]

def get_grafana_url(cluster_name):
"""
Return a Grafana instance URL using the cluster's "support.values.yaml"
file's grafana.ingress.tls[0].hosts[0] config.
"""
cluster_config_dir_path = find_absolute_path_to_cluster_file(cluster_name).parent
config_file = cluster_config_dir_path.joinpath("support.values.yaml")
with open(config_file) as f:
support_config = yaml.load(f)
grafana_tls_config = (
support_config.get("grafana", {}).get("ingress", {}).get("tls", [])
)
if not grafana_tls_config:
raise ValueError(f"grafana.ingress.tls config for {cluster_name} missing!")
# We only have one tls host right now. Modify this when things change.
return "https://" + grafana_tls_config[0]["hosts"][0]

Reference sof get_grafana_url

Grafana API requests via deploy_grafana_dashboards

This function clones the https://github.com/jupyterhub/grafana-dashboards repo and passes the grafana URL to the ./deploy.py script in that project

def deploy_grafana_dashboards(

When ./deploy.py from that project is used, it sends GET and POST requests using this function. I think they may very well redirect correctly and we should be fine. But I don't know for sure. Some tools like curl require you to for example explicitly pass a flag to say that redirects should be followed.

It seems the following is used: from urllib.request import urlopen, Request and testing against https://google.com I note that it does follow the 301 redirect for a GET request at least.

Grafana API requests via new_grafana_token and update_central_grafana_datasources

def new_grafana_token(

def update_central_grafana_datasources(

Seems to use import requests and that seem to follow redirects at least for GET requests.

Related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Shaping / Refinement
Development

No branches or pull requests

1 participant