Skip to content

Development

robnagler edited this page Apr 13, 2023 · 27 revisions

Development

To configure the initial master in Vagrant on a Mac or a Linux development environment:

mkdir ~/v3
cd ~/v3
radia_run vagrant-rsconf-dev

You might also want to build-perl-rpms.sh or empty-rpm.sh.

Start the local rsconf development server on v3:

cd ~/v3
vssh
cd ~/src/radiasoft/rsconf
rsconf build
bash run/nginx/start.sh

On the Mac run:

mkdir ~/v4
cd ~/v4
radia_run vagrant-rsconf-dev

This will pull from the development server.

Once installed, you can just do:

cd ~/v4
vssh
sudo su -
rsc

The alias rsc will use the $install_server set on the initial install.

Restarting/reinstalling

However, if you need to re-install, run:

s=file:///home/vagrant/src/radiasoft/rsconf/run/srv
curl $s/index.html | install_server=$s bash -s rsconf.sh $(hostname -f) setup_dev

To restart the local server:

cd ~/src/radiasoft/rsconf
bash run/nginx/start.sh

You'll need to destroy manually.

Simple Sirepo Setup

Create a master, and then run this:

rsconf build
pykern test
cp -a ~/src/radiasoft/rsconf/tests/pkcli/build_work/2/srv/host/v4.radia.run ~/src/radiasoft/rsconf/run/srv/host
bash run/nginx/start.sh

Then create v4, which will use build_data/2.in configuration:

mkdir v4
cd v4
radia_run rsconf-vagrant-dev

Docker Registry

When working on sirepo, it helps to have a local registry, which can be configured on the master, but you'll also need to:

sudo cat /root/.docker/config.json > ~/.docker/config.json
cd ~/src/radiasoft/sirepo
build_push= build_docker_registry=$(hostname -f):5000 radia_run container-build
docker push 'v3.radia.run:5000/radiasoft/sirepo:dev' | cat

To rebuild all the beamsim and sirepo images:

export install_server=http://$(hostname -f):2916
cd ~/src/radiasoft/container-python2
radia_run container-build
vcd ~/src/radiasoft/download/installers/rpm-code
bash dev-setup.sh
bash dev-build-all.sh
cd ~/src/radiasoft/container-beamsim
radia_run container-build
# Make available for download to workers
docker tag radiasoft/beamsim:dev $(hostname -f):5000/radiasoft/beamsim:dev
docker push $(hostname -f):5000/radiasoft/beamsim:dev | cat
cd ~/src/radiasoft/container-sirepo
radia_run container-build
docker tag radiasoft/sirepo:dev $(hostname -f):5000/radiasoft/sirepo:dev
docker push $(hostname -f):5000/radiasoft/sirepo:dev | cat

Local sirepo Docker image

On workers, you'll need to do this manually:

docker pull v3.radia.run:5000/radiasoft/sirepo:dev

OR, you can configure the registry in run/db/000.yml by removing the docker.io/ prefix from mpi_cluster.docker_image:

mpi_cluster:
  docker_image: radiasoft/beamsim-jupyter

Sirepo docker runner multiple hosts

First setup full stack with a local docker daemon and make sure it works. The following assumes localhost.localdomain is a valid host to use.

The docker runner requires some special setup. You should add this to your run/db/000.yml (not .jinja):

    v.radia.run:
      nfs_server:
        exports:
          /home/vagrant/src/radiasoft/sirepo/run/user: [ 10.10.10.0/24 ]
      rsconf_db:
        components: [ sirepo, nfs_server ]
      sirepo:
        docker_hosts: [ v4.radia.run, v5.radia.run ]

For v4 and v5 (both):

      nfs_client:
        mounts:
          v4.radia.run:
            - /srv/sirepo/db/user

On v3 (master) as vagrant:

rsconf host init-docker-registry v.radia.run
rsconf build
sudo bash -l -c rsc
(cd run/srv/host/v.radia.run; tar cf - etc/exports.d root/.docker srv/sirepo/docker_tls etc/docker/certs.d etc/pki) > v.tar
scp v.tar v.radia.run:

On v.radia.run as root:

dnf install -y nfs-utils
cd /
tar xpf ~vagrant/v.tar
cp -a /srv/sirepo/docker_tls /home/vagrant/src/radiasoft/sirepo/run
rm -rf /srv/sirepo
systemctl restart nfs-server
update-ca-trust
systemctl restart docker
sudo install -o vagrant -g vagrant -m 600 /root/.docker/config.json /home/vagrant/.docker

On v4 and v5 as root:

rsc

On v as vagrant:

docker pull v3.radia.run:5000/radiasoft/sirepo:dev
PYKERN_PKDEBUG_CONTROL=runner \
    SIREPO_MPI_CORES=4 SIREPO_RUNNER_DOCKER_HOSTS=localhost.localdomain:v4.radia.run:v5.radia.run \
    SIREPO_RUNNER_DOCKER_IMAGE=v3.radia.run:5000/radiasoft/sirepo:dev \
    SIREPO_RUNNER_DOCKER_TLS_DIR=$PWD/run/docker_tls \
    SIREPO_RUNNER_JOB_CLASS=Docker sirepo service http

Sirepo debugging

When configured with RSConf, you will have files in /src/sirepo.

  • env - contains environment variables. You can add PYKERN_PKDEBUG_CONTROL=. to turn on all real-time tracing
  • start - how container is run. You can add -v /srv/sirepo/sirepo:/home/vagrant/.pyenv/versions/py2/lib/python2.7/site-packages/sirepo to have a local copy of sirepo that is persistent outside the container to debug. You can make the copy by running docker exec -it sirepo bash and cp -a /home/vagrant/.pyenv/versions/py2/lib/python2.7/site-packages/sirepo /srv/sirepo.
  • uswgi.yml and uwsgi.py are created from sirepo/package_data/uwsgi.*.jinja at container start so you need to modify those.

Port forwarding

If you happen to need to port forward, use socat:

# add this line to /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --match multiport --dports https -j ACCEPT
# run this as root
socat TCP-LISTEN:443,fork,reuseaddr TCP:v4.radia.run:443

You can also use ssh LocalForward

# ~/.ssh/config
Host <redacted>
  HostName <redacted>
  Port <redacted>
  User <redacted>
  LocalForward 8080 sirepo.v4.radia.run:443

To get this to work with nginx routing you will need to update your /etc/hosts on the machine where your browser is running

# /etc/hosts
127.0.0.1	localhost localhost.localdomain sirepo.v4.radia.run

Then visit https://sirepo.v4.radia.run:8080. You will get a warning in your browser about the certificates which are self-signed. Click accept.

Misc Errors

If you see this:

Error getting v2 registry: Get https://v3.radia.run:5000/v2/: x509: certificate has expired or is not yet valid"

Restart the docker daemon. It may be the certs were recreated, and the docker daemon caches them instead of reading them from disk.