Récemment, lorsque j'ai tenté de mettre à niveau les versions de php du fichier docker qui exécute craft cms dans un service d'exécution en nuage, j'ai commencé à obtenir des erreurs de connexion CloudSQL.
Exemple de journaux.
2019-08-08T06:58:25.612096Z POST200 474 B 38 ms Chrome 75 /index.php?p=mangomin/actions/install/validate-db
2019-08-08T07:00:12.134410Z CloudSQL connection failed. Please see https://cloud.google.com/functions/docs/sql#troubleshooting for additional details: Post https://www.googleapis.com/sql/v1beta4/projects/c3gatsby-workflow-420fc457/instances/master-sql-f47f6b/createEphemeral?alt=json&prettyPrint=false: context deadline exceeded
2019-08-08T07:00:12.141939Z 169.254.8.129 - - [08/Aug/2019:07:00:02 +0000] "GET / HTTP/1.1" 503 52611 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"
2019-08-08T07:00:12.144019Z GET503 51.4 KB 10 s Chrome 75 /
2019-08-08T07:01:34.189448Z CloudSQL connection failed. Please see https://cloud.google.com/functions/docs/sql#troubleshooting for additional details: Post https://www.googleapis.com/sql/v1beta4/projects/c3gatsby-workflow-420fc457/instances/master-sql-f47f6b/createEphemeral?alt=json&prettyPrint=false: context deadline exceeded
2019-08-08T07:01:34.200976Z GET503 51.4 KB 10 s Chrome 75 /
Cela a commencé à se produire ce matin, le 8 août 2019. Au départ, je pensais que c'était juste que la version de php que j'ai mise à niveau n'était pas compatible avec les sockets unix ou similaires, alors j'ai rétrogradé. Cela n'a pas fonctionné. J'ai donc continué à revenir en arrière, jusqu'à la révision d'hier (même environnement et même docker). Le problème a persisté, j'ai ensuite fait marche arrière jusqu'à une version stable de docker qui, je le sais, fonctionne sur un service sœur exécuté dans le nuage. Rien à faire.
En bref, la seule chose que j'ai essayé de mettre à jour est le fichier docker et la façon dont il est construit. (J'ai essayé d'activer opcache qui a fait des merveilles localement pour accélérer les requêtes). Ancien
FROM php:7.1-apache
# Enable Reqrite and Headers for .htaccess
RUN a2enmod rewrite
RUN a2enmod headers
# Ensure UTF-8
RUN echo "AddDefaultCharset UTF-8" > /var/www/html/.htaccess
# Install linux dependencies
RUN export CFLAGS="$PHP_CFLAGS" CPPFLAGS="$PHP_CPPFLAGS" LDFLAGS="$PHP_LDFLAGS" \
&& apt-get update --fix-missing \
&& apt-get install -y ssl-cert libmagickwand-dev libpq-dev zlib1g \
&& rm -rf /var/lib/apt/lists/*
# Install imagick
RUN pecl install imagick-3.4.3
# Install php extentions for docker
RUN docker-php-ext-enable imagick \
&& docker-php-ext-install pdo pdo_mysql zip
# Enable SSL apache2
RUN a2ensite default-ssl \
&& a2enmod ssl
# Replace the default served file to /web
RUN sed -i 's%/var/www/html%/var/www/html/web%g' /etc/apache2/sites-enabled/*.conf
# Use the PORT environment variable in Apache configuration files.
RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-enabled/000-default.conf /etc/apache2/ports.conf
# Replace with production mode
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# Up the upload file size limit, memory limit and max-execution time
RUN sed -i "s/max_input_time = 30/max_input_time = 120/g" "$PHP_INI_DIR/php.ini"
RUN sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 5M/g" "$PHP_INI_DIR/php.ini"
RUN sed -i "s/max_execution_time = 30/max_execution_time = 120/g" "$PHP_INI_DIR/php.ini"
RUN sed -i "s/memory_limit = 128M/memory_limit = 256M/g" "$PHP_INI_DIR/php.ini"
Nouveau
FROM php:7.3-apache-stretch
# Enable Reqrite and Headers for .htaccess
RUN a2enmod rewrite
RUN a2enmod headers
# Ensure UTF-8
RUN echo "AddDefaultCharset UTF-8" > /var/www/html/.htaccess
RUN export CFLAGS="$PHP_CFLAGS" CPPFLAGS="$PHP_CPPFLAGS" LDFLAGS="$PHP_LDFLAGS"
# Install linux dependencies
RUN apt-get update --fix-missing \
&& apt-get install -y libfreetype6-dev libjpeg62-turbo-dev \
libpng-dev libbz2-dev \
libssl-dev autoconf \
ca-certificates curl g++ libicu-dev mysql-client \
ssl-cert libmagickwand-dev libpq-dev zlib1g libzip-dev \
&& rm -rf /var/lib/apt/lists/*
# Install imagick
RUN pecl install imagick-3.4.3
# Install php extentions for docker
RUN docker-php-ext-enable imagick
RUN docker-php-ext-install bcmath bz2 exif \
gd gettext mbstring opcache
RUN docker-php-ext-install shmop sockets sysvmsg sysvsem sysvshm \
zip iconv pdo_mysql intl
# Enable SSL apache2
RUN a2ensite default-ssl \
&& a2enmod ssl
COPY php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS="0" \
PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \
PHP_OPCACHE_MEMORY_CONSUMPTION="192" \
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10"
# Replace the default served file to /web
RUN sed -i 's%/var/www/html%/var/www/html/web%g' /etc/apache2/sites-enabled/*.conf
# Use the PORT environment variable in Apache configuration files.
RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-enabled/000-default.conf /etc/apache2/ports.conf
# Replace with production mode
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# Up the upload file size limit, memory limit and max-execution time
RUN sed -i "s/max_input_time = 30/max_input_time = 120/g" "$PHP_INI_DIR/php.ini" && \
sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 10M/g" "$PHP_INI_DIR/php.ini" && \
sed -i "s/max_execution_time = 30/max_execution_time = 120/g" "$PHP_INI_DIR/php.ini" && \
sed -i "s/memory_limit = 128M/memory_limit = 512M/g" "$PHP_INI_DIR/php.ini"
Je m'excuse d'avoir posté des fichiers entiers.
Les résultats attendus et réels ont déjà été expliqués.
J'ai constaté que les délais d'attente sont exactement de 10 secondes, si cela a un rapport avec quelque chose.
Toute aide sera appréciée.
Merci d'avance.