Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cloud Debugger] Cloud Debugger Daemon is not working #2067

Closed
govargo opened this issue Jun 26, 2019 · 5 comments · Fixed by #2252
Closed

[Cloud Debugger] Cloud Debugger Daemon is not working #2067

govargo opened this issue Jun 26, 2019 · 5 comments · Fixed by #2252
Assignees
Labels
api: clouddebugger Issues related to the Cloud Debugger API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@govargo
Copy link

govargo commented Jun 26, 2019

Background

I would like to use Stackdriver Debugger for PHP.
I use Google Kubernetes Engine with scope(debugger).

Environment details

  • OS: Debian GNU/Linux VERSION9
  • PHP version: PHP 7.2.8 (cli)
    Zend Engine v3.2.0
    with Zend OPcache v7.2.8
  • Package name and version: google/cloud-debugger: 0.18.5
  • Run laravel application container by GKE

Steps to reproduce

Main Step is here.
https://cloud.google.com/debugger/docs/setup/php#gke

  1. ... gcloud container clusters create example-cluster-name
    --scopes=https://www.googleapis.com/auth/cloud_debugger
  2. ... RUN pecl install stackdriver_debugger_alpha
  3. ... composer require google/cloud-debugger
  4. ... RUN php /project/vendor/bin/google-cloud-debugger -c /project/config.php

Then Error happens. Please refer to "Problem Detail".

Problem Detail

I took these steps.
https://cloud.google.com/debugger/docs/setup/php#gke

In step.4

RUN php /project/vendor/bin/google-cloud-debugger -c /project/config.php

Then I'm facing following PHP Error.

Fatal error: Uncaught Exception: Given value cannot be converted to string. in /project/vendor/google/cloud-debugger/src/V2/Debuggee.php:179
Stack trace:
#0 /project/vendor/google/gax/src/Serializer.php(420): Google\Cloud\Debugger\V2\Debuggee->setId(NULL)
#1 /project/vendor/google/gax/src/Serializer.php(126): Google\ApiCore\Serializer->decodeMessageImpl(Object(Google\Cloud\Debugger\V2\Debuggee), Object(Google\Protobuf\Descriptor), Array)
#2 /project/vendor/google/cloud-debugger/src/Connection/Grpc.php(114): Google\ApiCore\Serializer->decodeMessage(Object(Google\Cloud\Debugger\V2\Debuggee), Array)
#3 /project/vendor/google/cloud-debugger/src/Debuggee.php(199): Google\Cloud\Debugger\Connection\Grpc->registerDebuggee(Array)
#4 /project/vendor/google/cloud-debugger/src/Daemon.php(193): Google\Cloud\Debugger\Debuggee->register()
#5 [internal function]: Google\Cloud\Debugger\Daemon->Google\Cloud\Debugger\{closure}()
#6 /project/vendor/google/cloud-core/src/ExponentialBackoff.php(80): call_user_func_array(Object(Closure), Array) in /project/vendor/google/gax/src/Serializer.php on line 128

In my opinion, The reason of problem is "Debuggee->setId(NULL)" especially "NULL".
I set config.php. But I could not avoid this.

Code

index.php

...
use Google\Cloud\Debugger\Agent;
use Google\Cloud\Debugger\BreakpointStorage\FileBreakpointStorage;

$fileBreakStorage = new FileBreakpointStorage();
$agent = new Agent(['sourceRoot' => realpath('../'), 'storage' => $fileBreakStorage]);
...

config.php

<?php

require __DIR__.'/vendor/autoload.php';

use Google\Cloud\Debugger\Daemon;
use Google\Cloud\Debugger\BreakpointStorage\FileBreakpointStorage;
use Google\Cloud\Debugger\DebuggerClient;
use Google\Cloud\Debugger\ExtendedSourceContext;
use Google\Cloud\Debugger\CloudRepoSourceContext;
use Google\Cloud\Debugger\ProjectRepoId;
use Google\Cloud\Debugger\RepoId;
use Google\Cloud\Debugger\AliasContext;

$projectRepoId = new ProjectRepoId('<MyProjectID>','laravel-skeleton');
$repoId = new RepoId($projectRepoId,'<Random UID>');
$aliasContext = new AliasContext(AliasContext::KIND_FIXED, 'master');
$cloudRepoSourceContext = new CloudRepoSourceContext($repoId,'<Revisionid>',$aliasContext);
$extSourceContext = new ExtendedSourceContext($cloudRepoSourceContext,['foo' => 'bar']);

$sourceRoot = '/project';
$fileBreakStorage = new FileBreakpointStorage();
$uniquifier = 'laravel-skeleton';
$description = 'StackDriverDebuggerTest';

$label = array(
    "foo" => "bar",
);

$clientConfig = array(
    "projectId" => "<MyProjectID>",
);

$debuggeeConfig = array(
    "uniquifier" => "laravel-skeleton",
    "description" => "StackDriverDebuggerTest",
    "isInactive" => "false",
    "status" => "status",
    "ExtendedSourceContext" => $extSourceContext,
);

$debugger = new DebuggerClient($clientConfig);
$debuggee = $debugger->debuggee('laravel-skelton',$debuggeeConfig);

