-
Notifications
You must be signed in to change notification settings - Fork 7
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
make the main endpoint more CRUD #25
Conversation
2cb9e38
to
5d6ff8d
Compare
use POST for launch and GET for server status addresses #24
05346aa
to
7ed5316
Compare
7ed5316
to
ee1a864
Compare
The basic functionality is there -- needs to be extended to handle e.g. failed pod launches, I will make additional issues for it. |
32f026d
to
caf119a
Compare
|
||
# check if we are running on k8s | ||
try: | ||
from kubernetes import client, config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this test is enough. Running:
config.load_incluster_config()
should fail outside of k8s.
You can also see if paths like /var/run/secrets/kubernetes.io/serviceaccount
exists and are not empty.
src/notebooks_service.py
Outdated
server_name=server_name | ||
) | ||
) | ||
status = 'spawn initialized' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it intended that we don't return here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops yes this status is superflous. If we return here, it wouldn't make sense to return the html, so I just log that the spawn has been initiated and when we get to the bottom of the function we return with the html that waits for the server.
src/notebooks_service.py
Outdated
if r.status_code == 201: | ||
# server is already running | ||
return redirect(notebook_url) | ||
status = get_notebook_container_status(user['name'], server_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that overwritten?
status = 'spawn initialized'
Pipfile
Outdated
escapism = "*" | ||
kubernetes = "*" | ||
|
||
[dev-packages] | ||
|
||
[requires] | ||
python_version = "3.6" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed because it's forced by the Dockerfile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure actually...
cba860d
to
ab0e595
Compare
src/notebooks_service.py
Outdated
user=user, server_name=server_name | ||
status = 'not started' | ||
|
||
if request.method == 'POST': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if block is too long (readability of code)
f3fb53b
to
bc2f7bd
Compare
bc2f7bd
to
803a1d5
Compare
@jirikuncar Since I authored a sizeable bit too, can I get you to review this? Would help to have another pair of eyes look over this. |
@rokroskar can you check my changes? it's not a small change |
src/notebooks_service.py
Outdated
) as f: | ||
kubernetes_namespace = f.read() | ||
KUBERNETES = True | ||
except: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use bare except.
@@ -0,0 +1,22 @@ | |||
<!DOCTYPE html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Templates should contain a license header too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently not the case in renku-ui --> https://github.com/SwissDataScienceCenter/renku-ui/blob/master/public/index.html
Also, I do not see putting a license header on HTML pages as a standard practice. (Check sites like github, docker, gitlab, stack overflow, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's a Jinja2 template you can include it as a comment.
{#
...
#}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it necessary? required? @erbou ?
src/notebooks_service.py
Outdated
kubernetes_namespace = f.read() | ||
KUBERNETES = True | ||
except: | ||
KUBERNETES = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to start the server without K8S?
src/notebooks_service.py
Outdated
# server is already running | ||
app.logger.debug( | ||
'server {server_name} running'.format(server_name=server_name) | ||
) | ||
return redirect(notebook_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't really need to return here since get_user_server_status
will redirect anyway?
I think this is gtg @jirikuncar and @leafty -- just waiting on @ableuler to do two minor changes to the UI PR SwissDataScienceCenter/renku-ui#266 |
Closes #26 |
addresses #24