ca-gateway icon indicating copy to clipboard operation
ca-gateway copied to clipboard

cagatway does not pass user and host information along with PVs to caPutlog-er

Open mirek23 opened this issue 1 month ago • 7 comments

Does the ca-gateway requires some "switches" to be used in order to pass properly the names of the user and host to caPutlog logger? We use in ALS the ca-gateway version 2.1.3 configured (CAPUTLOG=/path_to_caputlog in configure/RELEASE file) but the ca-gateway does not pass the user and host to the caputlogger as it is expected to pass. It passes the name of the host where the ca-gateway runs and the name of the user who runs the ca-gateway.

ldd bin/RL8-x86_64/gateway
	linux-vdso.so.1 (0x00007ffc9d988000)
	libcas.so.4.13.0 => /usr/local/epics/R7.0.7/extensions/src/pcas-4.13.3/lib/RL8-x86_64/libcas.so.4.13.0 (0x00007fbb2816e000)
	libgdd.so.4.13.0 => /usr/local/epics/R7.0.7/extensions/src/pcas-4.13.3/lib/RL8-x86_64/libgdd.so.4.13.0 (0x00007fbb27f3a000)
	libca.so.4.14.2 => /usr/local/epics/R7.0.7/base/lib/RL8-x86_64/libca.so.4.14.2 (0x00007fbb27cd4000)
	libCom.so.3.22.0 => /usr/local/epics/R7.0.7/base/lib/RL8-x86_64/libCom.so.3.22.0 (0x00007fbb27a5e000)
	libcaPutLog.so => /usr/local/epics/R7.0.7/modules/soft/caPutLog/lib/RL8-x86_64/libcaPutLog.so (0x00007fbb27853000)
	libdbRecStd.so.3.22.0 => /usr/local/epics/R7.0.7/base/lib/RL8-x86_64/libdbRecStd.so.3.22.0 (0x00007fbb2760d000)
	libdbCore.so.3.22.0 => /usr/local/epics/R7.0.7/base/lib/RL8-x86_64/libdbCore.so.3.22.0 (0x00007fbb27376000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fbb26fe1000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fbb26c5f000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fbb26a47000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fbb26670000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fbb26450000)
	librt.so.1 => /lib64/librt.so.1 (0x00007fbb26248000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007fbb26044000)
	libreadline.so.7 => /lib64/libreadline.so.7 (0x00007fbb25df5000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fbb283b2000)
	libtinfo.so.6 => /lib64/libtinfo.so.6 (0x00007fbb25bc8000)

mirek23 avatar Nov 20 '25 23:11 mirek23

... pass properly the names of the user and host to caPutlog logger?

Do you mean caPutLog as part of the ca-gateway, or caPutLog as part of an IOC which is reached through a ca-gateway?

mdavidsaver avatar Nov 21 '25 00:11 mdavidsaver

I mean: caPutLog as part of the ca-gateway is not passing thought the name of the host and name of the user of the client application which changes the given PV.

mirek23 avatar Nov 24 '25 01:11 mirek23

I will try to reproduce that. (Actually started yesterday, but got trapped in a caPutLog rabbit hole.)

ralphlange avatar Nov 25 '25 10:11 ralphlange

Thanks Ralph. I do appreciate it. Our ca-gateway was built and runs on Rocky Linux 8.10

mirek23 avatar Nov 25 '25 17:11 mirek23

Can you show how your log lines look like? Also, which version of caPutLog are you using?

Using current versions of Base 7.0, Gateway and caPutLog, I am getting buggy caPutLog messages, but the user and host info is correct.

Test Setup and First Observations

On my "main" host, (Ubuntu 24.04 on WSL2, named FR-IWL-LANGER):

A single softIoc loading a minimal database:

record (ao, "ao") {}

socat TCP4-LISTEN:12345 STDOUT to show the caPutLog output.

CA Gateway with caPutLog, serving on port 24000:

langer@FR-IWL-LANGER:~/work/EPICS/cagw-test$ ~/work/EPICS/ca-gateway/bin/linux-x86_64/gateway -debug 2 -access GATEWAY.access -pvlist GATEWAY.pvlist -sport 24000 -no_cache -caputlog localhost:12345
Nov 26 19:26:29 PV Gateway Version 2.2.0-DEV [Nov 26 2025 19:14:47]
EPICS 7.0.9.1-DEV PID=10155
CA Protocol version 4.13
EPICS_CA_ADDR_LIST=Not specified
EPICS_CA_AUTO_ADDR_LIST=Not specified
EPICS_CA_SERVER_PORT=Not specified
EPICS_CA_MAX_ARRAY_BYTES=Not specified
EPICS_CAS_INTF_ADDR_LIST=Not specified
EPICS_CAS_SERVER_PORT=24000
EPICS_CAS_IGNORE_ADDR_LIST=Not specified
EPICS_CAS_AUTO_BEACON_ADDR_LIST=Not specified
EPICS_CAS_BEACON_ADDR_LIST=Not specified
Running as user langer on host FR-IWL-LANGER
caPutLogInit config: All
sevr=info caPutLog: successfully initialized
log client: connected to log server at '127.0.0.1:12345'
Statistics PV prefix is FR-IWL-LANGER

On a second host, in a VBox named debian-12 as user ralph, I'm setting EPICS_CA_ADDR_LIST to the IP of the WSL2 instance and port 24000.

Starting with a fresh IOC and Gateway, when I do a series of puts as

ralph@debian-12:~$ ~/work/EPICS/7.0/base/bin/linux-x86_64/caput -c ao 11.11
Old : ao                             0
New : ao                             11.11
ralph@debian-12:~$ ~/work/EPICS/7.0/base/bin/linux-x86_64/caput -c ao 22.22
Old : ao                             11.11
New : ao                             22.22
ralph@debian-12:~$ ~/work/EPICS/7.0/base/bin/linux-x86_64/caput -c ao 33.33
Old : ao                             22.22
New : ao                             33.33
ralph@debian-12:~$ ~/work/EPICS/7.0/base/bin/linux-x86_64/caput -c ao 44.44
Old : ao                             33.33
New : ao                             44.44

the caPutLog output does not do timestamps and always reports the new value as "0".

langer@FR-IWL-LANGER:~$ socat TCP4-LISTEN:12345 STDOUT
2025/11/26 19:26:29 socat[10148] W address is opened in read-write mode but only supports write-only
<undefined> debian-12 ralph ao new=0 old=0
<undefined> debian-12 ralph ao new=0 old=11.11
<undefined> debian-12 ralph ao new=0 old=22.22
<undefined> debian-12 ralph ao new=0 old=33.33

User and host, however, are reported correctly.

ralphlange avatar Nov 26 '25 18:11 ralphlange

@anjohnson, @simon-ess - any ideas? Were there other API changes in caPutLog in the last 10 years that the Gateway might have missed? 😊

ralphlange avatar Nov 26 '25 18:11 ralphlange

Ignoring the changes that added all the JSON logging code, since R3.7 we've added the timeout parameter to caPutLogInit() and caPutLogReconf(), the routines to configure time output format and burst period, and caPutLogInitialized().

I'm not so sure about listener interface to the IOC/Gateway itself, the code that feeds updates to the caPutLog task looks reasonable though, and @ralphlange demonstrates above that it works.

@mirek23 you aren't running more than one gateway on this host are you? I could imagine that your users are connecting through one gateway that lets them into the accelerator network say, and the client-side of that connects to PVs on a second gateway which does the logging and talks to the IOCs running in another internal network? The logging gateway would then see the username and host that is running the first gateway, since the CA gateway code can't pass through a client's identification from its server-side to the client-side. I can't think of any other obvious explanation.

anjohnson avatar Nov 26 '25 20:11 anjohnson

I found and fixed the issue with values and timestamps not being shown for the caPutLog of the Gateway (epics-modules/caPutLog/issues/44).

Now my logserver (socat) shows the expected output:

langer@FR-IWL-LANGER:~/work/EPICS/ca-gateway$ socat TCP4-LISTEN:12345 STDOUT
2025/11/28 13:05:44 socat[1193] W address is opened in read-write mode but only supports write-only
28-Nov-25 13:05:58 debian-12 ralph ao new=11.11 old=0
28-Nov-25 13:06:13 debian-12 ralph ao new=22.22 old=11.11
28-Nov-25 13:06:38 debian-12 ralph ao new=33.33 old=22.22

As for the original issue, I agree with Andrew that a connection through two Gateways in a row running on the same host as the same user is the most probable explanation.

ralphlange avatar Nov 28 '25 12:11 ralphlange