Skip to content

Commit 6df80e5

Browse files
committed
Add class cs599 nb-culler and update group-sync image
1 parent afb66c9 commit 6df80e5

File tree

8 files changed

+26
-14
lines changed

8 files changed

+26
-14
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This offers us a way to keep class users added to course namespaces via ColdFron
1515
oc project <namespace>
1616
```
1717

18-
3. Update the `GROUP_NAME` and `NAMESPACE` env variables in cronjobs/group-sync/cronjob.yaml
18+
3. Update the `GROUP_NAME` and `NAMESPACE` env variables in cronjobs/group-sync/cronjob.yaml and update `namespace` variable in kustomization.yaml
1919
4. From cronjobs/group-sync/ directory run:
2020
```
2121
oc apply -k . --as system:admin
@@ -33,7 +33,7 @@ Alternatively, to run the script immediately:
3333

3434
3. Run:
3535
```
36-
kubectl create -n rhods-notebooks job --from=cronjob/group-sync group-sync
36+
kubectl create -n <class_namespace> job --from=cronjob/group-sync group-sync
3737
```
3838

3939
### nb-culler

container-images/group-sync/Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ FROM quay.io/operate-first/opf-toolbox:v0.8.0
33
# Create the destination directory
44
WORKDIR /scripts
55

6+
# Install pip first
7+
RUN dnf install -y python3-pip
8+
69
# Install requirements first to maximize caching
7-
COPY src/python/group-sync/requirements.txt ./requirements.txt
8-
RUN pip install -r requirements.txt
10+
COPY requirements.txt ./requirements.txt
11+
RUN pip3 install -r requirements.txt
912

1013
# Install the group-sync application
11-
COPY src/python/group-sync/group-sync.py ./
14+
COPY group-sync.py ./

container-images/group-sync/group-sync.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import sys
3-
import openshift as oc
3+
import openshift_client as oc
44
import logging
55

66
LOG = logging.getLogger(__name__)
@@ -13,7 +13,8 @@ def add_users_to_group(group):
1313
users_in_rolebinding = set(
1414
subject['name'] for subject in rolebinding.model.subjects
1515
)
16-
users_in_group = set(group.model.users)
16+
# Handle case where group.model.users might be None
17+
users_in_group = set(group.model.users) if group.model.users else set()
1718

1819
users_to_add = users_in_rolebinding.difference(users_in_group)
1920
users_to_remove = users_in_group.difference(users_in_rolebinding)

cronjobs/group-sync/cronjob.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ spec:
1313
serviceAccountName: group-sync
1414
containers:
1515
- name: group-sync
16-
image: ghcr.io/ocp-on-nerc/bu-rhoai:toolkit
17-
command: ["python", "group-sync.py"]
16+
image: quay.io/sdanni/bu-rhoai:toolkit
17+
command: ["python3", "group-sync.py"]
1818
env:
1919
# EDIT VALUE HERE BEFORE RUNNING
2020
- name: GROUP_NAME
21-
value: <group>
21+
value: cs210
2222
# EDIT VALUE HERE BEFORE RUNNING
2323
- name: NAMESPACE
24-
value: <namespace>
24+
value: cs210-f25-ab47f6
2525
imagePullPolicy: Always
2626
restartPolicy: Never
2727
successfulJobsHistoryLimit: 7

cronjobs/group-sync/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ resources:
77
- rolebinding.yaml
88
- serviceaccount.yaml
99
# EDIT VALUE HERE BEFORE APPLYING
10-
namespace: <namespace>
10+
namespace: cs210-f25-ab47f6

cronjobs/nb-culler/clusterrole.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,11 @@ rules:
3838
- get
3939
- list
4040
- watch
41+
- apiGroups:
42+
- ""
43+
resources:
44+
- namespaces
45+
verbs:
46+
- get
47+
- list
48+
- watch

cronjobs/nb-culler/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ resources:
66
- cronjob.yaml
77
- rolebinding.yaml
88
- serviceaccount.yaml
9-
namespace: rhods-notebooks
9+
namespace: ope-rhods-testing

gpu-class/gpu-class-setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ add_sa_to_clusterrolebinding() {
7979
# create_clusterrole_bindings
8080

8181
oc get ns | grep "^${CLASS_NAME}-" | awk '{print $1}' | while read ns; do
82-
# ns="bu-cs599-pmpp-cuda-71cd48"
82+
#ns="ja-ope-test"
8383
oc project "$ns"
8484

8585
#create a workbench and save the name of the notebook to apply rolebindings

0 commit comments

Comments
 (0)