FIX theia pod init for playgrounds
@@ -306,6 +306,7 @@ def create_theia_k8s_pod_pvc(
)
)
+ if theia_session.course_id is not None:
# Include COURSE_CONTEXT environment variable as urlsafe_base64
# value. THis needs to be urlsafe because of the way the course
# context cookie is loaded from a request (see get_course_context
@@ -321,6 +322,15 @@ def create_theia_k8s_pod_pvc(
)
)
+ # Only set course code env var if it is available for this session
+ if theia_session.course_id is not None:
+ # Set the course code to be the course code for the course
+ # that this theia session belongs to.
+ theia_extra_env.append(client.V1EnvVar(
+ name="COURSE_CODE",
+ value=theia_session.course.course_code,
+ ))
+
# Figure out which uid to use
theia_user_id = 1001
if privileged:
@@ -377,12 +387,6 @@ def create_theia_k8s_pod_pvc(
name="AUTOSAVE",
value="ON" if autosave else "OFF",
),
- # Set the course code to be the course code for the course
- # that this theia session belongs to.
- client.V1EnvVar(
- name="COURSE_CODE",
- value=theia_session.course.course_code,
- ),
# Setting the repo name makes some of the initialization
# a little easier.
client.V1EnvVar(
