5G-MAG / rt-5gms-application-server

5G Media Streaming - Application Server
https://www.5g-mag.com/streaming
Other
4 stars 5 forks source link

MVP#2 Application Server installation/running issues/observations #57

Closed jordijoangimenez closed 1 year ago

jordijoangimenez commented 1 year ago

I'm testing AF (development brach) and AS (1.0.1-rc). I've deleted all repos and re-started from scratch. The AF is up and running. When trying to run the AS after having installed it I got:

fivegmag@NUC1:~/rt-5gms-application-server$ 5gms-application-server 
Traceback (most recent call last):
  File "/home/fivegmag/.local/bin/5gms-application-server", line 8, in <module>
    sys.exit(main())
  File "/home/fivegmag/.local/lib/python3.10/site-packages/rt_5gms_as/app.py", line 257, in main
    context = Context(config)
  File "/home/fivegmag/.local/lib/python3.10/site-packages/rt_5gms_as/context.py", line 87, in __init__
    self.__loadConfiguration(force=True)
  File "/home/fivegmag/.local/lib/python3.10/site-packages/rt_5gms_as/context.py", line 374, in __loadConfiguration
    os.makedirs(directory)
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/run/rt-5gms'

Not sure if my issue is now even more fundamental as the AS fails to run entirely before launching the AF. I launch the AS as 5gms-application-server (ie without a -c configfile). What is the AS doing when no config file is specified? For MVP#2 I understand it should wait for receiving info from the AF?

rjb1000 commented 1 year ago

Not sure if my issue is now even more fundamental as the AS fails to run entirely before launching the AF.

The AS runs independently of the AF in MVP#2, so it should be possible to start them in any order.

rjb1000 commented 1 year ago

The error you posted indicates that the AS is having trouble creating a directory:

PermissionError: [Errno 13] Permission denied: '/run/rt-5gms'

Looks like the process lacks permissions to create the directory /run/rt-5gms.

Does that directory already exist in your system, but is owned by root while you are trying to run the AS as a non-root user?

jordijoangimenez commented 1 year ago
fivegmag@NUC1:/run$ cd rt-5gms
bash: cd: rt-5gms: No such file or directory

It looks like it doesn't exist so it's actually not an issue of permission to access to it? Which process creates it?

rjb1000 commented 1 year ago

Reading the full error trace bottom to top suggests that the problem was encountered during a directory creation operation.

If the directory doesn't exist, that suggests that that AS process lacks sufficient permission to create it.

That's as far as I can help you. @davidjwbbc can take over from here!

jordijoangimenez commented 1 year ago

Thank you Richard! For some more info, if useful. I've tried to run the AS as sudo:

fivegmag@NUC1:~$ sudo /home/fivegmag/.local/bin/5gms-application-server
Traceback (most recent call last):
  File "/home/fivegmag/.local/bin/5gms-application-server", line 5, in <module>
    from rt_5gms_as.app import main
ModuleNotFoundError: No module named 'rt_5gms_as'
jordijoangimenez commented 1 year ago

I've tried with another machine. What I've found now is the following problem:

fivegmag@NUC2:~/rt-5gms-application-server$ 5gms-application-server -h
Traceback (most recent call last):
  File "/home/fivegmag/.local/bin/5gms-application-server", line 5, in <module>
    from rt_5gms_as.app import main
  File "/home/fivegmag/.local/lib/python3.10/site-packages/rt_5gms_as/app.py", line 37, in <module>
    from .proxy_factory import WebProxy, list_registered_web_proxies
  File "/home/fivegmag/.local/lib/python3.10/site-packages/rt_5gms_as/proxy_factory.py", line 438, in <module>
    importlib.import_module('.proxies.'+module_name, __package__)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/fivegmag/.local/lib/python3.10/site-packages/rt_5gms_as/proxies/nginx.py", line 41, in <module>
    from ..context import Context
  File "/home/fivegmag/.local/lib/python3.10/site-packages/rt_5gms_as/context.py", line 36, in <module>
    from .openapi_5g.models.content_hosting_configuration import ContentHostingConfiguration
ModuleNotFoundError: No module named 'rt_5gms_as.openapi_5g'

I remember this was reported by @dsilhavy here: https://github.com/5G-MAG/rt-5gms-application-server/issues/39

davidjwbbc commented 1 year ago

So the No module named 'rt_5gms_as.openapi_5g' error means that the openapi-generator failed to create the bindings. Running the script separately (build_scripts/generate_5gms_as_openapi) will show you why it's failing.

The No module named 'rt_5gms_as' when you tried to use sudo was because the root user's default PYTHONPATH does not include include your user's ~/.local/lib/python3.10/site-packages directory, so the installed rt_5gms_as module could not be found. You will probably find it will work if you do: sudo PYTHONPATH=/home/fivegmag/.local/lib/python3.10/site-packages:/home/fivegmag/.local/lib/python3.10 /home/fivegmag/.local/bin/5gms-application-server

