Skip to content

Commit 30a5784

Browse files
committed
add troubleshooting and ioc-source
1 parent b85982b commit 30a5784

File tree

4 files changed

+126
-59
lines changed

4 files changed

+126
-59
lines changed

docs/user/explanations/ioc-source.rst

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,69 @@
33
Dev Container vs Runtime Container
44
==================================
55

6-
TODO: explain how and why ioc-xxxx is mounted in dev container and what happens
7-
to the ioc folder.
6+
Introduction
7+
------------
8+
9+
The dev container is where all development of IOCs and support modules will
10+
take place. The runtime container is where the IOC will run when deployed
11+
to a target system.
12+
13+
The dev container mounts several host folders into the container to achieve
14+
the following goals:
15+
16+
- make the developer container look as similar as possible to the runtime
17+
container
18+
- allow the developer to make changes and recompile things without having
19+
to rebuild the container
20+
- make sure that all useful changes occur in the host filesystem so that
21+
they are not lost when the container is rebuilt or deleted
22+
23+
The details of which folders are mounted where in the container are
24+
shown here: `container-layout`_.
25+
26+
The ioc-XXX project folder is found in the container at ``/workspaces/ioc-XXX``,
27+
along with all of it's peers (because the parent folder is mounted
28+
at ``/workspaces``).
29+
30+
31+
The ioc Folder
32+
--------------
33+
34+
The ioc folder contains the Generic IOC source code. It is typically the same
35+
for all Generic IOCs but is included in the ioc-XXX repo in /ioc so that it can be
36+
modified if necessary.
37+
38+
At container build time this folder is copied into the container at
39+
``/epics/generic-source/ioc`` and it is compiled so that the binaries are
40+
available at runtime.
41+
42+
In the dev container the ``/epics/generic-source`` folder has the project
43+
folder ioc-XXX mounted over the top of it. This means:
44+
45+
- the project folder ioc-XXX is mounted in two locations in the container
46+
- ``/workspaces/ioc-XXX``
47+
- ``/epics/generic-source``
48+
- the ioc source folder ``/epics/generic-source/ioc`` is also mounted over
49+
and now contains the source only. The compiled binaries are no longer
50+
visible inside the dev container.
51+
52+
It is for this reason that a newly created dev container needs to have the IOC
53+
binaries re-compiled. But this is a good thing, because now any changes you
54+
make to the IOC source code can be compiled and tested, but also those
55+
changes are now visible on the host filesystem inside the project folder
56+
``ioc-XXX/ioc``. This avoids loss of work.
57+
58+
Finally the ``ioc`` folder is always soft linked from ``/epics/ioc`` so that
59+
the source and binaries are always in a known location.
60+
61+
Summing Up
62+
----------
63+
64+
The above description makes things sound rather complicated. However,
65+
you can for the most part ignore the details and just remember:
66+
67+
- use ``/epics/ioc`` to compile and run the IOC.
68+
- you are free to make changes to the above folder and recompile
69+
- the changes you make will be visible on the host filesystem in the
70+
original project folder.
871

docs/user/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ side-bar.
7575
:maxdepth: 1
7676

7777
reference/faq
78+
reference/troubleshooting
7879
reference/configuration
7980
reference/environment
8081
reference/cli
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Troubleshooting
2+
===============
3+
4+
Permissions issues with GitHub
5+
-------------------------------
6+
7+
Problem: in the devcontainer you see the following error:
8+
9+
.. code-block:: none
10+
11+
[email protected]: Permission denied (publickey).
12+
fatal: Could not read from remote repository.
13+
14+
Solution: you may need to add your github ssh key to the ssh-agent as
15+
follows:
16+
17+
.. code-block:: none
18+
19+
eval "$(ssh-agent -s)"
20+
ssh-add ~/.ssh/id_rsa
21+
22+
Where ``id_rsa`` is the name of your private key file you use for connecting
23+
to GitHub.

docs/user/tutorials/ioc_changes2.rst

Lines changed: 37 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
Changing a Generic IOC
22
======================
33

4-
.. warning ::
5-
6-
TODO: This tutorial is a work in progress. It is not yet complete.
7-
84
This is a type 2 change from `ioc_change_types`.
95

106
The changes that you can make in an IOC instance are limited to what
@@ -30,49 +26,36 @@ Some of the reasons for doing this are:
3026
manage multiple small services is cleaner than having a handful of
3127
monolithic services.
3228

33-
This tutorial will make some changes to the generic IOC ``ioc-adsample``.
34-
This Generic IOC is a simplified copy of ``ioc-adsimdetector`` tailored for
35-
use in these tutorials.
3629

37-
For this exercise we will initially work locally inside the ``ioc-adsample``
38-
developer container.
30+
This tutorial will make some changes to the generic IOC ``ioc-adsimdetector``
31+
that you already used in earlier tutorials.
3932

40-
At the end we will push the changes and see the CI build a new version of the
41-
generic IOC container image. This allows for the demonstration of:
42-
43-
- Deploying an IOC instance using a new image published by the CI
44-
- Showing how to do a Pull Request back to the original repository.
33+
For this exercise we will work locally inside the ``ioc-adsimdetector``
34+
developer container. To discover how to fork repositories and push changes
35+
back to GitHub
4536

