project Websites / Gitlab Issue Listing Script avatar

websites/Gitlab-Issue-Listing-Script#56: Whitescreen on project page caused by empty Container List



Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Milestone: v0.5
Created: 27-Aug-22 15:29



Description

With display_errors enabled we get the following


Warning: Redis::connect(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /var/www/html/lib/gitlab.php on line 940 Warning: Redis::connect(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /var/www/html/lib/gitlab.php on line 940 Warning: Redis::connect(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /var/www/html/lib/gitlab.php on line 940 Warning: Redis::connect(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /var/www/html/lib/gitlab.php on line 940 Warning: Redis::connect(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /var/www/html/lib/gitlab.php on line 940 Warning: Redis::connect(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /var/www/html/lib/gitlab.php on line 940 Fatal error: Uncaught TypeError: count(): Argument [[#1](/issue/websites/Gitlab-Issue-Listing-Script/1.html)](/issue/websites/Gitlab-Issue-Listing-Script/1.html) ($value) must be of type Countable|array, null given in /var/www/html/lib/gitlab.php:550 Stack trace: [#0](/issue/websites/Gitlab-Issue-Listing-Script/0.html) /var/www/html/lib/router.php(65): GILSGitlab->getProjectAndIssues('websites/Gitlab...') [[#1](/issue/websites/Gitlab-Issue-Listing-Script/1.html)](/issue/websites/Gitlab-Issue-Listing-Script/1.html) /var/www/html/index.php(14): GILSRouter->route('/project/websit...') [#2](/issue/websites/Gitlab-Issue-Listing-Script/2.html) {main} thrown in /var/www/html/lib/gitlab.php on line 550


Toggle State Changes

Activity


assigned to @btasker

changed title from {-Interruption in name resolution can lead to errors being cached-} to {+Whitescreen on project page+}

changed the description

Turns out this isn't Redis related - have updated the description.

I'm not sure how we got here yet, but the issue is here

$c = $this->getContainers($proj_path);
$o['has_containers'] = (count($c['containers']) > 0)? true : false;

That function, at first glance, looks reasonable safe:

    function getContainers($proj_path){
        global $config;

        if (!$this->enforceProjectFilters($proj_path)){
            http_response_code(404);
            echo "Containers Not found";
            die;
        }        

        $url = $config->server . "/api/v4/projects/" . urlencode($proj_path) . "/registry/repositories/?tags=true";
        $r = $this->callAPI("GET", $url, false, $config->do_auth);

        $containers = json_decode($r['result']);    

        if (is_object($containers) && $containers->message){
            $containers = array();
        }

        $o = array(
            "containers" => $containers,
            "project" => $this->getProject($proj_path)
        );

        return $o;           
    }

But.... what if the returned result is not an object? If we get an empty response back (for whatever reason) then we won't add the empty array.

Dropping a print_r() in there confirms it

Array ( [result] => [headers] => Array ( ) [links] => Array ( ) ) 

The request failed (potentially because of the Redis issue, but we'll deal with that seperately).

verified

mentioned in commit b06238355b9aae7bc90b5c577defd7d8c4e2e853

Commit: b06238355b9aae7bc90b5c577defd7d8c4e2e853 
Author: B Tasker                            
                            
Date: 2022-08-27T16:37:08.000+01:00 

Message

Handle things if the container list request fails (websites/Gitlab-Issue-Listing-Script#56)

+1 -1 (2 lines changed)

The commit handles this particular failure case.

Now need to look into the Redis handling - the page is no longer generating a 500, but we're also not getting any data back. Presumably the Redis container has OOM'd or similar.

I'll raise a separate issue to track improving handling of that

FTR looks like we already handle Redis issues sanely

            try {
                $this->redis->connect($config->redis_host, $config->redis_port);

                if ($config->redis_pass){
                    $this->redis->auth($config->redis_pass);   
                }
            }
            catch (exception $e){
                // We failed to connect
                // let's not kill the application
                // The library will push warnings out, so it's not a silent failure
                $this->redis = false;
            }

Presumably, whatever interrupted name resolution also prevented us resolving the name of Gitlab's API, which is why pages came back without content.

changed title from Whitescreen on project page to Whitescreen on project page{+ caused by empty Container List+}