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

feat: ensure notebook endpoints do their job #388

Merged
merged 30 commits into from
Sep 25, 2024

Conversation

sgaist
Copy link
Collaborator

@sgaist sgaist commented Sep 6, 2024

Describe your changes

This PR ensure that the notebook API part correctly answers and acts on the requests sent to make it on par with the renku- notebook implementation.

Issue ticket number and link

Part of #303

@sgaist sgaist requested a review from a team as a code owner September 6, 2024 11:31
@sgaist sgaist force-pushed the feature/notebook-api-working branch 4 times, most recently from bb70ba7 to 0ed563d Compare September 11, 2024 13:28
Copy link
Member

@olevski olevski left a comment

Choose a reason for hiding this comment

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

Thank you for adding this Samuel. It looks really good! Just a few changes.

test/bases/renku_data_services/data_api/utils.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
Comment on lines +709 to +708
try:
await self.nb_config.k8s_client.delete_server(server_name, safe_username=user.id)
except MissingResourceError as err:
raise exceptions.NotFound(message=err.message)
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: Just supress a missing resource error for deletion. I.e. we want the server to not be there so if the resource is not there we can just return a 204. This is what we do in most other endpoints.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was wondering whether there should be a trace left for the admin if there was at some point too many tentative to delete a server.

Copy link
Member

Choose a reason for hiding this comment

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

Sure if you want log a warning instead of fully suppressing.

)
return json(ServerLogs().dump(logs))
except MissingResourceError as err:
raise exceptions.NotFound(message=err.message)
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: just use MissingResourceError from errors.errors - when we raise errors we should be using these exceptions. Then our centralized error handler properly formats these. Not sure why you have even added this try/except because the k8s client will already raise the proper error and message if the server does not exist. So you dont have to catch and reraise here at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did this because the MissingResourceError exception would trigger a 500 error and not the NotFound from sanic.

If I understand things correctly, k8s_client should use the one from errors.errors rather than notebook.errors.user.

Copy link
Member

Choose a reason for hiding this comment

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

If I understand things correctly, k8s_client should use the one from errors.errors rather than notebook.errors.user.

Yes that is exactly right. We should just fully eliminate the errors from notebook.errors

test/bases/renku_data_services/data_api/test_notebooks.py Outdated Show resolved Hide resolved
test/bases/renku_data_services/data_api/test_notebooks.py Outdated Show resolved Hide resolved
test/bases/renku_data_services/data_api/test_notebooks.py Outdated Show resolved Hide resolved
@olevski olevski force-pushed the feat-run-notebook-service-simplify-history branch 3 times, most recently from 9e88bad to 1a44f2e Compare September 23, 2024 08:41
Base automatically changed from feat-run-notebook-service-simplify-history to release-amaltheas-migration September 23, 2024 11:52
@olevski olevski force-pushed the release-amaltheas-migration branch 2 times, most recently from 8b164c0 to 8878712 Compare September 23, 2024 12:03
olevski and others added 17 commits September 23, 2024 22:55
chore: filter environments by owner type

squashme: address comments

feat!: expand environment specification

This is a breaking change in the API.

chore: add tests and minor fixes

chore: test the global environments migration

chore: fix tests

chore: minor improvements to db session handling

squashme: minor fix

squashme: fixups for conflict resolutuion after merge

squashme: fix failing tests

chore: address comments
This includes major edits to the notebooks code to work with the data
service.
The gitlab credentials header from the notebooks is really complicated.
We used it here just to get the access token expiry. I modified the
gateway to now pass in an extra header value to indicate the gitlab
token expiry.
The query args retrieval was incorrect and the log retrieval needed to be waited on.

Slight refactor to ensure mypy is happy with int conversion
The returned values must be tested more thoroughly as for example the
hibernation status is not in the returned json.
The manifest being now validated, it looks like the v2 variant
does not provide some of the fields.

The question is the following: should the manifest definition
reflect that or the code adapted to provide the values.

Currently the second option is used.
@olevski
Copy link
Member

olevski commented Sep 24, 2024

Squash and merge please when you merge this.

@olevski olevski self-requested a review September 24, 2024 08:50
@olevski olevski dismissed their stale review September 24, 2024 08:51

We should fix the tests before we merge.

This configuration forces the use of ipv4 which is required to be
able to start on GitHub's runner which do not provide ipv6.
It's a leftover of the original API and note used in the current
implementation.
The message shown during the CI run on error is not fully
visible so it's hard to understand what is going wrong.
The cluster creation in the CI fails with kind however
k3d was successfully used in renku-notebooks for the
same kind of tests.
The exit method will not be called and the cluster will thus
not be properly deleted.
This ensures that each of them get its own cluster in case one of
them is not properly deleted.
This allows to use the same tool in development and CI.
@sgaist sgaist merged commit 30923b5 into release-amaltheas-migration Sep 25, 2024
15 checks passed
@sgaist sgaist deleted the feature/notebook-api-working branch September 25, 2024 08:21
olevski added a commit that referenced this pull request Sep 25, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
olevski added a commit that referenced this pull request Oct 2, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
olevski added a commit that referenced this pull request Oct 4, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
olevski added a commit that referenced this pull request Oct 8, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
olevski added a commit that referenced this pull request Oct 22, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
olevski added a commit that referenced this pull request Oct 28, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
olevski added a commit that referenced this pull request Oct 28, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
olevski added a commit that referenced this pull request Oct 30, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
olevski added a commit that referenced this pull request Oct 31, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
olevski added a commit that referenced this pull request Nov 1, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
olevski added a commit that referenced this pull request Nov 4, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
olevski added a commit that referenced this pull request Nov 6, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
olevski added a commit that referenced this pull request Nov 8, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
olevski added a commit that referenced this pull request Nov 11, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
olevski added a commit that referenced this pull request Nov 11, 2024
This work brings the notebook related endpoints to a working state
to serve as replacement for the renku-notebooks external service.

Short summary:
- API tests have been added
- Code has been fixed to answer / handle exception
- Automated test cluster creation has been added using k3d

---------

Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
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

Successfully merging this pull request may close these issues.

3 participants