镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

After deployment of ExApp "Test Deploy" infinite loop at Heartbeat #439

Closed

Description

@jirireischig

Describe the bug

After having deployed the ExApp "Test Deploy" Interface shows circle at Heartbeat and test never stop.

Docker container test-deploy is running and browser never stop getting answer from "https://server/index.php/apps/app_api/daemons/docker_socket_proxy/test_deploy/status" as json data:

{
    "deploy": 100,
    "init": 0,
    "action": "healthcheck",
    "type": "install",
    "error": "",
    "deploy_start_time": 1730990023
}

Steps/Code to Reproduce

Deploy the "Test Deploy" on NextCloud

Expected Results

All test steps are OK

Actual Results

infinite loop at Heartbeat test

Setup configuration

app_api = 4.0.0, Nextcloud = 30.0.2

Activity

  1. trisosamu commented on Dec 9, 2024

    @trisosamu

    same problem

  2. oleksandr-nc commented on May 9, 2025

    @oleksandr-nc
    Contributor

    Please retry with the latest version of Nextcloud/AppAPI.

    And we need logs for test-deploy container(there is button in UI to get them)

  3. jirireischig commented on May 28, 2025

    @jirireischig
    Author

    I have latest Version of AppAPI 5.0.2.

    Logs for test-deploy:

    HP_SHARED_KEY is not set. Skipping FRP configuration.
    Starting main application...
    Started
    INFO:     Started server process [1]
    INFO:     Waiting for application startup.
    TRACE:    ASGI [1] Started scope={'type': 'lifespan', 'asgi': {'version': '3.0', 'spec_version': '2.0'}, 'state': {}}
    TRACE:    ASGI [1] Receive {'type': 'lifespan.startup'}
    TRACE:    ASGI [1] Send {'type': 'lifespan.startup.complete'}
    INFO:     Application startup complete.
    INFO:     Uvicorn running on http://127.0.0.1:23000 (Press CTRL+C to quit)
    HP_SHARED_KEY is not set. Skipping FRP configuration.
    Starting main application...
    Started
    INFO:     Started server process [1]
    INFO:     Waiting for application startup.
    TRACE:    ASGI [1] Started scope={'type': 'lifespan', 'asgi': {'version': '3.0', 'spec_version': '2.0'}, 'state': {}}
    TRACE:    ASGI [1] Receive {'type': 'lifespan.startup'}
    TRACE:    ASGI [1] Send {'type': 'lifespan.startup.complete'}
    INFO:     Application startup complete.
    INFO:     Uvicorn running on http://127.0.0.1:23000 (Press CTRL+C to quit)
    
  4. oleksandr-nc commented on May 28, 2025

    @oleksandr-nc
    Contributor

    I assume that the ExApps are installed on the remote machine (judging by this Uvicorn running on http://127.0.0.1:23000)

    And looks like Nextcloud instance could not connect to it (to DSP container, where HaProxy is listening on the 0.0.0.0:23000 port)

    To help configure your setup we need additional information:

    1. What fields are set in DeployDaemon
    2. Can you ping the DSP container from the Nextcloud instance
    3. Maybe firewall is blocking connection?
  5. jirireischig commented on May 28, 2025

    @jirireischig
    Author

    IP 127.0.0.1 = localhost and it is on the same machine.
    There is not any firewall and connection is OK.

    I got logs entries in podman from health requests:
    May 28 15:38:48 "GET /v1.41/containers/nc_app_test-deploy/json HTTP/1.1" 200 6743 "" "GuzzleHttp/7"

    I also create simple php test in webroot directory where is Nextcloud installed:
    file_get_contents('http://127.0.0.1:23000/v1.41/containers/nc_app_test-deploy/json')

    and got this answer:
    file_get_contents(http://127.0.0.1:23000/v1.41/containers/nc_app_test-deploy/json): Failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized

    So, the connection look like good. I don't have good authentication for my simple test.

  6. oleksandr-nc commented on May 28, 2025

    @oleksandr-nc
    Contributor

    I got logs entries in podman from health requests:
    May 28 15:38:48 "GET /v1.41/containers/nc_app_test-deploy/json HTTP/1.1" 200 6743 "" "GuzzleHttp/7"

    This is a connection from the Nextcloud to the Docker Engine.

    Can you share Nextcloud logs for the Test Deploy action? There should be string that shows to which address AppAPI tries to connect to reach ExApp.

  7. jirireischig commented on May 28, 2025

    @jirireischig
    Author

    In webdeveloper I see a lot of requests for health checking on url /index.php/apps/app_api/daemons/docker_local/test_deploy/status with code 200 and this content:

    {
        "deploy": 100,
        "init": 0,
        "action": "healthcheck",
        "type": "install",
        "error": "",
        "deploy_start_time": 1748440577
    }
    
  8. oleksandr-nc commented on May 28, 2025

    @oleksandr-nc
    Contributor

    In webdeveloper I see a lot of requests for health checking on url /index.php/apps/app_api/daemons/docker_local/test_deploy/status with code 200 and this content:

    That is not related, it is a frontend request to the Nextcloud instance...

  9. jirireischig commented on May 28, 2025

    @jirireischig
    Author

    I got logs entries in podman from health requests:
    May 28 15:38:48 "GET /v1.41/containers/nc_app_test-deploy/json HTTP/1.1" 200 6743 "" "GuzzleHttp/7"

    This is a connection from the Nextcloud to the Docker Engine.

    Can you share Nextcloud logs for the Test Deploy action? There should be string that shows to which address AppAPI tries to connect to reach ExApp.

    I'm sorry, but I don't have any log entry in data/nextcloud.log file.

  10. 6 remaining items

  11. oleksandr-nc commented on May 29, 2025

    @oleksandr-nc
    Contributor

    To summurize what we have:

    1. Nextcloud instance installed on bare metal.
    2. DockerSocketProxy installed with network=host on the same machine where Nextcloud is.
    3. Docker network in the Deploy Daemon configuration in the AppAPI is host.

    Is this all correct?

  12. jirireischig commented on May 29, 2025

    @jirireischig
    Author

    Yes it is.

  13. oleksandr-nc commented on May 30, 2025

    @oleksandr-nc
    Contributor

    And forgot to ask: I assume the "Enable https" checkbox in the Deploy Daemon configuration is unchecked?

  14. jirireischig commented on May 30, 2025

    @jirireischig
    Author

    Yes it is unchecked.

  15. oleksandr-nc commented on May 30, 2025

    @oleksandr-nc
    Contributor

    From what I see, the configuration seems to be correct. We are testing something similar on GitHub actions (there is only no DSP, but direct access to the socket, but it shouldn't play a role):

    nc-host-network-host:
    runs-on: ubuntu-22.04
    name: NC In Host(network=host)
    services:
    postgres:
    image: ghcr.io/nextcloud/continuous-integration-postgres-14:latest
    ports:
    - 4444:5432/tcp
    env:
    POSTGRES_USER: root
    POSTGRES_PASSWORD: rootpassword
    POSTGRES_DB: nextcloud
    options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
    steps:
    - name: Set app env
    run: echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
    - name: Checkout server
    uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
    with:
    submodules: true
    repository: nextcloud/server
    ref: master
    - name: Checkout AppAPI
    uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
    with:
    path: apps/${{ env.APP_NAME }}
    - name: Set up php 8.3
    uses: shivammathur/setup-php@4bd44f22a98a19e0950cbad5f31095157cc9621b # v2
    with:
    php-version: 8.3
    extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, pgsql, pdo_pgsql, redis
    coverage: none
    ini-file: development
    env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    - name: Check composer file existence
    id: check_composer
    uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
    with:
    files: apps/${{ env.APP_NAME }}/composer.json
    - name: Set up dependencies
    if: steps.check_composer.outputs.files_exists == 'true'
    working-directory: apps/${{ env.APP_NAME }}
    run: composer i
    - name: Set up Nextcloud
    env:
    DB_PORT: 4444
    run: |
    mkdir data
    ./occ maintenance:install --verbose --database=pgsql --database-name=nextcloud --database-host=127.0.0.1 \
    --database-port=$DB_PORT --database-user=root --database-pass=rootpassword \
    --admin-user admin --admin-pass admin
    ./occ config:system:set loglevel --value=0 --type=integer
    ./occ config:system:set debug --value=true --type=boolean
    ./occ config:system:set overwrite.cli.url --value http://127.0.0.1:8080 --type=string
    ./occ app:enable --force ${{ env.APP_NAME }}
    - name: Test deploy
    run: |
    PHP_CLI_SERVER_WORKERS=2 php -S 127.0.0.1:8080 &
    ./occ app_api:daemon:register \
    docker_socket_local Docker docker-install http /var/run/docker.sock http://127.0.0.1:8080/index.php \
    --net=host --set-default
    ./occ app_api:daemon:list
    ./occ app_api:app:register app-skeleton-python \
    --info-xml https://github.com/raw/nextcloud/app-skeleton-python/main/appinfo/info.xml
    ./occ app_api:app:enable app-skeleton-python
    ./occ app_api:app:disable app-skeleton-python
    - name: Check logs
    run: |
    grep -q 'Hello from app-skeleton-python :)' data/nextcloud.log || error
    grep -q 'Bye bye from app-skeleton-python :(' data/nextcloud.log || error

    {"reqId":"F5XoF8qtwL9dX8epU4mg","level":2,"time":"2025-05-28T14:33:15+00:00","remoteAddr":"","user":"--","app":"app_api","method":"","url":"--","message":"Failed to update certificates in container: nc_app_test-deploy. Error: Client error: POST http://127.0.0.1:2375/v1.41/containers/nc_app_test-deploy/exec resulted in a 403 Forbidden response:\n

    403 Forbidden

    \nRequest forbidden by administrative rules.\n\n\n","userAgent":"--","version":"31.0.5.1","data":{"app":"app_api"}}

    This error is not critical (although it should not be with the latest version of DockerSocketProxy) - so it is still strange to see it.
    But we see that the container is created after this error.

    After creating the container, AppAPI should send a request to the ExApp public endpoint `http://127.0.0.1:23000:/heartbeat'

    But from the logs of test-deploy container you provided I do not see that this happen, and either there is no such records in nextcloud.log

    Can you click "Test Deploy" again and then do curl 'http://127.0.0.1:23000:/heartbeat' from the host?

    It should return {"status":"ok"}

  16. jirireischig commented on May 30, 2025

    @jirireischig
    Author

    I test curl 'http://127.0.0.1:23000:/heartbeat' and it return {"status":"ok"}

    Web browser, when i click on "deploy test", generate POST request to
    /index.php/apps/app_api/daemons/ecn_docker_local/test_deploy which end after 10 min with status code 500

    There is no tcp communcitaion to port 23000

    I dump tcp communication to 2375 port:

        4 0.000092324    127.0.0.1 → 127.0.0.1    HTTP 319 POST /v1.41/images/create?fromImage=ghcr.io%2Fnextcloud%2Ftest-deploy%3Arelease-cpu HTTP/1.1 
        6 0.553782175    127.0.0.1 → 127.0.0.1    HTTP 334 HTTP/1.1 404 Not Found 
       12 0.566455621    127.0.0.1 → 127.0.0.1    HTTP 319 POST /v1.41/images/create?fromImage=ghcr.io%2Fnextcloud%2Ftest-deploy-cpu%3Arelease HTTP/1.1 
       15 0.883537454    127.0.0.1 → 127.0.0.1    HTTP 404 HTTP/1.1 500 Internal Server Error 
       23 0.885118877    127.0.0.1 → 127.0.0.1    HTTP 315 POST /v1.41/images/create?fromImage=ghcr.io%2Fnextcloud%2Ftest-deploy%3Arelease HTTP/1.1 
       26 1.748537339    127.0.0.1 → 127.0.0.1    HTTP 1766 HTTP/1.1 200 OK 
       36 1.770399468    127.0.0.1 → 127.0.0.1    HTTP 243 GET /v1.41/containers/nc_app_test-deploy/json HTTP/1.1 
       37 1.778630522    127.0.0.1 → 127.0.0.1    HTTP 432 HTTP/1.1 404 Not Found  (application/json)
       39 1.787531455    127.0.0.1 → 127.0.0.1    HTTP 310 POST /v1.41/volumes/create HTTP/1.1  (application/json)
       40 1.796137263    127.0.0.1 → 127.0.0.1    HTTP 510 HTTP/1.1 201 Created  (application/json)
       41 1.796451614    127.0.0.1 → 127.0.0.1    HTTP 971 POST /v1.41/containers/create?name=nc_app_test-deploy HTTP/1.1  (application/json)
       42 1.823361573    127.0.0.1 → 127.0.0.1    HTTP 383 HTTP/1.1 201 Created  (application/json)
       43 1.828053544    127.0.0.1 → 127.0.0.1    HTTP 264 POST /v1.41/containers/nc_app_test-deploy/start HTTP/1.1 
       45 1.980618987    127.0.0.1 → 127.0.0.1    HTTP 246 HTTP/1.1 204 No Content 
       46 1.981273067    127.0.0.1 → 127.0.0.1    HTTP 371 POST /v1.41/containers/nc_app_test-deploy/exec HTTP/1.1  (application/json)
       48 1.992825104    127.0.0.1 → 127.0.0.1    HTTP 369 HTTP/1.1 201 Created  (application/json)
       49 1.993453285    127.0.0.1 → 127.0.0.1    HTTP 365 POST /v1.41/exec/bd520a33441d4979cecb8a19859c74cf3e69f118918ffc31c0d5bc3e21e5a574/start HTTP/1.1  (application/json)
       50 2.006584160    127.0.0.1 → 127.0.0.1    TCP 153 HTTP/1.1 200 OK  [TCP segment of a reassembled PDU]
       54 2.078008493    127.0.0.1 → 127.0.0.1    HTTP 66 HTTP/1.1 200 OK  (application/vnd.docker.raw-stream)
       60 2.093031305    127.0.0.1 → 127.0.0.1    HTTP 398 POST /v1.41/containers/nc_app_test-deploy/exec HTTP/1.1  (application/json)
       61 2.104051172    127.0.0.1 → 127.0.0.1    HTTP 369 HTTP/1.1 201 Created  (application/json)
       63 2.104421568    127.0.0.1 → 127.0.0.1    HTTP 365 POST /v1.41/exec/5e84c0e346f9056512be3b05fd62ee922b072865a1f3b6aebc4c493929d53f65/start HTTP/1.1  (application/json)
       64 2.116492110    127.0.0.1 → 127.0.0.1    TCP 153 HTTP/1.1 200 OK  [TCP segment of a reassembled PDU]
       66 2.162978581    127.0.0.1 → 127.0.0.1    HTTP 66 HTTP/1.1 200 OK 
       72 2.168139544    127.0.0.1 → 127.0.0.1    HTTP 3382 PUT /v1.41/containers/nc_app_test-deploy/archive?path=%2F HTTP/1.1  (application/x-tar)
       74 2.196193303    127.0.0.1 → 127.0.0.1    HTTP 257 HTTP/1.1 200 OK 
    
    

    And than there are a lot of repeated requests like this:

       76 2.197238087    127.0.0.1 → 127.0.0.1    HTTP 3382 PUT /v1.41/containers/nc_app_test-deploy/archive?path=%2F HTTP/1.1  (application/x-tar)
       77 2.223204212    127.0.0.1 → 127.0.0.1    HTTP 257 HTTP/1.1 200 OK 
       78 2.224595878    127.0.0.1 → 127.0.0.1    HTTP 3382 PUT /v1.41/containers/nc_app_test-deploy/archive?path=%2F HTTP/1.1  (application/x-tar)
       79 2.247801203    127.0.0.1 → 127.0.0.1    HTTP 257 HTTP/1.1 200 OK 
       80 2.248853260    127.0.0.1 → 127.0.0.1    HTTP 3894 PUT /v1.41/containers/nc_app_test-deploy/archive?path=%2F HTTP/1.1  (application/x-tar)
       81 2.279831788    127.0.0.1 → 127.0.0.1    HTTP 257 HTTP/1.1 200 OK 
    
    
    
  17. oleksandr-nc commented on May 30, 2025

    @oleksandr-nc
    Contributor

    And than there are a lot of repeated requests like this:

    Can you post requests that comes after them?

    Or you can comment this line to disable those requests, as they are not needed in your setup (we probably should do them as an option).

  18. jirireischig commented on May 30, 2025

    @jirireischig
    Author

    Another test look like this:

        4 0.000094608    127.0.0.1 → 127.0.0.1    HTTP 319 POST /v1.41/images/create?fromImage=ghcr.io%2Fnextcloud%2Ftest-deploy%3Arelease-cpu HTTP/1.1 
        6 0.538062248    127.0.0.1 → 127.0.0.1    HTTP 334 HTTP/1.1 404 Not Found 
       12 0.547923956    127.0.0.1 → 127.0.0.1    HTTP 319 POST /v1.41/images/create?fromImage=ghcr.io%2Fnextcloud%2Ftest-deploy-cpu%3Arelease HTTP/1.1 
       15 0.878721673    127.0.0.1 → 127.0.0.1    HTTP 404 HTTP/1.1 500 Internal Server Error 
       23 0.880159225    127.0.0.1 → 127.0.0.1    HTTP 315 POST /v1.41/images/create?fromImage=ghcr.io%2Fnextcloud%2Ftest-deploy%3Arelease HTTP/1.1 
       26 1.812802083    127.0.0.1 → 127.0.0.1    HTTP 1778 HTTP/1.1 200 OK 
       36 1.832731397    127.0.0.1 → 127.0.0.1    HTTP 243 GET /v1.41/containers/nc_app_test-deploy/json HTTP/1.1 
       37 1.840789145    127.0.0.1 → 127.0.0.1    HTTP 432 HTTP/1.1 404 Not Found  (application/json)
       39 1.847666253    127.0.0.1 → 127.0.0.1    HTTP 310 POST /v1.41/volumes/create HTTP/1.1  (application/json)
       40 1.856166192    127.0.0.1 → 127.0.0.1    HTTP 510 HTTP/1.1 201 Created  (application/json)
       41 1.856468490    127.0.0.1 → 127.0.0.1    HTTP 970 POST /v1.41/containers/create?name=nc_app_test-deploy HTTP/1.1  (application/json)
       42 1.882698649    127.0.0.1 → 127.0.0.1    HTTP 383 HTTP/1.1 201 Created  (application/json)
       43 1.905553003    127.0.0.1 → 127.0.0.1    HTTP 264 POST /v1.41/containers/nc_app_test-deploy/start HTTP/1.1 
       45 2.080350269    127.0.0.1 → 127.0.0.1    HTTP 246 HTTP/1.1 204 No Content 
       46 2.116996809    127.0.0.1 → 127.0.0.1    HTTP 243 GET /v1.41/containers/nc_app_test-deploy/json HTTP/1.1 
       48 2.129653242    127.0.0.1 → 127.0.0.1    HTTP 7052 HTTP/1.1 200 OK  (application/json)
       50 2.136224244    127.0.0.1 → 127.0.0.1    HTTP 243 GET /v1.41/containers/nc_app_test-deploy/json HTTP/1.1 
       51 2.145641848    127.0.0.1 → 127.0.0.1    HTTP 7052 HTTP/1.1 200 OK  (application/json)
      148 34.475046339    127.0.0.1 → 127.0.0.1    HTTP 243 GET /v1.41/containers/nc_app_test-deploy/json HTTP/1.1 
      149 34.484915893    127.0.0.1 → 127.0.0.1    HTTP 7052 HTTP/1.1 200 OK  (application/json)
    ...
     1831 601.057900306    127.0.0.1 → 127.0.0.1    HTTP 243 GET /v1.41/containers/nc_app_test-deploy/json HTTP/1.1 
     1832 601.067293003    127.0.0.1 → 127.0.0.1    HTTP 7052 HTTP/1.1 200 OK  (application/json)
     1837 601.254137437    127.0.0.1 → 127.0.0.1    HTTP 252 DELETE /v1.41/containers/nc_app_test-deploy?force=true HTTP/1.1 
     1839 601.800239568    127.0.0.1 → 127.0.0.1    HTTP 246 HTTP/1.1 204 No Content 
     1844 602.067721689    127.0.0.1 → 127.0.0.1    HTTP 243 GET /v1.41/containers/nc_app_test-deploy/json HTTP/1.1 
     1845 602.075844058    127.0.0.1 → 127.0.0.1    HTTP 432 HTTP/1.1 404 Not Found  (application/json)
    ...
     2759 909.675963436    127.0.0.1 → 127.0.0.1    HTTP 243 GET /v1.41/containers/nc_app_test-deploy/json HTTP/1.1 
     2760 909.683849409    127.0.0.1 → 127.0.0.1    HTTP 432 HTTP/1.1 404 Not Found  (application/json)
    
    
  19. oleksandr-nc commented on Jun 3, 2025

    @oleksandr-nc
    Contributor

    I have a hard time understanding what is going on and why some entries are missing from the logs.

    Here is the part of the source code we need:

    if ($daemonConfig->getAcceptsDeployId() === $this->dockerActions->getAcceptsDeployId()) {
    $deployParams = $this->dockerActions->buildDeployParams($daemonConfig, $appInfo);
    $deployResult = $this->dockerActions->deployExApp($exApp, $daemonConfig, $deployParams);
    if ($deployResult) {
    $this->logger->error(sprintf('ExApp %s deployment failed. Error: %s', $appId, $deployResult));
    if ($outputConsole) {
    $output->writeln(sprintf('ExApp %s deployment failed. Error: %s', $appId, $deployResult));
    }
    $this->exAppService->setStatusError($exApp, $deployResult);
    $this->_unregisterExApp($appId, $isTestDeployMode);
    return 1;
    }
    if (!$this->dockerActions->healthcheckContainer($this->dockerActions->buildExAppContainerName($appId), $daemonConfig, true)) {
    $this->logger->error(sprintf('ExApp %s deployment failed. Error: %s', $appId, 'Container healthcheck failed.'));
    if ($outputConsole) {
    $output->writeln(sprintf('ExApp %s deployment failed. Error: %s', $appId, 'Container healthcheck failed.'));
    }
    $this->exAppService->setStatusError($exApp, 'Container healthcheck failed');
    return 1;
    }
    $exAppUrl = $this->dockerActions->resolveExAppUrl(
    $appId,
    $daemonConfig->getProtocol(),
    $daemonConfig->getHost(),
    $daemonConfig->getDeployConfig(),
    (int)explode('=', $deployParams['container_params']['env'][6])[1],
    $auth,
    );
    } else {
    $this->manualActions->deployExApp($exApp, $daemonConfig);
    $exAppUrl = $this->manualActions->resolveExAppUrl(
    $appId,
    $daemonConfig->getProtocol(),
    $daemonConfig->getHost(),
    $daemonConfig->getDeployConfig(),
    (int) $appInfo['port'],
    $auth,
    );
    }
    if (!$this->service->heartbeatExApp($exAppUrl, $auth, $appId)) {
    $this->logger->error(sprintf('ExApp %s heartbeat check failed. Make sure that Nextcloud instance and ExApp can reach it other.', $appId));
    if ($outputConsole) {
    $output->writeln(sprintf('ExApp %s heartbeat check failed. Make sure that Nextcloud instance and ExApp can reach it other.', $appId));
    }
    $this->exAppService->setStatusError($exApp, 'Heartbeat check failed');
    return 1;
    }
    $this->logger->info(sprintf('ExApp %s deployed successfully.', $appId));
    if ($outputConsole) {
    $output->writeln(sprintf('ExApp %s deployed successfully.', $appId));
    }

    We see requests in a circle:

    HTTP 243 GET /v1.41/containers/nc_app_test-deploy/json HTTP/1.1

    As far as I understand, everything fails in this functions:

    public function healthcheckContainer(string $containerId, DaemonConfig $daemonConfig, bool $waitForSuccess): bool {
    $dockerUrl = $this->buildDockerUrl($daemonConfig);
    $containerInfo = $this->inspectContainer($dockerUrl, $containerId);
    if (!isset($containerInfo['State']['Health']['Status'])) {
    return true; // container does not support Healthcheck
    }
    if (!$waitForSuccess) {
    return $containerInfo['State']['Health']['Status'] === 'healthy';
    }
    $maxTotalAttempts = 900;
    while ($maxTotalAttempts > 0) {
    $containerInfo = $this->inspectContainer($dockerUrl, $containerId);
    if ($containerInfo['State']['Health']['Status'] === 'healthy') {
    return true;
    }
    if ($containerInfo['State']['Health']['Status'] === 'unhealthy') {
    return false;
    }
    $maxTotalAttempts--;
    sleep(1);
    }
    return false;
    }

    Why then we do not see the lines Container healthcheck failed. in the log or console - I do not understand..

  20. jirireischig commented on Jun 3, 2025

    @jirireischig
    Author

    I don't known, why there is nothing in log, but I find the problem. Thank you for your help.

    Function healthcheckContainer is looking for ['State']['Health']['Status'] === 'healthy' in json answer from GET /v1.41/containers/nc_app_test-deploy/json.

    But this is empty:

    {
      "Id": "537c2e9faa8541d317e3f02623db1dcbd483b9ef022a4d6582e85c9dc1766cea",
      "Created": "2025-05-28T14:12:56.33722341Z",
      "Path": "/start.sh",
      "Args": [
        "/start.sh"
      ],
      "State": {
        "Status": "running",
        "Running": true,
        "Paused": false,
        "Restarting": false,
        "OOMKilled": false,
        "Dead": false,
        "Pid": 624447,
        "ExitCode": 0,
        "Error": "",
        "StartedAt": "2025-05-28T14:13:06.806346947Z",
        "FinishedAt": "2025-05-28T14:13:06.600476924Z",
        "Health": {
          "Status": "",
          "FailingStreak": 0,
          "Log": null
        }
      },
    ...
    

    I don't known if it is differences between Docker and Podman or it's depending on version or ???

    Simple dirty solution is add one more test to the function like this:

            public function healthcheckContainer(string $containerId, DaemonConfig $daemonConfig, bool $waitForSuccess): bool {
                    $dockerUrl = $this->buildDockerUrl($daemonConfig);
                    $containerInfo = $this->inspectContainer($dockerUrl, $containerId);
                    if (!isset($containerInfo['State']['Health']['Status'])) {
                            return true;  // container does not support Healthcheck
                    }
                    if (!$waitForSuccess) {
                            return $containerInfo['State']['Health']['Status'] === 'healthy';
                    }
                    $maxTotalAttempts = 900;
                    while ($maxTotalAttempts > 0) {
                            $containerInfo = $this->inspectContainer($dockerUrl, $containerId);
                            if ($containerInfo['State']['Health']['Status'] === 'healthy') {
                                    return true;
                            }
                            if ($containerInfo['State']['Health']['Status'] === 'unhealthy') {
                                    return false;
                            }
                            if ($containerInfo['State']['Health']['Status'] === '') {
                                    return true;
                            }
                            $maxTotalAttempts--;
                            sleep(1);
                    }
                    return false;
            }
    
    
  21. oleksandr-nc commented on Jun 4, 2025

    @oleksandr-nc
    Contributor

    Thanks a lot to you for helping triaging this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions