Skip to content

Commit fa76e42

Browse files
committed
started ioc_changes1 tutorial
1 parent 0dc11a5 commit fa76e42

File tree

4 files changed

+110
-105
lines changed

4 files changed

+110
-105
lines changed

docs/user/tutorials/create_ioc.rst

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,21 @@ detector as follows:
188188
entities:
189189
190190
- type: ADSimDetector.simDetector
191-
PORT: DET.DET
192-
P: BL01T-EA-TST-01
193-
R: ":DET:"
191+
PORT: DET.DET
192+
P: BL01T-EA-TST-01
193+
R: ":DET:"
194+
195+
.. note::
196+
197+
If you are unfamiliar with YAML then you could take a look at
198+
the YAML spec here: https://yaml.org/spec/1.2/spec.html#id2759963.
199+
200+
Be aware that white space is significant. i.e. indentation represents
201+
nesting. Above we have a list of entities, each list item is denoted by
202+
``-``. There is currently a single entry in the list which is a dictionary
203+
of key value pairs. The first key is ``type`` and the value is
204+
``ADSimDetector.simDetector``.
205+
194206

195207
This will create us a simulation detector driver with PV prefix
196208
``BL01T-EA-TST-01:DET:`` that publishes its output on the Asyn port ``DET.DET``.

docs/user/tutorials/dev_container.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,33 @@ simply launch the developer container in a shell and use it via CLI only.
8585
Starting a Developer Container
8686
------------------------------
8787

88+
.. Warning::
89+
90+
DLS Users and Redhat Users:
91+
92+
There is a
93+
`bug in VSCode devcontainers extension <https://github.com/microsoft/vscode-remote-release/issues/8557>`_
94+
at the time of writing
95+
that makes it incompatible with podman and an SELinux enabled /tmp directory.
96+
This will affect most Redhat users and you will see an error regarding
97+
permissions on the /tmp folder when VSCode is building your devcontainer.
98+
99+
Here is a temporary workaround, paste this into a terminal:
100+
101+
.. code-block:: bash
102+
103+
echo '
104+
#!/bin/bash
105+
if [[ "${@}" == "buildx build"* ]] ; then
106+
shift 2
107+
/usr/bin/podman buildx build --security-opt=label=disable "${@}"
108+
else
109+
/usr/bin/podman "${@}"
110+
fi
111+
' > $HOME/.local/bin/podman
112+
chmod +x $HOME/.local/bin/podman
113+
114+
88115
For this section we will work with the ADSimDetector Generic IOC that we
89116
used in previous tutorials. Let's go and fetch a version of the Generic IOC
90117
source and build it locally.

docs/user/tutorials/ioc_changes1.rst

Lines changed: 67 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
11
Changing the IOC Instance
22
=========================
33

4-
5-
.. Warning::
6-
7-
This tutorial is out of date and will be updated in November 2023.
8-
9-
10-
This tutorial will make a very simple change to the example IOC ``bl01t-ea-ioc-01``.
11-
This is a type 1. change from the above list, types 2, 3 will be covered in the
4+
This tutorial will make a very simple change to the example IOC ``bl01t-ea-ioc-02``.
5+
This is a type 1 change from `ioc_change_types`, types 2, 3 will be covered in the
126
following 2 tutorials.
137

8+
Strictly speaking, Type 1 changes do not require a devcontainer. You created
9+
and deployed the IOC instance a previous tutorial without one. It is up to
10+
you how you choose to make these types of changes. Types 2,3 do require a
11+
devcontainer because they involve compiling Generic IOC / support module code.
12+
1413
We are going to add a hand crafted EPICS DB file to the IOC instance. This will
1514
be a simple record that we will be able to query to verify that the change
1615
is working.
1716

1817
Make the following changes in your test IOC config folder
19-
(``bl01t/iocs/bl01t-ea-ioc-01/config``):
18+
(``bl01t/iocs/bl01t-ea-ioc-02/config``):
2019

2120
1. Add a file called ``extra.db`` with the following contents.
22-
IMPORTANT replace [$USER] with your username:
2321

