ImportError when importing Numpy on a vFunction Server's vfunction-vfapi-measurements Container



Overview of the Issue

This issue occurs in the following circumstances:

  1. The vFunction Sudo or Sudoless Server is installed in a Linux environment using a default Installation TGZ with Alpine and Debian Base Images
  2. A vFunction .NET or Java Controller is installed and an organization’s Application is hooked with the vFunction Agent
  3. Learning is started in the vFunction Server UI and tests are performed in the organization’s Application
  4. Unexpectedly, the vFunction Server UI shows that there are 0 Resources and 0 Functions being tracked in the organization’s Application
  5. 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
  6. The Application’s Namespace configuration (Classes to Include) is configured correctly in the vFunction Server UI
  7. 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:

  1. SSH to the vFunction Server VM
  2. Run docker stop vfunction-monit
  3. Run docker stop vfunction-nginx
  4. Run docker stop vfunction-vfapi-idp vfunction-vfapi-organizations vfunction-vfapi-users vfunction-vfapi-measurements vfunction-vfapi-parser
  5. Run docker stop vfunction-mysql
  6. Run systemctl docker restart
  7. Run docker volume rm -f vfapi_measurements_storage_vol
  8. Run docker volume rm -f mysql_vol
  9. Download the newest vFunction Server UBI Offline Installation TGZ to the vFunction Server VM
  10. Move to the directory where vFunction Server is installed on the VM, e.g. cd /home/username/vfunction/ or cd /
  11. Run cp etc/sysconfig/vfunction/installation/server-installation.yaml /tmp/
  12. Unpack the vFunction Server UBI Offline Installation TGZ over the existing vFunction Server directory structure, e.g. tar -Pxvf (sudo) or tar -xvf (sudoless)
  13. Run cp /tmp/server-installation.yaml etc/sysconfig/vfunction/installation/
  14. Run bash opt/vfunction/server-installation/install.sh
  15. Log into the vFunction Server UI in a browser
  16. Create a new Application
  17. Gather the App ID, Org ID, Client ID, and Client Secret for the new Application that was just created
  18. SSH or RDP to the .NET or Java Controller(s)
  19. Modify the vFunction Controller’s installation.yaml(s) to place the four new values for App ID, Org ID, Client ID, and Client Secret
  20. Run the vFunction Controller’s install.sh script for each vFunction Controller instance
  21. Start Learning in the VF Server UI in a browser
  22. Test the Application’s functionality again
  23. Confirm that the Resource and Functions counts in the vFunction Server UI are no longer 0
  24. Confirm that the Analysis tab is accessible in the vFunction Server UI