Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import htcondor
import os
import argparse

def monitor_event_log(event_log_path, username):
event_log = htcondor.JobEventLog(event_log_path)
print(f"Monitoring HTCondor event log: {event_log_path} for user: {username}")

for event in event_log.events(0):
if hasattr(event, "submitter") and event.submitter != username:
continue

if isinstance(event, htcondor.JobEventLog.JobExecutedEvent):
print(f"Job Started by {username}: Cluster {event.cluster} Job {event.proc}")
elif isinstance(event, htcondor.JobEventLog.JobTerminatedEvent):
print(f"Job Completed by {username}: Cluster {event.cluster} Job {event.proc}")
else:
print(f"Unhandled Event for {username}: {event}")

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Monitor HTCondor job events for a specific user.")
parser.add_argument(
"username",
type=str,
help="The username of the submitter whose jobs you want to monitor."
)
parser.add_argument(
"--log-path",
type=str,
default="/var/lib/condor/JobEventLog",
help="Path to the HTCondor job event log file (default: /var/lib/condor/JobEventLog)."
)
args = parser.parse_args()

if not os.path.exists(args.log_path):
print(f"Event log not found at {args.log_path}")
else:
monitor_event_log(args.log_path, args.username)

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

podman exec -it ce-workspace.glideinwms.org /bin/bash
podman exec -it factory-workspace.glideinwms.org /bin/bash
podman exec -it frontend-workspace.glideinwms.org /bin/bash
14 changes: 14 additions & 0 deletions workspaces/shared/scripts/automation_scripts/start_containers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

if [ -z "$1" ]; then
if [ -d "containers/workspaces" ]; then
cd "containers/workspaces" || { echo "Failed to change directory to containers/workspaces"; exit 1; }
else
echo "Error: 'containers/workspaces' not found"
exit 1
fi
else
cd "$1" || { echo "Directory not found: $1"; exit 1; }
fi

podman-compose up -d
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

podman-compose down
75 changes: 75 additions & 0 deletions workspaces/shared/scripts/automation_scripts/workspaces.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

# Script to automate the setup of GlideinWMS ITB environment using podman

# Step 1: Set up working directory
WORKDIR="/myworkdir"
mkdir -p "$WORKDIR/ws-test"
cd "$WORKDIR/ws-test" || exit 1
TEST_DIR=$(pwd)
# Step 2: Clone the GlideinWMS containers repository (check if repo already exists)
if [ ! -d "containers" ]; then
git clone https://github.com/glideinWMS/containers.git
fi
cd containers/workspaces || exit 1

CONTAINER_NAMES=("ce-workspace.glideinwms.org" "factory-workspace.glideinwms.org" "frontend-workspace.glideinwms.org")

# Loop through each container name and remove if it exists
for CONTAINER_NAME in "${CONTAINER_NAMES[@]}"; do
if podman ps -a --format "{{.Names}}" | grep -q "$CONTAINER_NAME"; then
echo "Removing existing container with name $CONTAINER_NAME..."
podman rm -f "$CONTAINER_NAME"
fi
done
# Step 3: Pull the GlideinWMS images (optional namespace for different repo)
export IMAGE_NAMESPACE=${IMAGE_NAMESPACE:-"docker.io/glideinwms"}
podman-compose pull


# Step 4: Set up a directory for GWMS if not provided
#GWMS_PATH="${GWMS_PATH:-$TEST_DIR/gwms}" # don't worry about this step (for now)
#mkdir -p "$GWMS_PATH"

# Step 5: Start the containers
podman-compose up -d

htgettoken -a htvaultprod.fnal.gov -i hypot -r production --credkey=hypotpro/managedtokens/fifeutilgpvm03.fnal.gov -o /tmp/frontend.scitoken

podman cp /tmp/frontend.scitoken frontend-workspace.glideinwms.org:/var/lib/gwms-frontend/.condor/tokens.d/frontend-workspace.glideinwms.org.scitoken
#
# execute commands to run tests inside the containers
#
#podman exec -it frontend-workspace.glideinwms.org /root/scripts/run-test.sh

# Step 7: Bring down the containers on script exit
#cleanup() {
# echo "Bringing down the containers..." # comment this step for future use
# podman-compose down
#}
#trap cleanup EXIT

# Step 8: Optional: Using SL7 images and containers (change IMAGE_LABEL as needed)
#read -p "Do you want to use SL7 images? (y/n) " USE_SL7
#if [[ $USE_SL7 == "y" ]]; then
# IMAGE_LABEL="sl7_latest-20240717-0328" # this can be implemented later, but should be called before step 3
# podman-compose pull
# podman-compose up -d
#fi

# Step 9: Provide useful commands
echo "Useful commands:"
echo "List containers: podman ps -a"
echo "List images: podman images"
echo "Start container scripts:"
echo "podman exec -it ce-workspace.glideinwms.org /root/scripts/startup.sh"
echo "podman exec -it factory-workspace.glideinwms.org /root/scripts/startup.sh"
echo "podman exec -it frontend-workspace.glideinwms.org /root/scripts/startup.sh"
echo "Run tests:"
echo "podman exec -it frontend-workspace.glideinwms.org /root/scripts/run-test.sh"
echo "Shell access:"
echo "podman exec -it ce-workspace.glideinwms.org /bin/bash"
echo "podman exec -it factory-workspace.glideinwms.org /bin/bash"
echo "podman exec -it frontend-workspace.glideinwms.org /bin/bash"


Loading