2422
.. code-block:: text
2523
26-
record(ai, "[$USER]-EA-IOC-01:TEST") {
24+
record(ai, "BL01T-EA-IOC-01:TEST") {
2725
field(DESC, "Test record")
2826
field(DTYP, "Soft Channel")
2927
field(SCAN, "Passive")
3028
field(VAL, "1")
3129
}
3230
33-
2. Add the following line to the ``st.cmd`` file after the last ``dbLoadRecords``
34-
line:
31+
2. Add the following lines to the end ``ioc.yaml`` (verify that the indentation
32+
matches the above entry so that ``- type:`` statements line up):
3533

36-
.. code-block:: text
34+
.. code-block:: yaml
3735
38-
dbLoadRecords(config/extra.db)
36+
- type: epics.StartupCommand
37+
command: dbLoadRecords(config/extra.db)
3938
4039
Locally Testing Your changes
4140
----------------------------
@@ -46,13 +45,14 @@ folder:
4645

4746
.. code-block:: bash
4847
49-
ec dev ioc-launch iocs/bl01t-ea-ioc-01
48+
# stop the first IOC shell by hitting Ctrl-D or typing exit
49+
cd /epics/ioc
50+
./start.sh
5051
51-
This will launch Generic IOC container specified in the ``bl01t-ea-ioc-01``
52-
helm chart and mount into it the local config specified in
53-
``/iocs/bl01t-ea-ioc-01/config``.
52+
If all is well you should see your iocShell prompt and the output should
53+
show ``dbLoadRecords(config/extra.db)``.
5454

55-
If all is well you should see your iocShell prompt and you can test your change
55+
Test your change
5656
from another terminal (VSCode menus -> Terminal -> New Terminal) like so:
5757

5858
.. code-block:: bash
@@ -61,91 +61,57 @@ from another terminal (VSCode menus -> Terminal -> New Terminal) like so:
6161
6262
If you see the value 1 then your change is working.
6363

64-
.. note::
65-
66-
If you also wanted to make local changes
67-
to the Generic IOC itself you could clone the Generic IOC source repo,
68-
locally build the container image and then use ``ec dev ioc-launch`` as
69-
follows:
70-
71-
.. code-block:: bash
72-
73-
# advanced example - not part of this tutorial
74-
cd <root of your workspace>
75-
git clone [email protected]:epics-containers/ioc-adsimdetector.git
76-
cd ioc-adsimdetector
77-
# this makes a local image with tag :local
78-
ec dev build
79-
cd ../bl01t
80-
ec dev ioc-launch iocs/bl01t-ea-ioc-01 ../ioc-adsimdetector
81-
82-
83-
Note you can see your running IOC in podman using this command:
84-
85-
.. code-block:: bash
86-
87-
podman ps
88-
89-
You should see a container named bl01t-ea-ioc-01 and also a another one with a
90-
random name and an image called ``localhost/vsc-work...``. The latter is the
91-
container that is running your developer environment.
92-
93-
If you would like to take a look inside the container you can run a bash shell
94-
in the container like this:
95-
96-
.. code-block:: bash
97-
98-
podman exec -it bl01t-ea-ioc-01 bash
99-
100-
When you type exit on the iocShell the container will stop and and be removed.
101-
102-
.. _local_deploy_ioc:
103-
104-
Deploying a Beta IOC Instance to The Cluster
105-
============================================
64+
.. Note::
10665

107-
In ``05_deploy_example`` we deployed a tagged version of the IOC instance to
108-
the cluster. This the correct way to deploy a production IOC instance as it
109-
means there is a record of version of the IOC instance in the Helm Chart
110-
OCI registry and you can always roll back to that version if needed.
66+
You are likely to see
67+
*"Identical process variable names on multiple servers"* warnings. This is
68+
because caget can see the PV on the host network and the container network,
69+
but as these are the same IOC this is not a problem.
11170

112-
However, it is also possible to directly deploy a version of the IOC instance
113-
from your local machine to the cluster.
114-
This is useful for testing changes to the IOC instance
115-
before publishing a new version. In this case
116-
your IOC will be given a beta tag in the cluster, indicating that it has
117-
not yet been released.
71+
You can change this and make your devcontainer network isolated by removing
72+
the line ``"--net=host",`` from ``.devcontainer/devcontainer.json``, but
73+
it is convenient to leave it if you want to run OPI tools locally on the
74+
host. You may want to isolate your development network if multiple
75+
developers are working on the same subnet. In this case some other solution
76+
is required for running OPI tools on the host (TODO add link to solution).
11877

119-
To deploy your changes direct to the cluster use the following command:
78+
Because of the symlink between ``/epics/ioc/config`` and
79+
``/repos/bl01t/iocs/bl01t-ea-ioc-02/config`` the same files you are testing
80+
by launching the ioc inside of the devcontainer are also ready to be
81+
committed and pushed to the bl01t repo. i.e.:
12082

12183
.. code-block:: bash
12284
123-
ec ioc deploy-local iocs/bl01t-ea-ioc-01
124-
125-
You will get a warning that this is a temporary deployment and you will see that
126-
the version number will look something like ``2023.3.29-b14.29`` this
127-
indicates that this is a beta deployment made at 14:29 on 29th March 2023.
128-
129-
Now when you ask for the IOCs running in your domain you should see your IOC
130-
with beta version listed:
131-
132-
.. code-block:: bash
133-
134-
$ ec ps -w
135-
POD VERSION STATE RESTARTS STARTED IP GENERIC_IOC_IMAGE
136-
bl01t-ea-ioc-01-7d7c5bc759-5bjsr 2023.3.29-b14.29 Running 0 2023-03-29T14:29:18Z 192.168.0.32 ghcr.io/epics-containers/ioc-adsimdetector-linux-runtime:23.3.4
137-
138-
You can check it is working as before (replace the IP with yours
139-
from the above command):
140-
141-
.. code-block:: bash
142-
143-
export EPICS_CA_ADDR_LIST=192.168.0.32
144-
caget $USER-EA-IOC-01:TEST
145-
146-
Once you are happy with your changes you can push and tag your beamline repo.
147-
This will publish a new version of the IOC instance helm chart to the OCI helm
148-
registry. You can then deploy the versioned IOC instance to the cluster.
149-
150-
85+
# Do this from the host terminal (not the devcontainer terminal)
86+
cd bl01t
87+
git add .
88+
git commit -m "Added extra.db"
89+
git push
90+
# tag a new version of the beamline repo
91+
git tag 2023.11.2
92+
git push origin 2023.11.2
93+
ec deploy bl01t-ea-ioc-02 2023.11.2
94+
95+
The above steps were performed on a host terminal because we are using ``ec``
96+
but all of the previous steps could have been done *inside* the devcontainer
97+
starting with ``cd /repos/bl01t``.
98+
99+
Raw Startup Assets
100+
------------------
101+
102+
If you plan not to use `ibek` runtime asset creation you could use the raw
103+
startup assets from the previous tutorial. If you do this then the process
104+
above is identical except that you will add the ``dbLoadRecords`` command to
105+
the end of ``st.cmd``.
106+
107+
More about ibek Runtime Asset Creation
108+
--------------------------------------
109+
110+
The set of ``entities`` that you may create in your ioc.yaml is defined by the
111+
``ibek`` IOC schema that we reference at the top of ``ioc.yaml``.
112+
The schema is in turn defined by the set of support modules that were compiled
113+
into the Generic IOC (ioc-adsimdetector). Each support module has an
114+
``ibek`` *support YAML* file that contributes to the schema.
115+
116+
The *Support yaml* files are in the folder ``/epics/ibek``
151117

docs/user/tutorials/rtems_ioc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ To deploy an IOC instance to the cluster you can use one of two approaches:
257257

258258
- use ``ec ioc deploy-local`` to directly deploy the local copy of the IOC
259259
instance helm chart to kubernetes as a beta version. This was covered for
260-
linux IOCs in `local_deploy_ioc`.
260+
linux IOCs in --local_deploy_ioc--.
261261

262262
Both types of deployment of IOC instances above work exactly the same for
263263
linux and RTEMS IOCs. We will do the latter as it is quicker for

0 commit comments

Comments
 (0)