1
1
Changing the IOC Instance
2
2
=========================
3
3
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
12
6
following 2 tutorials.
13
7
8
+ Strictly speaking, Type 1 changes do not require a devcontainer. You created
9
+ and deployed the IOC instance in 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
+
14
13
We are going to add a hand crafted EPICS DB file to the IOC instance. This will
15
14
be a simple record that we will be able to query to verify that the change
16
15
is working.
17
16
17
+ .. note ::
18
+
19
+ Before doing this tutorial make sure you have not left the IOC
20
+ bl01t-ea-ioc-02 running from a previous tutorial. Execute this command
21
+ outside of the devcontainer to stop it:
22
+
23
+ .. code-block :: bash
24
+
25
+ ec ioc stop bl01t-ea-ioc-02
26
+
18
27
Make the following changes in your test IOC config folder
19
- (``bl01t/iocs/bl01t-ea-ioc-01 /config ``):
28
+ (``bl01t/iocs/bl01t-ea-ioc-02 /config ``):
20
29
21
30
1. Add a file called ``extra.db `` with the following contents.
22
- IMPORTANT replace [$USER] with your username:
23
31
24
32
.. code-block :: text
25
33
26
- record(ai, "[$USER] -EA-IOC-01:TEST") {
34
+ record(ai, "BL02T -EA-IOC-01:TEST") {
27
35
field(DESC, "Test record")
28
36
field(DTYP, "Soft Channel")
29
37
field(SCAN, "Passive")
30
38
field(VAL, "1")
31
39
}
32
40
33
- 2. Add the following line to the `` st.cmd `` file after the last `` dbLoadRecords ``
34
- line:
41
+ 2. Add the following lines to the end `` ioc.yaml `` (verify that the indentation
42
+ matches the above entry so that `` - type: `` statements line up) :
35
43
36
- .. code-block :: text
44
+ .. code-block :: yaml
37
45
38
- dbLoadRecords(config/extra.db)
46
+ - type : epics.StartupCommand
47
+ command : dbLoadRecords(config/extra.db)
39
48
40
49
Locally Testing Your changes
41
50
----------------------------
@@ -46,106 +55,127 @@ folder:
46
55
47
56
.. code-block :: bash
48
57
49
- ec dev ioc-launch iocs/bl01t-ea-ioc-01
58
+ # stop any existing IOC shell by hitting Ctrl-D or typing exit
59
+ cd /epics/ioc
60
+ ./start.sh
50
61
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 ``.
62
+ If all is well you should see your iocShell prompt and the output should
63
+ show ``dbLoadRecords(config/extra.db) ``.
54
64
55
- If all is well you should see your iocShell prompt and you can test your change
65
+ Test your change
56
66
from another terminal (VSCode menus -> Terminal -> New Terminal) like so:
57
67
58
68
.. code-block :: bash
59
69
60
- caget $USER -EA-IOC-01 :TEST
70
+ caget BL02T -EA-IOC-02 :TEST
61
71
62
72
If you see the value 1 then your change is working.
63
73
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:
74
+ .. Note ::
70
75
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
76
+ You are likely to see
77
+ *"Identical process variable names on multiple servers" * warnings. This is
78
+ because caget can see the PV on the host network and the container network,
79
+ but as these are the same IOC this is not a problem.
81
80
81
+ You can change this and make your devcontainer network isolated by removing
82
+ the line ``"--net=host", `` from ``.devcontainer/devcontainer.json ``, but
83
+ it is convenient to leave it if you want to run OPI tools locally on the
84
+ host. You may want to isolate your development network if multiple
85
+ developers are working on the same subnet. In this case some other solution
86
+ is required for running OPI tools on the host (TODO add link to solution).
82
87
83
- Note you can see your running IOC in podman using this command:
88
+ Because of the symlink between ``/epics/ioc/config `` and
89
+ ``/repos/bl01t/iocs/bl01t-ea-ioc-02/config `` the same files you are testing
90
+ by launching the ioc inside of the devcontainer are also ready to be
91
+ committed and pushed to the bl01t repo. i.e.:
84
92
85
93
.. code-block :: bash
86
94
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
- ============================================
106
-
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.
111
-
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.
118
-
119
- To deploy your changes direct to the cluster use the following command:
120
-
121
- .. code-block :: bash
122
-
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
-
151
-
95
+ # Do this from a host terminal (not a devcontainer terminal)
96
+ cd bl01t
97
+ git add .
98
+ git commit -m " Added extra.db"
99
+ git push
100
+ # tag a new version of the beamline repo
101
+ git tag 2023.11.2
102
+ git push origin 2023.11.2
103
+ # deploy the new version of the IOC to the local docker / podman instance
104
+ ec deploy bl01t-ea-ioc-02 2023.11.2
105
+
106
+ The above steps were performed on a host terminal because we are using ``ec ``.
107
+ However all of the steps except for the ``ec `` command could have been done
108
+ *inside * the devcontainer starting with ``cd /repos/bl01t ``.
109
+
110
+ We choose not to have ``ec `` installed inside of the devcontainer because
111
+ that would involve containers in containers which adds too much complexity.
112
+
113
+ Raw Startup Assets
114
+ ------------------
115
+
116
+ If you plan not to use ``ibek `` runtime asset creation you could use the raw
117
+ startup assets from the previous tutorial. If you do this then the process
118
+ above is identical except that you will add the ``dbLoadRecords `` command to
119
+ the end of ``st.cmd ``.
120
+
121
+ More about ibek Runtime Asset Creation
122
+ --------------------------------------
123
+
124
+ The set of ``entities `` that you may create in your ioc.yaml is defined by the
125
+ ``ibek `` IOC schema that we reference at the top of ``ioc.yaml ``.
126
+ The schema is in turn defined by the set of support modules that were compiled
127
+ into the Generic IOC (ioc-adsimdetector). Each support module has an
128
+ ``ibek `` *support YAML * file that contributes to the schema.
129
+
130
+ The *Support yaml * files are in the folder ``/epics/ibek `` inside of the
131
+ container. They were placed their during the compilation of the support
132
+ modules at Generic IOC build time.
133
+
134
+ It can be instructive to look at these files to see what entities are available
135
+ to *IOC instances *. For example the global support yaml file
136
+ ``/epics/ibek/ibek.yaml `` contains the following:
137
+
138
+ .. code :: yaml
139
+
140
+ - name : StartupCommand
141
+ description : Adds an arbitrary command in the startup script before iocInit
142
+ args :
143
+ - type : str
144
+ name : command
145
+ description : command string
146
+ default : " "
147
+ pre_init :
148
+ - type : text
149
+ value : " {{ command }}"
150
+
151
+ - name : PostStartupCommand
152
+ description : Adds an arbitrary command in the startup script after iocInit
153
+ args :
154
+ - type : str
155
+ name : command
156
+ description : command string
157
+ default : " "
158
+ post_init :
159
+ - type : text
160
+ value : " {{ command }}"
161
+
162
+ These two definitions allow you to add arbitrary commands to the startup script
163
+ before and after iocInit. This is how we added the ``dbLoadRecords `` command.
164
+
165
+ If you want to specify multiple lines in a command you can use the following
166
+ syntax for multi-line stings:
167
+
168
+ .. code-block :: yaml
169
+
170
+ - type : epics.StartupCommand
171
+ command : |
172
+ # loading extra records
173
+ dbLoadRecords(config/extra.db)
174
+ # loading even more records
175
+ dbLoadRecords(config/extra2.db)
176
+
177
+ This would place the 4 lines verbatim into the startup script (except that
178
+ they would not be indented - the nesting whitespace is stripped).
179
+
180
+ In later tutorials we will see where the *Support yaml * files come from and
181
+ how to add your own.
0 commit comments