ImportError when importing Numpy on a vFunction Server's vfunction-vfapi-measurements Container
Overview of the Issue
This issue occurs in the following circumstances:
- The vFunction Sudo or Sudoless Server is installed in a Linux environment using a default Installation TGZ with Alpine and Debian Base Images
- A vFunction .NET or Java Controller is installed and an organization’s Application is hooked with the vFunction Agent
- Learning is started in the vFunction Server UI and tests are performed in the organization’s Application
- Unexpectedly, the vFunction Server UI shows that there are 0 Resources and 0 Functions being tracked in the organization’s Application
- After stopping Learning, a user cannot click on the Analysis tab in the vFunction Server UI. Instead, a message is displayed below the Analysis tab that inaccurately says that the application is still in Learning
- The Application’s Namespace configuration (Classes to Include) is configured correctly in the vFunction Server UI
- The logs from the vFunction Server’s vfunction-vfapi-measurements Container, retrieved either via “docker logs vfunction-vfapi-measurements” or via the var/log/vfunction/vfapi.log, show the following error:
{"level":"debug","s":"measurements","time":"2024-03-06T09:21:31Z","caller":"/src/vfapi/services/measurements/bl/analysis.go:172","message":
"Executing [/usr/bin/env python3 analysis service_decomposition --call_tree_methods_in /tmp/vfunction/measurements/tmp-.../
call_tree_methods-PART24338.parquet --call_tree_vars_in /tmp/vfunction/measurements/tmp-.../call_tree_vars-
PART24338.parquet --methods_in /tmp/vfunction/measurements/tmp-.../methods-PART24338.parquet --vars_in /tmp/vfunction/measurements
/tmp-.../vars-PART24338.parquet --state_json_out /tmp/vfunction/measurements/tmp-.../state.json --out_dir /tmp/vfunction/measurements/
tmp-.../db --msrmt_id ... --conf /tmp/vfunction/measurements/tmp-.../conf.yaml --full_graph_in /tmp/vfunction/measurements/tmp-.../full_graph.json]"}
{"level":"debug","s":"measurements","pid":28245,"time":"2024-03-06T09:21:31Z","caller":"/src/vfapi/services/measurements/bl/analysis.go:177",
"message":"service_decomposition is running"}
OpenBLAS blas_thread_init: pthread_create failed for thread 1 of 2: Operation not permitted
OpenBLAS blas_thread_init: RLIMIT_NPROC -1 current, -1 max
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "<frozen __main__>", line 3, in <module>
File "<frozen analysis.__main__>", line 5, in <module>
File "<frozen analysis>", line 3, in <module>
File "<frozen analysis>", line 4, in <module>
File "/usr/local/lib/python3.11/site-packages/pandas/__init__.py", line 16, in <module>
raise ImportError(
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.11 from "/usr/bin/env python3"
* The NumPy version is: "1.25.2"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: PyCapsule_Import could not import module "datetime"
Steps to Resolve the Issue
This issue can be resolved by taking the following steps to re-install the vFunction Server using UBI Base Images:
- SSH to the vFunction Server VM
- Run
docker stop vfunction-monit
- Run
docker stop vfunction-nginx
- Run
docker stop vfunction-vfapi-idp vfunction-vfapi-organizations vfunction-vfapi-users vfunction-vfapi-measurements vfunction-vfapi-parser
- Run
docker stop vfunction-mysql
- Run
systemctl docker restart
- Run
docker volume rm -f vfapi_measurements_storage_vol
- Run
docker volume rm -f mysql_vol
- Download the newest vFunction Server UBI Offline Installation TGZ to the vFunction Server VM
- Move to the directory where vFunction Server is installed on the VM, e.g. cd /home/username/vfunction/ or cd /
- Run
cp etc/sysconfig/vfunction/installation/server-installation.yaml /tmp/
- Unpack the vFunction Server UBI Offline Installation TGZ over the existing vFunction Server directory structure, e.g. tar -Pxvf (sudo) or tar -xvf (sudoless)
- Run
cp /tmp/server-installation.yaml etc/sysconfig/vfunction/installation/
- Run
bash opt/vfunction/server-installation/install.sh
- Log into the vFunction Server UI in a browser
- Create a new Application
- Gather the App ID, Org ID, Client ID, and Client Secret for the new Application that was just created
- SSH or RDP to the .NET or Java Controller(s)
- Modify the vFunction Controller’s installation.yaml(s) to place the four new values for App ID, Org ID, Client ID, and Client Secret
- Run the vFunction Controller’s install.sh script for each vFunction Controller instance
- Start Learning in the VF Server UI in a browser
- Test the Application’s functionality again
- Confirm that the Resource and Functions counts in the vFunction Server UI are no longer 0
- Confirm that the Analysis tab is accessible in the vFunction Server UI