-
Notifications
You must be signed in to change notification settings - Fork 3
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
Clusters card on home page not tied to underlying API server #110
Comments
This is causing logs noise in the non-production Portal applications when viewing the Dashboard page. ERROR HIT: 'reachable'
[2022-08-04 14:30:44,774] ERROR in views_error_handling: Thu Aug 4 14:30:44 2022 Traceback occurred:
File "/home/agriffith/.conda/envs/slate-portal/lib/python3.6/site-packages/flask/app.py", line 1513, in full_dispatch_request
rv = self.dispatch_request()
n File "/home/agriffith/.conda/envs/slate-portal/lib/python3.6/site-packages/flask/app.py", line 1499, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
n File "/home/agriffith/repos/slate-portal/portal/decorators.py", line 34, in decorated_function
return fn(*args, **kwargs)
n File "portal/views/views_clusters.py", line 156, in get_cluster_status_xhr
cluster_status = get_cluster_status(cluster_name)
n File "portal/views/views_clusters.py", line 171, in get_cluster_status
cluster_status = cluster_status_query['reachable']
Traceback completed
127.0.0.1 - - [04/Aug/2022 14:30:44] "GET /cluster-status-xhr/uutah-prod HTTP/1.1" 200 -
ERROR HIT: 'reachable'
[2022-08-04 14:30:44,786] ERROR in views_error_handling: Thu Aug 4 14:30:44 2022 Traceback occurred:
File "/home/agriffith/.conda/envs/slate-portal/lib/python3.6/site-packages/flask/app.py", line 1513, in full_dispatch_request
rv = self.dispatch_request()
n File "/home/agriffith/.conda/envs/slate-portal/lib/python3.6/site-packages/flask/app.py", line 1499, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
n File "/home/agriffith/repos/slate-portal/portal/decorators.py", line 34, in decorated_function
return fn(*args, **kwargs)
n File "portal/views/views_clusters.py", line 156, in get_cluster_status_xhr
cluster_status = get_cluster_status(cluster_name)
n File "portal/views/views_clusters.py", line 171, in get_cluster_status
cluster_status = cluster_status_query['reachable']
Traceback completed
127.0.0.1 - - [04/Aug/2022 14:30:44] "GET /cluster-status-xhr/umich-prod HTTP/1.1" 200 -
ERROR HIT: 'reachable'
[2022-08-04 14:30:44,800] ERROR in views_error_handling: Thu Aug 4 14:30:44 2022 Traceback occurred:
File "/home/agriffith/.conda/envs/slate-portal/lib/python3.6/site-packages/flask/app.py", line 1513, in full_dispatch_request
rv = self.dispatch_request()
n File "/home/agriffith/.conda/envs/slate-portal/lib/python3.6/site-packages/flask/app.py", line 1499, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
n File "/home/agriffith/repos/slate-portal/portal/decorators.py", line 34, in decorated_function
return fn(*args, **kwargs)
n File "portal/views/views_clusters.py", line 156, in get_cluster_status_xhr
cluster_status = get_cluster_status(cluster_name)
n File "portal/views/views_clusters.py", line 171, in get_cluster_status
cluster_status = cluster_status_query['reachable'] |
Doing more digging, in if request.method == 'GET':
print("Session from dashboard: {}".format(session))
if session["slate_portal_user"]:
# single-user mode
clusters = ["my-cluster"]
else:
clusters = ["uutah-prod", "uchicago-prod", "umich-prod"]
with open('portal/static/news.md', "r") as file:
news = file.read()
# This json conversion is for JS to read on the frontend
clusters_list = json.dumps(clusters)
return render_template('dashboard.html', clusters=clusters,
news=news, clusters_list=clusters_list) Since new Vue({
el: '#clusters-card',
data () {
return {
clusters: {},
loading: true,
failed: false
}
},
async mounted() {
let status_results = [];
await Promise.all(clusters.map(cluster =>
axios.get('/cluster-status-xhr/' + cluster).then(response => {
status_results.push([cluster, response.data]);
})
));
this.clusters = status_results;
}
}); where we discover an API call in @app.route('/cluster-status-xhr/<cluster_name>', methods=['GET'])
@authenticated
def get_cluster_status_xhr(cluster_name):
"""
- List Clusters Registered on SLATE (json response)
"""
if request.method == 'GET':
cluster_status = get_cluster_status(cluster_name)
# print(cluster_status)
return jsonify(cluster_status)
def get_cluster_status(cluster_name):
"""
- Get Clusters and Status on SLATE
"""
access_token = get_user_access_token(session)
query = {'token': access_token, 'cache': 'cache'}
cluster_status_query = requests.get(
slate_api_endpoint + '/v1alpha3/clusters/' + cluster_name + '/ping', params=query)
cluster_status_query = cluster_status_query.json()
cluster_status = cluster_status_query['reachable']
return cluster_status |
I could make the errors go away for right now without "truly" fixing the issue by doing the following in if session["slate_portal_user"]:
# single-user mode
clusters = ["my-cluster"]
elif slate_api_endpoint == "https://api.dev.slateci.io":
clusters = ["river-dev-fp"]
elif slate_api_endpoint == "https://api.staging.slateci.io":
clusters = ["uutah-dev"]
else:
clusters = ["uutah-prod", "uchicago-prod", "umich-prod"] |
You're right that the clusters on the card should not be hardcoded, but which clusters do we show? The first 5 in the list? The first five may not be the ones we want to highlight. Maybe it can be split, if in production it shows the main three production sites, but in staging and dev it shows the first five. Just some thoughts. |
Steps to reproduce
SLATE_API_ENDPOINT = 'https://api.dev.slateci.io'
inportal.conf
.Suggested fix
Update the Clusters card on the home page to display a subset of the clusters registered with the underlying API server.
Screenshot
The text was updated successfully, but these errors were encountered: