Unable to load configurations using MAAPI_LOAD_CONFIG_FILE API

I’m loading configurations using MAAPI_LOAD_CONFIG_FILE maapi API.
But getting error as

2021-08-24 13:50:29:631434 TRACE MAAPI_LOAD_CONFIG_FILE 2021-08-24 13:50:29:633553 DEBUG system call failed - couldn't open file /opt/ani/etc/load_config.xml: no such file or directory
2021-08-24 13:50:29:633566  --> CONFD_ERR

File is present in the required path

[root@cucpapp-bharat-cp1-nrcpconfdproxy-01 /]# ls -ltrh /opt/ani/etc/load_config.xml 
-rw-r--r-- 1 root root 1.8K Aug 24 13:50 /opt/ani/etc/load_config.xml
[root@cucpapp-bharat-cp1-nrcpconfdproxy-01 /]#

Code snippet is:

flags = MAAPI_CONFIG_XML | MAAPI_CONFIG_MERGE;
#define CMA_CONFIG_FILE_NAME                    "/opt/ani/etc/load_config.xml"
iRetVal = maapi_load_config(maapi_fd, txn_handler, flags, CMA_CONFIG_FILE_NAME);

File content is :

<config xmlns="http://tail-f.com/ns/config/1.0">
<ManagedElement xmlns="urn:3gpp:sa5:_3gpp-common-managed-element">
 	<id>1</id>
 	<attributes>
 		<priorityLabel>1</priorityLabel>
 	</attributes>
</ManagedElement>
</config>

Please let me know, what could be the issue here?

what system user is running the app that attempts to call MAAPI_LOAD_CONFIG_FILE?
does it have access to the file, that is owned/accessible by root only?

application is running as root user. Also file has read permission for all the users
[root@cucpapp-bharat-cp1-nrcpconfdproxy-01 /]# ls -ltrh /opt/ani/etc/load_config.xml
-rw-r–r-- 1 root root 1.8K Aug 24 22:01 /opt/ani/etc/load_config.xml
[root@cucpapp-bharat-cp1-nrcpconfdproxy-01 /]#

Also I have tried with confd_cmd image, getting the same error.
[root@robin11-m1 Bharat]# ./confd_load -lm load_config.xml
confd_load: 618: maapi_load_config(sock, tid, flags, abspath(argv[0])) failed: system call failed (24): couldn’t open file /root/Bharat/load_config.xml: no such file or directory
[root@robin11-m1 Bharat]# ./confd_load -lm /root/Bharat/load_config.xml
confd_load: 618: maapi_load_config(sock, tid, flags, abspath(argv[0])) failed: system call failed (24): couldn’t open file /root/Bharat/load_config.xml: no such file or directory
[root@robin11-m1 Bharat]# ls -ltrh load_config.xml
-rw-r–r-- 1 root root 1.8K Aug 24 22:04 load_config.xml
[root@robin11-m1 Bharat]# pwd
/root/Bharat
[root@robin11-m1 Bharat]# ls -ltrh /root/Bharat/load_config.xml
-rw-r–r-- 1 root root 1.8K Aug 24 22:04 /root/Bharat/load_config.xml

Running confd_cmd with root user

It’s not the application that is important here, it is confd itself - does it have a read access to that file? If you do something like

confd_load -lm < load_config.xml

does that work? Note that in this case, confd_load sends the contents of the file, not the file path, whereas in what you are trying to do, both confd_load as well as your application sends only the file path; if ConfD does not have access to the file (e.g. it is running in a container or a chroot environment or a remote system), it inevitably fails.

Thanks @mvf
Understood the things.

We are running confd daemon & application in different POD/container. From application trying to execute MAAPI_LOAD_CONFIG_FILE api. So it is failing

When I tried executing in confd pod it is working fine

Can you please let us know how can we achieve 2 or more configuration blocks loading in to confd in a single transaction?

Note: Using MAAPI_LOAD_CONFIG_CMDS to load single config block into confd. Is it possible to load multiple config block using MAAPI_LOAD_CONFIG_CMDS?
iRetVal = maapi_load_config_cmds(maapi_fd, txn_handler, flags, strConfig.c_str(), strConfigBlock.c_str());

You may want to prefer maapi_load_config_stream instead of maapi_load_config_cmds, with the streaming variant you do not have to keep the whole configuration in memory and pass it as a parameter, you stream it over a socket instead. This is what confd_load does when you pipe the file into it, you can look at the source code to see how the function should be used.

But in either case, running any maapi_load_config* variant does not finish the transaction, you can run any number of them and only then run maapi_apply_trans followed by maapi_finish_trans.