Skip to content

Commit 6f3ad3c

Browse files
committed
completed create_ioc
1 parent e78c5b8 commit 6f3ad3c

File tree

3 files changed

+97
-9
lines changed

3 files changed

+97
-9
lines changed

docs/explanations/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ forks of these repositories.
3939

4040
#### Generic IOCs and instances
4141

42-
An important principal of the approach presented here is that an IOC container image represents a 'Generic' IOC. The Generic IOC image is used for all IOC instances that connect to a given class of device. For example the Generic IOC image here: [ghcr.io/epics-containers/ioc-adaravis-linux-runtime:2024.1.2](https://github.com/epics-containers/ioc-adaravis/pkgs/container/ioc-adaravis-linux-runtime) uses the AreaDetector driver ADAravis to connect to GigE cameras.
42+
An important principal of the approach presented here is that an IOC container image represents a 'Generic' IOC. The Generic IOC image is used for all IOC instances that connect to a given class of device. For example the Generic IOC image here: [ghcr.io/epics-containers/ioc-adaravis-linux-runtime:2024.2.2 ](https://github.com/epics-containers/ioc-adaravis/pkgs/container/ioc-adaravis-linux-runtime) uses the AreaDetector driver ADAravis to connect to GigE cameras.
4343

4444
An IOC instance runs in a container runtime by loading two things:
4545

docs/how-to/debug.md

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,88 @@
11
# Debug an IOC instance locally
22

3-
Todo
3+
:::{warning}
4+
This is an early draft
5+
:::
46

5-
# Debug an IOC instance in Kubernetes
7+
This guide will show you how to debug an IOC instance locally. It will use the example IOC made in the [Create an IOC instance](./create-ioc-instance.md) guide. That IOC is called `bl01t-ea-test-02` in the guide but you may have chosen a different name.
68

7-
Todo
9+
## Setting up
10+
11+
Get the IOC Instance definition repository and deliberately break the IOC instance so that you can debug it.
12+
13+
```bash
14+
git clone [email protected]:YOUR_GITHUB_USERNAME/bl01t.git
15+
cd bl01t
16+
source environment.sh
17+
code .
18+
# now edit services/bl01t-ea-test-02/config/ioc.yaml
19+
```
20+
21+
## Breaking the IOC instance
22+
23+
Add the phrase 'deliberate_error' to the top of the `ioc.yaml` file. Then try to launch the IOC instance, but use the `-v` flag to see the underlying commands:
24+
25+
```bash
26+
ec -v deploy-local services/bl01t-ea-test-02
27+
```
28+
29+
You should see something like this (for docker users - podman users will see something similar):
30+
31+
<pre>$ ec -v deploy-local services/bl01t-ea-test-02
32+
<font color="#5F8787">docker --version</font>
33+
<font color="#5F8787">docker buildx version</font>
34+
Deploy TEMPORARY version 2024.2.17-b8.30 from /home/giles/tutorial/bl01t/services/bl01t-ea-test-02 to the local docker instance
35+
Are you sure ? [y/N]: y
36+
<font color="#5F8787">docker stop -t0 bl01t-ea-test-02</font>
37+
<font color="#5F8787">docker rm -f bl01t-ea-test-02</font>
38+
<font color="#5F8787">docker volume rm -f bl01t-ea-test-02_config</font>
39+
<font color="#5F8787">docker volume create bl01t-ea-test-02_config</font>
40+
<font color="#5F8787">docker rm -f busybox</font>
41+
<font color="#5F8787">docker container create --name busybox -v bl01t-ea-test-02_config:/copyto busybox</font>
42+
<font color="#5F8787">docker cp /home/giles/tutorial/bl01t/services/bl01t-ea-test-02/config/ioc.yaml busybox:copyto</font>
43+
<font color="#5F8787">docker rm -f busybox</font>
44+
<font color="#5F8787">docker run -dit --net host --restart unless-stopped -l is_IOC=true -l version=2024.2.17-b8.30 -v bl01t-ea-test-02_config:/epics/ioc/config/ -e IOC_NAME=bl01t-ea-test-02 --name bl01t-ea-test-02 ghcr.io/epics-containers/ioc-adsimdetector-linux-runtime:2024.2.2</font>
45+
76c2834dac805780b3329af91c332abb90fb2692a510c11b888b82e48f60b44f
46+
<font color="#5F8787">docker ps -f name=bl01t-ea-test-02 --format &apos;{{.Names}}&apos;</font>
47+
</pre>
48+
49+
Now if you try these commands you should see that the IOC instance keeps restarting and that the logs show an error:
50+
51+
```bash
52+
ec ps
53+
ec logs bl01t-ea-test-02
54+
```
55+
56+
## Debugging the IOC instance
57+
58+
Now you can tell `ec` to stop the IOC instance and then run it in a way that you can debug it, by copying the command that `ec` used to run the IOC instance and adding the `--entrypoint bash` and removing `-d` flag and `--restart unless-stopped`. Also change the name to have a `-debug` suffix, like so:
59+
60+
```bash
61+
ec stop bl01t-ea-test-02
62+
docker run --entrypoint bash -it --net host -l is_IOC=true -l version=2024.2.17-b8.30 -v bl01t-ea-test-02_config:/epics/ioc/config/ -e IOC_NAME=bl01t-ea-test-02 --name bl01t-ea-test-02-debug ghcr.io/epics-containers/ioc-adsimdetector-linux-runtime:2024.2.2
63+
```
64+
65+
You should now be in a shell inside the container. You can look at the files and run the IOC instance manually to see what the error is. You can re-run the IOC instance multiple times and you can even install your favourite editor or debugging tools.
66+
67+
e.g.
68+
69+
```bash
70+
apt update
71+
apt install vim
72+
ls /epics/ioc/config/
73+
cat /epics/ioc/config/ioc.yaml
74+
cd /epics/ioc
75+
./start.sh
76+
# ctrl-d to exit
77+
vim /epics/ioc/config/ioc.yaml
78+
# fix the error
79+
./start.sh
80+
```
81+
82+
When you are done you can exit the container with `ctrl-d` and then remove it (or you can keep it around for later and restart it with `docker start -i bl01t-ea-test-02-debug`):
83+
84+
```bash
85+
docker rm -f bl01t-ea-test-02-debug
86+
```
87+
88+
You can now apply the fix you made to the local filesystem and retry the deployment.

docs/tutorials/create_ioc.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ code services/bl01t-ea-test-02/values.yaml
5252
You will now have vscode and open and editing the values.yaml file. Add the following:
5353

5454
```yaml
55-
image: ghcr.io/epics-containers/ioc-adsimdetector-linux-runtime:2024.1.1
55+
image: ghcr.io/epics-containers/ioc-adsimdetector-linux-runtime:2024.2.2
5656
```
5757
5858
This tells the IOC Instance to run in the `ioc-adsimdetector-linux-runtime`
@@ -283,15 +283,15 @@ the c2dv viewer showing an image from the example IOC
283283

284284
Above we looked at some ibek *Support yaml* and created an *IOC yaml* file.
285285
The details of where *Support yaml* files come from and how to create your
286-
own are covered in later tutorials on creating Generic services.
286+
own are covered a later tutorial {any}`generic_ioc`.
287287

288288
However, without looking into the set of *Support yaml* files that are
289289
inside a given Generic IOC we can still make a meaningful *IOC yaml* file.
290290
That is because every Generic IOC publishes an *IOC schema* that describes
291291
the set of entities that an instance of that IOC may instantiate.
292292

293293
The Generic IOC we used was released at this location:
294-
<https://github.com/epics-containers/ioc-adsimdetector/releases/tag/2024.1.1>.
294+
<https://github.com/epics-containers/ioc-adsimdetector/releases/tag/2024.2.2>.
295295
This page includes the assets that are published as part of the release and
296296
one of those is `ibek.ioc.schema.json`. This is the *IOC schema* for the
297297
`ioc-adsimdetector` Generic IOC. This is what we referred to at the top of
@@ -355,14 +355,21 @@ podman cp bl01t-ea-test-02:/epics/runtime/st.cmd services/bl01t-ea-test-02/confi
355355
podman cp bl01t-ea-test-02:/epics/runtime/ioc.subst services/bl01t-ea-test-02/config/ioc.subst
356356
# no longer need an ibek ioc yaml file
357357
rm services/bl01t-ea-test-02/config/ioc.yaml
358-
# re-deploy from local filesystem
359-
ec deploy-local services/bl01t-ea-test-02
360358
```
361359

360+
You will need to make a minor change to the `ioc.subst` file. Edit this and remove references to the two template files with `.pvi` in their name. These are PVI generated templates for use with BlueSky Asyc and are not available in manually build IOC Instances.
361+
362362
Your IOC Instance will now be using the raw startup script and database. But
363363
should behave exactly the same as before. You are free to experiment with
364364
changes in the startup script and substitution file and re-deploy the IOC.
365365

366+
To start your new version of the the Instance and replace the previous one use the `deploy-local` command again:
367+
368+
```bash
369+
# re-deploy from local filesystem
370+
ec deploy-local services/bl01t-ea-test-02
371+
```
372+
366373
:::{note}
367374
We used some raw podman / docker commands in the above script. If you
368375
want to know what commands `ec` is running under the hood then you can

0 commit comments

Comments
 (0)