UnityHPC / unity-web-portal

A frontend user portal for HPC clusters
GNU General Public License v3.0
9 stars 11 forks source link

can't accept user into PI group #109

Open simonLeary42 opened 1 day ago

simonLeary42 commented 1 day ago

accepting user into PI group causes timeout error / blank page

[Mon Oct 28 16:32:45.783277 2024] [php7:error] [pid 2262080] [client 128.111.197.218:53616] PHP Fatal error:  Maximum execution time of 30 seconds exceeded in /srv/www/unity-web-1.1.1/vendor/hakasapl/phpopenldaper/src/PHPOpenLDAPer/LDAPEntry.php on line 167
[Mon Oct 28 16:33:19.312955 2024] [php7:error] [pid 2261999] [client 128.111.197.218:36826] PHP Fatal error:  Maximum execution time of 30 seconds exceeded in /srv/www/unity-web-1.1.1/resources/lib/UnityLDAP.php on line 132
[Mon Oct 28 16:33:53.826068 2024] [php7:error] [pid 2261789] [client 128.111.197.218:36838] PHP Fatal error:  Maximum execution time of 30 seconds exceeded in /srv/www/unity-web-1.1.1/vendor/hakasapl/phpopenldaper/src/PHPOpenLDAPer/LDAPConn.php on line 89
[Mon Oct 28 16:35:37.465928 2024] [php7:error] [pid 2262080] [client 128.111.197.218:59246] PHP Fatal error:  Maximum execution time of 30 seconds exceeded in /srv/www/unity-web-1.1.1/vendor/hakasapl/phpopenldaper/src/PHPOpenLDAPer/LDAPConn.php on line 87

this is happening for pi_jlb_umass_edu for user broder49@msu.edu

bryank-cs commented 1 day ago

The issue was GIDNumInUse was getting called for every user and not caching the result. Suggested fix:

diff --git a/resources/lib/UnityLDAP.php b/resources/lib/UnityLDAP.php
index b5a5d90..8bc2af8 100644
--- a/resources/lib/UnityLDAP.php
+++ b/resources/lib/UnityLDAP.php
@@ -192,7 +192,11 @@ class UnityLDAP extends ldapConn

     private function GIDNumInUse($id)
     {
-        $users = $this->groupOU->getChildrenArray(true);
+        static $users = null;
+        # Only do this lookup once
+        if ($users === null) {
+            $users =  $this->groupOU->getChildrenArray(true);
+        }
         foreach ($users as $user) {
             if ($user["gidnumber"][0] == $id) {
                 return true;