$daemonConfig = array(
    "debuggee" => $debuggee,
    "sourceRoot" => $sourceRoot,
    "clientConfig" => $clientConfig,
    "uniquifier" => $uniquifier,
    "description" => $description,
    "storage" => $fileBreakStorage,
    "labels" => $label,
    "extSourceContext" => $extSourceContext,
);

$daemon = new Daemon($daemonConfig);

return $daemon;
@castaneai
Copy link

Hi,
I found the cause of the error.
Always NULL for debuggee identifier in Daemon class.
https://github.com/googleapis/google-cloud-php/blob/master/Debugger/src/Daemon.php#L183

This looks like Bug.

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Jun 27, 2019
@dwsupplee dwsupplee added api: clouddebugger Issues related to the Cloud Debugger API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed triage me I really want to be triaged. labels Jun 27, 2019
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Jun 27, 2019
@dwsupplee
Copy link
Contributor

Thanks for the report @govargo, @castaneai - we're looking in to this.

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Jul 1, 2019
@dwsupplee dwsupplee added status: investigating The issue is under investigation, which is determined to be non-trivial. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Jul 3, 2019
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. triage me I really want to be triaged. labels Jul 3, 2019
@dwsupplee dwsupplee removed 🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jul 3, 2019
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Jul 3, 2019
@jdpedrie
Copy link
Contributor

@govargo are you able to share a (possibly simplified) Dockerfile demonstrating your container configuration?

@govargo
Copy link
Author

govargo commented Jul 25, 2019

Here is my Dockerfile.
If you do not have enough information, please let me know.

##----------------------------------------------------------------------##
##     composer install stage
##----------------------------------------------------------------------##
FROM composer:1.8.6 AS builder

COPY composer.json composer.lock /app/
RUN  composer global require hirak/prestissimo \
   && composer install --ignore-platform-reqs --no-interaction --no-plugins --no-scripts --prefer-dist \
   && find vendor/ -type d -name '.git' -print0 | xargs -0 rm -rf \
   && composer global remove hirak/prestissimo \
   && rm -rf /root/.composer/

##----------------------------------------------------------------------##
##     image base stage
##----------------------------------------------------------------------##
FROM php:7.2.8-fpm-stretch AS base

ENV DEBIAN_FRONTEND noninteractive
ENV TZ Asia/Tokyo

RUN docker-php-source extract \
  && apt-get update \
  && apt-get install -y --no-install-recommends supervisor vim-tiny zip unzip nginx libnginx-mod-http-lua procps libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng-dev libxml2-dev zlib1g-dev libcurl4-openssl-dev gcc g++ make git \
  && docker-php-ext-install -j$(nproc) bcmath calendar curl exif gd gettext mbstring opcache pcntl shmop sockets sysvmsg sysvsem sysvshm wddx xml \
  && pecl install apcu \
  && pecl install redis \
  && pecl install msgpack \
  && pecl install grpc \
  && pecl install protobuf \
  && pecl install igbinary \
  && docker-php-ext-enable apcu redis msgpack grpc protobuf igbinary \
  && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng-dev libxml2-dev zlib1g-dev libcurl4-openssl-dev gcc g++ make \
  && apt-get clean -y \
  && docker-php-source delete \
  && rm -rf /var/cache/debconf/* /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/local/etc/php-fpm.d/* /usr/src/* \
  && find /var/log/ -type f -delete \
  && mkdir -p /run/lib/nginx \
  && rm -rf /var/lib/nginx \
  && ln -s /run/lib/nginx /var/lib/nginx \
  && chown -R www-data:www-data /var/lib/nginx

##----------------------------------------------------------------------##
##     k8s image base(dev environment) stage
##----------------------------------------------------------------------##
FROM base AS dev

COPY docker/files /
COPY composer.json composer.lock /project/

WORKDIR /project

COPY --from=builder /usr/bin/composer /usr/local/bin/composer
COPY --chown=www-data:www-data --from=builder /app/vendor /project/vendor
COPY --chown=www-data:www-data . /project/

RUN composer dump-autoload \
  && rm -rf /usr/local/bin/composer \
  && chmod +x /usr/local/bin/* \

USER www-data

# run script is custom script. Supervisord is started and Supervisord controll nginx + php-fpm.
CMD ["run"]

##----------------------------------------------------------------------##
##     k8s stackdriver debugger stage
##----------------------------------------------------------------------##
FROM dev AS dev-stackdriver

USER root

RUN apt-get update \
  && apt-get install -y --no-install-recommends zip unzip procps libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng-dev libxml2-dev zlib1g-dev libcurl4-openssl-dev gcc g++ make \
  && pecl install stackdriver_debugger-alpha \
  && docker-php-ext-enable stackdriver_debugger \
  && apt-get clean -y \
  && rm -rf /var/cache/debconf/* /var/lib/apt/lists/*

USER www-data

# run script is custom script. Supervisord is started and Supervisord controll nginx + php-fpm.
CMD ["run"]

@jdpedrie jdpedrie added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed status: investigating The issue is under investigation, which is determined to be non-trivial. labels Aug 16, 2019
@jdpedrie
Copy link
Contributor

@govargo @castaneai apologies it took so long to get back to you. I've confirmed the issue and opened #2252 to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: clouddebugger Issues related to the Cloud Debugger API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants