Skip to content

Commit

Permalink
Merge pull request #19 from omnivector-solutions/matheushent/PENG-236…
Browse files Browse the repository at this point in the history
…6--add-vantage-agent

PENG-2366  add vantage agent
  • Loading branch information
matheushent authored Nov 25, 2024
2 parents 22b66e5 + 73d3c56 commit c3b57b0
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 37 deletions.
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11.1
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ This project contains the democluster image producing codebase.


#### Tuning
The environment variables `JG_VERSION` and `ENV` are exposed as tunables
The environment variables `JG_VERSION`, `VTG_VERSION` and `ENV` are exposed as tunables
to enable customizing the `democluster` for development purposes.

Example
```bash
ENV=dev JG_VERSION=4.3.1 \
ENV=dev JG_VERSION=4.3.1 VTG_VERSION=2.3.0 \
./public-scripts/deploy-democluster.sh \
aset-fc8b1039-faa7-47b1-967a-c1a55c418740 \
9mWa98GbTJMcBZhinfy08aqHPyQWZUn7tH_XrAGLiYE
Expand Down
7 changes: 7 additions & 0 deletions democluster/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ Tracking of all notable changes to the Demo Cluster image.
Unreleased
----------

0.4.0 - 2024-11-25
------------------

- Install the Jobbergate Agent and the Vantage Agent from the Snap Store in classic mode (`PENG-2372`_).

.. _PENG-2372: https://app.clickup.com/t/18022949/PENG-2372

0.3.0 - 2024-10-13
------------------

Expand Down
3 changes: 0 additions & 3 deletions democluster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ check-deps: ## Check deps needed to build the image

.PHONY: init
init: ## Run packer init .
@if [ ! -z "$JG_VERSION" ]; then\
sed -i 's/jobbergate-agent==[0-9]\+\.[0-9]\+\.[0-9]\+/jobbergate-agent==$(JG_VERSION)/' user-data;\
fi
${PACKER} init .

.PHONY: stage0
Expand Down
44 changes: 25 additions & 19 deletions democluster/user-data
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,25 @@ write_files:
Alias=jobbergate-agent.service
WantedBy=multi-user.target

- path: /usr/lib/systemd/system/vantage-agent.service
owner: root:root
permissions: '0644'
content: |
[Unit]
Description=vantage-agent
After=network.target

[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/srv/vantage-agent-venv
ExecStart=/srv/vantage-agent-venv/bin/vtg-run

[Install]
Alias=vantage-agent.service
WantedBy=multi-user.target

- path: /etc/slurm/slurmrestd.conf
owner: root:root
permissions: '0600'
Expand Down Expand Up @@ -384,6 +403,12 @@ packages:
- apptainer
- influxdb
- influxdb-client

snap:
commands:
0: snap install vantage-agent --channel=stable --classic
1: snap install jobbergate-agent --channel=stable --classic

bootcmd:
- mkdir /run/packer_backup
- mkdir /run/packer_backup/etc
Expand Down Expand Up @@ -461,22 +486,3 @@ runcmd:
EOF

- systemctl daemon-reload

# create jobbergate agent venv
- /usr/bin/python3 -m venv /srv/jobbergate-agent-venv
- /srv/jobbergate-agent-venv/bin/pip install -U pip
- /srv/jobbergate-agent-venv/bin/pip install jobbergate-agent==5.1.0
- |
cat <<EOF > /srv/jobbergate-agent-venv/.env
JOBBERGATE_AGENT_X_SLURM_USER_NAME=root
JOBBERGATE_AGENT_BASE_API_URL=https://apis.@[email protected]
JOBBERGATE_AGENT_OIDC_DOMAIN=auth.@[email protected]/realms/vantage
JOBBERGATE_AGENT_OIDC_AUDIENCE=https://apis.vantagehpc.io
JOBBERGATE_AGENT_OIDC_CLIENT_ID=@CLIENT_ID@
JOBBERGATE_AGENT_OIDC_CLIENT_SECRET=@CLIENT_SECRET@
JOBBERGATE_AGENT_TASK_JOBS_INTERVAL_SECONDS=30
JOBBERGATE_AGENT_TASK_SELF_UPDATE_INTERVAL_SECONDS=30
EOF
chown root:root /srv/jobbergate-agent-venv/.env
chmod 0644 /srv/jobbergate-agent-venv/.env
- systemctl daemon-reload
2 changes: 1 addition & 1 deletion image_factory/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def democluster(
)

# Mount needed directories into the instance
lxd_instance = lxd.LXDInstance(name=instance_name, project="image-factory")
lxd_instance = lxd.LXDInstance(name=instance_name, project=ctx.obj.project_name)
lxd_instance.mount(host_source=Path(os.getcwd()), target=Path("/srv/image-factory"))

# If you already have a packer cache in your home, mount it to speed things up
Expand Down
27 changes: 15 additions & 12 deletions public-scripts/deploy-democluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ launch_instance () {

# Set the environment to the empty string if not supplied
if [ -z $ENV ]; then
ENVIRONMENT=""
BASE_API_URL="https://apis.vantagehpc.io"
OIDC_DOMAIN="auth.vantagehpc.io/realms/vantage"
else
ENVIRONMENT="${ENV}."
BASE_API_URL="https://apis.${ENV}.vantagehpc.io"
OIDC_DOMAIN="auth.${ENV}.vantagehpc.io/realms/vantage"
fi

# Create the cloud-init file and launch the demo cluster instance.
Expand All @@ -91,24 +93,25 @@ runcmd:
REAL_MEMORY=\$(free -m | grep -oP '\\d+' | head -n 1)
sed -i "s|@REAL_MEMORY@|\$REAL_MEMORY|g" /etc/slurm/slurm.conf
- |
sed -i "s|@CLIENT_ID@|$CLIENT_ID|g" /srv/jobbergate-agent-venv/.env
sed -i "s|@CLIENT_SECRET@|$CLIENT_SECRET|g" /srv/jobbergate-agent-venv/.env
sed -i "s|@ENVIRONMENT@|$ENVIRONMENT|g" /srv/jobbergate-agent-venv/.env
- systemctl start slurmrestd
- systemctl restart slurmdbd
- systemctl restart slurmd
- sleep 30
- systemctl restart slurmctld
- scontrol update NodeName=\$(hostname) State=RESUME
- systemctl start jobbergate-agent
- snap set vantage-agent base-api-url=$BASE_API_URL
- snap set vantage-agent oidc-client-id=$CLIENT_ID
- snap set vantage-agent oidc-client-secret=$CLIENT_SECRET
- snap set vantage-agent task-jobs-interval-seconds=30
- snap set jobbergate-agent base-api-url=$BASE_API_URL
- snap set jobbergate-agent oidc-client-id=$CLIENT_ID
- snap set jobbergate-agent oidc-client-secret=$CLIENT_SECRET
- snap set jobbergate-agent task-jobs-interval-seconds=30
- snap set jobbergate-agent x-slurm-user-name=root
- snap start vantage-agent.start
- snap start jobbergate-agent.start
EOF

if ! [ -z "${JG_VERSION}" ]; then
echo " - systemctl stop jobbergate-agent" >> /tmp/cloud-init.yaml
echo " - /srv/jobbergate-agent-venv/bin/pip install -U jobbergate-agent==$JG_VERSION" >> /tmp/cloud-init.yaml
echo " - systemctl start jobbergate-agent" >> /tmp/cloud-init.yaml
fi
mkdir -p $HOME/democluster/tmp

cat /tmp/cloud-init.yaml | multipass launch -c$(nproc) \
Expand Down

0 comments on commit c3b57b0

Please sign in to comment.