4637
For this exercise we will be using an example IOC Instance to test our changes.
4738
Instead of working with a beamline repository, we will use the example ioc instance
48-
that comes with ``ioc-adsample``. It is a good idea for Generic IOC authors to
39+
inside ``ioc-adsimdetector``. It is a good idea for Generic IOC authors to
4940
include an example IOC Instance in their repository for testing changes in
5041
isolation.
5142

52-
5343
Preparation
5444
-----------
5545

56-
Because we want to push our changes we will first make a fork of the
57-
``ioc-adsample`` repository. We will then clone our fork locally and
58-
make the changes there.
59-
60-
To make a fork go to
61-
`ioc-adsample <https://github.com/epics-containers/ioc-adsample>`_
62-
and click the ``Fork`` button in the top right corner. This will create a fork
63-
of the repository under your own GitHub account.
64-
65-
Now, clone the fork, build the container image locally and open the
66-
developer container:
46+
First, clone the ``ioc-adsimdetector`` repository and make sure the container
47+
build is working:
6748

6849
.. code-block:: console
6950
70-
git clone [email protected]:<YOUR GITHUB ACCOUNT NAME>/ioc-adsample.git
71-
cd ioc-adsample
51+
git clone [email protected]:epics-containers/ioc-adsimdetector.git
52+
cd ioc-adsimdetector
7253
./build
7354
code .
74-
# click the green button in the bottom left corner of vscode and select
75-
# "Reopen in Container"
55+
# Choose "Reopen in Container"
56+
57+
Note that if you do not see the prompt to reopen in container, you can open
58+
the ``Remote`` menu with ``Ctrl+Alt+O`` and select ``Reopen in Container``.
7659

7760
The ``build`` script does two things.
7861

@@ -94,26 +77,39 @@ Verify the Example IOC Instance is working
9477
When a new Generic IOC developer container is opened, there are two things
9578
that need to be done before you can run an IOC instance inside of it.
9679

97-
- Build the IOC source code
80+
- Build the IOC binary
9881
- Select an IOC instance definition to run
9982

100-
The folder ``ioc`` inside of the ``ioc-adsample`` is where the IOC source code
101-
is created and built. When you open the developer container, this folder does
102-
not yet exist. The following command will create it and build the IOC:
83+
The folder ``ioc`` inside of the ``ioc-adsimdetector`` is where the IOC source code
84+
resided. However the devcontainer always makes a symlink to this folder at
85+
``/epics/ioc``. This is so that it is always in the same place and can easily be
86+
found by ibek and the developer. Therefore you can build the binary with the
87+
following command:
10388

10489
.. code-block:: console
10590
106-
ec ioc build
91+
cd /epics/ioc
92+
make
93+
94+
.. note::
95+
96+
Note that we are required to build the IOC.
97+
This is even though the container you are using already had the IOC
98+
source code built by its Dockerfile (``ioc-adsimdetector/Dockerfile``
99+
contains the same command).
100+
101+
For a detailed explanation of why this is the case see
102+
`ioc-source`
107103

108104
The IOC instance definition is a YAML file that tells ``ibek`` what the runtime
109105
assets (ie. EPICS DB and startup script) should look like. Previous tutorials
110106
selected the IOC instance definition from a beamline repository. In this case
111-
we will use the example IOC instance that comes with ``ioc-adsample``. The
107+
we will use the example IOC instance that comes with ``ioc-adsimdetector``. The
112108
following command will select the example IOC instance:
113109

114110
.. code-block:: console
115111
116-
ibek dev instance /epics/ioc-adsample/ioc_examples/bl01t-ea-ioc-02
112+
ibek dev instance /epics/ioc-adsimdetector/ioc_examples/bl01t-ea-ioc-02
117113
118114
In an earlier tutorial when learning about the dev container, we manually
119115
performed this step, see `choose-ioc-instance`. The above command does
@@ -124,23 +120,7 @@ Now run the IOC:
124120

125121
.. code-block:: console
126122
127-
ibek dev run
128-
129-
You should see a iocShell prompt and no error messages above.
130-
131-
.. note::
132-
133-
The ``ec ioc build`` command required to re-create the IOC source code.
134-
This is even though the container you are using already had the IOC
135-
source code built by its Dockerfile (``ioc-adsample/Dockerfile``
136-
contains the same command).
137-
138-
For a detailed explanation of why this is the case see
139-
`ioc-source`
140-
123+
cd /epics/ioc
124+
./start.sh
141125
142-
TODO: complete by adding iocStats and using it in the ioc instance, then
143-
pushing and verifying CI runs and publishes a new image.
144-
TODO: now that cacheing is working, consider using ioc-adsimdetector instead
145-
of ioc-adsample. This is simpler - the change could be the addition of
146-
auto start of the sim detector IOC just like the presentation.
126+
You should see an iocShell prompt and no error messages above.

0 commit comments

Comments
 (0)