Repository navigation
fix: reuse custom environment when patching session launcher - #699
Conversation
640f791 to
ed0d7f6
Compare
|
You can access the deployment of this PR at https://renku-ci-ds-699.dev.renku.ch |
| assert patch.environment.build_parameters is not None # Make mypy happy in the following statement | ||
| # NOTE: The environment type is changed to be built, so, all required fields should be passed (as in | ||
| # a POST request). No need to get values from the current env, since they will be set by the build. |
There was a problem hiding this comment.
I'm not sure assert is the right thing to do here. if this were to happen, it'd trigger an assertion error which probably isn't handled correctly by our error handling.
Is using if patch.environment.build_parameters is None: with the raise that we had before not enough to keep mypy happy (like changing the not ... to is None)?
There was a problem hiding this comment.
We are already checking that patch.environment.build_parameters is not None in the previous if block and this check was redundant. However, mypy isn't smart enough to deduct that patch.environment.build_parameters is not null. I'm not sure what's the general policy to handle such cases, but we've used assertion before. I've replaced the assertion with a typing cast. I can re-introduce the if/raise block if you think that's a better way of handling it.
| launcher.environment.container_image = ( | ||
| "image:unknown-at-the-moment" # TODO: This should come from the build | ||
| ) | ||
| launcher.environment.default_url = "/lab" # TODO: This should come from the build | ||
| launcher.environment.port = 8888 # TODO: This should come from the build | ||
| launcher.environment.working_directory = None # TODO: This should come from the build | ||
| launcher.environment.mount_directory = None # TODO: This should come from the build | ||
| launcher.environment.uid = 1000 # TODO: This should come from the build | ||
| launcher.environment.gid = 1000 # TODO: This should come from the build | ||
| launcher.environment.environment_kind = models.EnvironmentKind.CUSTOM | ||
| launcher.environment.command = None # TODO: This should come from the build | ||
| launcher.environment.args = None # TODO: This should come from the build | ||
| launcher.environment.environment_image_source = models.EnvironmentImageSource.build | ||
| launcher.environment.build_parameters_id = build_parameters_orm.id | ||
| launcher.environment.build_parameters = build_parameters_orm |
There was a problem hiding this comment.
I know this is not really related to this PR(it was like this before) but I think we should handle this a bit better. Is there an issue for these TODOs? I think we'd either want some polymorphism in the db with an UnbuiltEnvironment type or to have a field in environment like environment.state that can be something like not_built and to allow the fields to be None (with dedicated types for built/unbuilt in code that validate that it's not None except for in this case)
There was a problem hiding this comment.
We'll do some work to store the build result and update the environment once a build finishes (there's a scope's task for that in the build note). I'll create an issue for it and add your comment there.
leafty
left a comment
There was a problem hiding this comment.
Thank you @mohammad-alisafaee!
I will test that the deployment works as expected.
Some early comments from me below.
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_post_build(sanic_client: SanicASGITestClient, user_headers, create_project) -> None: |
There was a problem hiding this comment.
Why is this test removed? We still need to check that triggering a build is working as expected.
There was a problem hiding this comment.
We start the build when the session launcher is posted and starting the build again will fail. We can stop this build and then rebuild it again but that's what we exactly do in test_get_build. I'll re-introduce this test with some modification to at least keep the action name in the test.
leafty
left a comment
There was a problem hiding this comment.
This works as expected when deployed. I had to do a small adjustment on the UI.
5f2a2cf to
1ad76c6
Compare
1ad76c6 to
b2f6581
Compare
ffe8c9a to
115cd4c
Compare
b2f6581 to
b5e20fc
Compare
|
Tearing down the temporary RenkuLab deplyoment for this PR. |
* fix: reuse custom environment when patching session launcher * feat: automatically start build when creating custom env from repo
* fix: reuse custom environment when patching session launcher * feat: automatically start build when creating custom env from repo
/deploy #notest renku=build/session-env-builders renku-notebooks=leafty/shipwright-buildrun-cache renku-ui=build/session-env-builders extra-values=dataService.imageBuilders.enabled=true,dataService.imageBuilders.pushSecretName=flora-docker-secret,dataService.imageBuilders.buildRunTimeoutSeconds=3600,dataService.imageBuilders.buildRunRetentionAfterFailedSeconds=86400,dataService.imageBuilders.buildRunRetentionAfterSucceededSeconds=3600,dataService.imageBuilders.nodeSelector.renku.io/node-purpose=image-build,dataService.imageBuilders.tolerations[0].key=renku.io/dedicated,dataService.imageBuilders.tolerations[0].operator=Equal,dataService.imageBuilders.tolerations[0].effect=NoSchedule,dataService.imageBuilders.tolerations[0].value=image-build,dataService.imageBuilders.outputImagePrefix=harbor.dev.renku.ch/flora-dev/