Skip to content

Commit 9797f46

Browse files
bsatoriuagoose77
andauthored
Refactor populate_token function for sidecar auth_state handling (#7896)
* Refactor populate_token function for sidecar auth_state handling * Fix indentation for populate_token function * Refactor populate_token function for clarity * More indentation fixes * Add new volume mount for my-team-buckets * Minor code cleanup Removed duplicate MAAP_PGT environment variable handling. * Apply suggestion from @agoose77 * refactor: rename volume label --------- Co-authored-by: Angus Hollands <goosey15@gmail.com>
1 parent a5c916b commit 9797f46

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

config/clusters/maap/common.values.yaml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,24 @@ jupyterhub:
7878
001-username-claim: |
7979
def populate_token(spawner, auth_state):
8080
# For our deployment-service-check health check user, there is no auth_state.
81-
# So these env variables need not be set.
8281
if auth_state:
83-
82+
pgt = f"jwt:{auth_state.get('id_token', '')}"
83+
8484
spawner.environment.update({
85-
"MAAP_PGT": f"jwt:{auth_state.get("id_token", "")}",
85+
"MAAP_PGT": pgt,
8686
"KC_ACCESS_TOKEN": auth_state.get("access_token", ""),
8787
"KC_ID_TOKEN": auth_state.get("id_token", ""),
8888
"KC_REFRESH_TOKEN": auth_state.get("refresh_token", "")
8989
})
90+
91+
# Inject MAAP_PGT into the s3fs sidecar container
92+
for container in spawner.extra_containers:
93+
if container.get("name") == "s3fs":
94+
env_list = container.setdefault("env", [])
95+
env_list.append({
96+
"name": "MAAP_PGT",
97+
"value": pgt,
98+
})
9099
91100
c.Spawner.auth_state_hook = populate_token
92101
singleuser:
@@ -101,7 +110,7 @@ jupyterhub:
101110
defaultUrl: /lab
102111
storage:
103112
extraVolumes:
104-
01-s3f3-volume:
113+
01-s3fs-volume:
105114
name: s3fs-volume
106115
emptyDir: {}
107116
extraVolumeMounts:
@@ -115,30 +124,36 @@ jupyterhub:
115124
mountPath: /home/rstudio/shared-public
116125
subPath: _shared-public
117126
readOnly: false
118-
03-s3f3-private-bucket-volumemount:
127+
03-s3fs-private-bucket-volumemount:
119128
name: s3fs-volume
120129
mountPath: /home/jovyan/my-private-bucket
121130
subPath: my-private-bucket
122131
mountPropagation: HostToContainer
123132
readOnly: false
124-
04-s3f3-public-bucket-volumemount:
133+
04-s3fs-public-bucket-volumemount:
125134
name: s3fs-volume
126135
mountPath: /home/jovyan/my-public-bucket
127136
subPath: my-public-bucket
128137
mountPropagation: HostToContainer
129138
readOnly: false
130-
05-s3f3-shared-bucket-volumemount:
139+
05-s3fs-shared-bucket-volumemount:
131140
name: s3fs-volume
132141
mountPath: /home/jovyan/shared-buckets
133142
subPath: shared-buckets
134143
mountPropagation: HostToContainer
135144
readOnly: true
136-
06-s3f3-private-triaged-jobs-volumemount:
145+
06-s3fs-private-triaged-jobs-volumemount:
137146
name: s3fs-volume
138147
mountPath: /home/jovyan/triaged-jobs
139148
subPath: triaged-jobs
140149
mountPropagation: HostToContainer
141150
readOnly: true
151+
07-s3fs-org-buckets-volumemount:
152+
name: s3fs-volume
153+
mountPath: /home/jovyan/my-team-buckets
154+
subPath: my-team-buckets
155+
mountPropagation: HostToContainer
156+
readOnly: false
142157
extraContainers:
143158
- name: s3fs
144159
image: mas.dit.maap-project.org/root/che-sidecar-s3fs:2i2c
@@ -171,6 +186,10 @@ jupyterhub:
171186
mountPath: /triaged-jobs
172187
subPath: triaged-jobs
173188
mountPropagation: Bidirectional
189+
- name: s3fs-volume
190+
mountPath: /my-team-buckets
191+
subPath: my-team-buckets
192+
mountPropagation: Bidirectional
174193
profileList:
175194
- display_name: Choose your environment and resources
176195
default: true

0 commit comments

Comments
 (0)