Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This offers us a way to keep class users added to course namespaces via ColdFron
oc project <namespace>
```

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

3. Run:
```
kubectl create -n rhods-notebooks job --from=cronjob/group-sync group-sync
kubectl create -n <class_namespace> job --from=cronjob/group-sync group-sync
```

### nb-culler
Expand Down
9 changes: 6 additions & 3 deletions container-images/group-sync/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ FROM quay.io/operate-first/opf-toolbox:v0.8.0
# Create the destination directory
WORKDIR /scripts

# Install pip first
RUN dnf install -y python3-pip

# Install requirements first to maximize caching
COPY src/python/group-sync/requirements.txt ./requirements.txt
RUN pip install -r requirements.txt
COPY requirements.txt ./requirements.txt
RUN pip3 install -r requirements.txt

# Install the group-sync application
COPY src/python/group-sync/group-sync.py ./
COPY group-sync.py ./
5 changes: 3 additions & 2 deletions container-images/group-sync/group-sync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import sys
import openshift as oc
import openshift_client as oc
import logging

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

users_to_add = users_in_rolebinding.difference(users_in_group)
users_to_remove = users_in_group.difference(users_in_rolebinding)
Expand Down
8 changes: 4 additions & 4 deletions cronjobs/group-sync/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ spec:
serviceAccountName: group-sync
containers:
- name: group-sync
image: ghcr.io/ocp-on-nerc/bu-rhoai:toolkit
command: ["python", "group-sync.py"]
image: quay.io/sdanni/bu-rhoai:toolkit
command: ["python3", "group-sync.py"]
env:
# EDIT VALUE HERE BEFORE RUNNING
- name: GROUP_NAME
value: <group>
value: cs210
# EDIT VALUE HERE BEFORE RUNNING
- name: NAMESPACE
value: <namespace>
value: cs210-f25-ab47f6
imagePullPolicy: Always
restartPolicy: Never
successfulJobsHistoryLimit: 7
Expand Down
2 changes: 1 addition & 1 deletion cronjobs/group-sync/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ resources:
- rolebinding.yaml
- serviceaccount.yaml
# EDIT VALUE HERE BEFORE APPLYING
namespace: <namespace>
namespace: cs210-f25-ab47f6
8 changes: 8 additions & 0 deletions cronjobs/nb-culler/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ rules:
- get
- list
- watch
- apiGroups:
- ""
resources:
- namespaces
verbs:
- get
- list
- watch
2 changes: 1 addition & 1 deletion cronjobs/nb-culler/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ resources:
- cronjob.yaml
- rolebinding.yaml
- serviceaccount.yaml
namespace: rhods-notebooks
namespace: ope-rhods-testing
2 changes: 1 addition & 1 deletion gpu-class/gpu-class-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ add_sa_to_clusterrolebinding() {
# create_clusterrole_bindings

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

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