The permissions issue with /run/rt-5gms is because /run is owned by root. To get around this edit/create an application server configuration file which redirects the application server to use directories that the user can write to, e.g. save the following into my-local-user-as.conf:

[DEFAULT]
log_dir = /tmp/rt-5gms-as/logs
run_dir = /tmp/rt-5gms-as

[5gms_as]
cache_dir = /tmp/rt-5gms-as/cache
certificates_cache = /tmp/rt-5gms-as/certificates
http_port = 8080
https_port = 8443

[5gms_as.nginx]
root_temp = /tmp/rt-5gms-as

then run the application server as ~/.local/bin/5gms-application-server -c my-local-user-as.conf

The default configuration assumes that the application server is being installed by root as a system service, so you'll need to create an alternative configuration if you wish to run as a normal user. The default configuration file can be found in ~/rt-5gms-application-server/docs/example-application-server.conf. You can either use your new configuration file by using the -c command line parameter, as indicated above, or you can place it in ~/.rt-5gms/application-server.conf to have it as the default configuration for that user.

jordijoangimenez commented 1 year ago

Thank you, David. I cannot see anything when executing build_scripts/generate_5gms_as_openapiin the PC where this is failing.

On the other PC this works: sudo PYTHONPATH=/home/fivegmag/.local/lib/python3.10/site-packages:/home/fivegmag/.local/lib/python3.10 /home/fivegmag/.local/bin/5gms-application-server However,

fivegmag@NUC1:~/rt-5gms-application-function/src/5gmsaf$ ~/rt-5gms-application-function/install/bin/open5gs-msafd
02/01 11:49:29.001: [app] FATAL: cannot open file `/home/fivegmag/rt-5gms-application-function/install/etc/open5gs/msaf.yaml` (../subprojects/open5gs/lib/app/ogs-init.c:171)
02/01 11:49:29.001: [app] FATAL: Open5GS initialization failed. Aborted (../subprojects/open5gs/src/main.c:210)

There is no msaf.yaml in that directory.

jordijoangimenez commented 1 year ago

I copied it manually from the /src/5gmsaf directory and now it works (doesnt complain)

jordijoangimenez commented 1 year ago

The AS shows me:

fivegmag@NUC1:~/rt-5gms-application-server/src$ sudo PYTHONPATH=/home/fivegmag/.local/lib/python3.10/site-packages:/home/fivegmag/.local/lib/python3.10 /home/fivegmag/.local/bin/5gms-application-server
[2023-02-01 12:04:53 +0100] [11102] [INFO] Running on http://127.0.0.1:7777 (CTRL + C to quit)
INFO:hypercorn.error:Running on http://127.0.0.1:7777 (CTRL + C to quit)

The AF shows me (based on the yaml I copied from one folder to another):

fivegmag@NUC1:~/rt-5gms-application-function/src/5gmsaf$ ~/rt-5gms-application-function/install/bin/open5gs-msafd
Open5GS daemon v2.4.9-116-g24e20f2+

02/01 12:05:03.011: [app] INFO: Configuration: '/home/fivegmag/rt-5gms-application-function/install/etc/open5gs/msaf.yaml' (../subprojects/open5gs/lib/app/ogs-init.c:126)
02/01 12:05:03.012: [sbi] WARNING: [BSF:nbsf-management] has no NRF (../subprojects/open5gs/lib/sbi/context.c:1859)
02/01 12:05:03.013: [sbi] INFO: mhd_server() [127.0.0.22]:7777 (../subprojects/open5gs/lib/sbi/mhd-server.c:279)
02/01 12:05:03.013: [msaf] INFO: [46e09078-a220-41ed-9232-2bb1447ad6bf] MSAF Running (../src/5gmsaf/msaf-sm.c:52)
02/01 12:05:03.013: [app] INFO: 5GMSAF initialize...done (../src/5gmsaf/app.c:24)

However I dont see its getting configured, it doesnt give me the ID. The server is up and running as I can see http://127.0.0.22:7777/3gpp-m5/v2/service-access-information/but cannot test it correctly as I dont have a provsessionID

davidjwbbc commented 1 year ago

The development branch of the AS (v1.1.0) will work with the development branch of the AF (v1.1.0) as they both implement the M3 interface.

The development AS (v1.1.0) will not get configured by the AF 1.0.1-rc as that AF does not implement M3.

If you wish to test the ServiceAccessInformation returned from AF 1.0.1-rc then please use the AS release 1.0.1 (or v1.0.x branch) with the same ContentHostingConfiguration configured, as these versions are compatible with each other. The ProvisioningSessionId is set in the msaf.yaml file and will be d54a1fcc-d411-4e32-807b-2c60dbaeaf5f unless you've changed it. The dynamic ProvisioningSessionId will only be coming in v1.1.0 (current development branch).