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

Allow networks to be created pre-emptively #3129

Closed
wants to merge 1 commit into from

Conversation

jennydaman
Copy link

Currently, nextcloud-aio-mastercontainer will crash if the nextcloud-aio network already exists. This PR changes the behavior so that the nextcloud-aio network may be created preemptively.

I did this as a workaround to a bug in rootless Podman: containers/podman#19577

Copy link
Collaborator

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, however podman should return error code 409 if the network already exists. See containers/podman#15499 and

if ($e->getCode() !== 409) {

@szaimen szaimen closed this Aug 10, 2023
@jennydaman
Copy link
Author

This patch is needed for Nextcloud-AIO to work with Podman version 4.6.0. The most recent reply to containers/podman#15499 was 7 months ago, yet no related change has landed in Podman yet.

If my setup breaks in the future, would you like me to submit another PR?

@szaimen
Copy link
Collaborator

szaimen commented Aug 10, 2023

Can you tell which error code is returned if the network already exists? Before the bug was fixed it was 500 if I remember correctly. Now it should in theory be 409 but apparently it is not...

@jennydaman
Copy link
Author

diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php
index 93abcdc..a3350d6 100644
--- a/php/src/Docker/DockerActionManager.php
+++ b/php/src/Docker/DockerActionManager.php
@@ -788,7 +788,8 @@ class DockerActionManager
                 $responseBody = json_decode((string)$response->getBody(), true);
                 $connectedNetworks = $responseBody['NetworkSettings']['Networks'];
                 if (array_key_exists($network, $connectedNetworks)) {
-                    return;
+                    error_log(sprintf("IAMHERE: THE ERROR IS %s", $e));
+                    //return;
                 }
             } catch (RequestException $e) {
                 // do nothing
logs
Aug 10 03:14:52 ferritin podman[97425]: time="2023-08-10T03:14:52-04:00" level=info msg="Request Failed(Conflict): network name nextcloud-aio already used: network already exists"Aug 10 03:14:52 ferritin podman[97425]: @ - - [10/Aug/2023:03:14:52 -0400] "POST /v1.41/networks/create HTTP/1.1" 409 126 "" "GuzzleHttp/7"Aug 10 03:14:52 ferritin podman[97425]: @ - - [10/Aug/2023:03:14:52 -0400] "GET /v1.41/containers/nextcloud-aio-mastercontainer/json HTTP/1.1" 200 9047 "" "GuzzleHttp/7"Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: NOTICE: PHP message: IAMHERE: THE ERROR IS GuzzleHttp\Exception\ClientException: Client error: `POST http://localhost/v1.41/networks/create` resulted in a `409 Conflict` response:Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: {"cause":"network already exists","message":"network name nextcloud-aio already used: network already exists","response" (truncated...)Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]:  in /var/www/docker-aio/php/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: Stack trace:Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #0 /var/www/docker-aio/php/vendor/guzzlehttp/guzzle/src/Middleware.php(72): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response), NULL, Array, NULL)Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #1 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(209): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))Aug 10 03:14:52 ferritin podman[97425]: time="2023-08-10T03:14:52-04:00" level=info msg="Request Failed(Internal Server Error): container c7739a6568dc622696883126dba4eb3127d4e99952d8ca9faf164f1b30ac889f is already connected to network \"nextcloud-aio\": network is already connected"Aug 10 03:14:52 ferritin podman[97425]: @ - - [10/Aug/2023:03:14:52 -0400] "POST /v1.41/networks/nextcloud-aio/connect HTTP/1.1" 500 223 "" "GuzzleHttp/7"Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #2 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(158): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #3 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/TaskQueue.php(52): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #4 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(251): GuzzleHttp\Promise\TaskQueue->run(true)Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #5 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(227): GuzzleHttp\Promise\Promise->invokeWaitFn()Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #6 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(272): GuzzleHttp\Promise\Promise->waitIfPending()Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #7 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(229): GuzzleHttp\Promise\Promise->invokeWaitList()Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #8 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(69): GuzzleHttp\Promise\Promise->waitIfPending()Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #9 /var/www/docker-aio/php/vendor/guzzlehttp/guzzle/src/Client.php(189): GuzzleHttp\Promise\Promise->wait()Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #10 /var/www/docker-aio/php/src/Docker/DockerActionManager.php(766): GuzzleHttp\Client->request('POST', 'http://localhos...', Array)Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #11 /var/www/docker-aio/php/src/Docker/DockerActionManager.php(822): AIO\Docker\DockerActionManager->ConnectContainerIdToNetwork('nextcloud-aio-m...', '')Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #12 /var/www/docker-aio/php/public/index.php(80): AIO\Docker\DockerActionManager->ConnectMasterContainerToNetwork()Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #13 /var/www/docker-aio/php/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(38): Closure->{closure}(Object(GuzzleHttp\Psr7\ServerRequest), Object(GuzzleHttp\Psr7\Response), Array)Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #14 /var/www/docker-aio/php/vendor/slim/slim/Slim/Routing/Route.php(358): Slim\Handlers\Strategies\RequestResponse->__invoke(Object(Closure), Object(GuzzleHttp\Psr7\ServerRequest), Object(GuzzleHttp\Psr7\Response), Array)Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #15 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\Routing\Route->handle(Object(GuzzleHttp\Psr7\ServerRequest))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #16 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\MiddlewareDispatcher->handle(Object(GuzzleHttp\Psr7\ServerRequest))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #17 /var/www/docker-aio/php/vendor/slim/slim/Slim/Routing/Route.php(315): Slim\MiddlewareDispatcher->handle(Object(GuzzleHttp\Psr7\ServerRequest))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #18 /var/www/docker-aio/php/vendor/slim/slim/Slim/Routing/RouteRunner.php(68): Slim\Routing\Route->run(Object(GuzzleHttp\Psr7\ServerRequest))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #19 /var/www/docker-aio/php/vendor/slim/csrf/src/Guard.php(476): Slim\Routing\RouteRunner->handle(Object(GuzzleHttp\Psr7\ServerRequest))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #20 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(168): Slim\Csrf\Guard->process(Object(GuzzleHttp\Psr7\ServerRequest), Object(Slim\Routing\RouteRunner))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #21 /var/www/docker-aio/php/vendor/slim/twig-view/src/TwigMiddleware.php(115): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #22 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Views\TwigMiddleware->process(Object(GuzzleHttp\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #23 /var/www/docker-aio/php/src/Middleware/AuthMiddleware.php(38): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #24 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(269): AIO\Middleware\AuthMiddleware->__invoke(Object(GuzzleHttp\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #25 /var/www/docker-aio/php/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(76): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #26 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\ErrorMiddleware->process(Object(GuzzleHttp\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #27 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #28 /var/www/docker-aio/php/vendor/slim/slim/Slim/App.php(199): Slim\MiddlewareDispatcher->handle(Object(GuzzleHttp\Psr7\ServerRequest))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #29 /var/www/docker-aio/php/vendor/slim/slim/Slim/App.php(183): Slim\App->handle(Object(GuzzleHttp\Psr7\ServerRequest))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #30 /var/www/docker-aio/php/public/index.php(181): Slim\App->run()Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #31 {main}Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: NOTICE: PHP message: Slim Application ErrorAug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: Type: GuzzleHttp\Exception\ServerExceptionAug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: Code: 500Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: Message: Server error: `POST http://localhost/v1.41/networks/nextcloud-aio/connect` resulted in a `500 Internal Server Error` response:Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: {"cause":"network is already connected","message":"container c7739a6568dc622696883126dba4eb3127d4e99952d8ca9faf164f1b30a (truncated...)Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: File: /var/www/docker-aio/php/vendor/guzzlehttp/guzzle/src/Exception/RequestException.phpAug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: Line: 113Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: Trace: #0 /var/www/docker-aio/php/vendor/guzzlehttp/guzzle/src/Middleware.php(72): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response), NULL, Array, NULL)Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #1 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(209): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #2 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(158): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #3 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/TaskQueue.php(52): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #4 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(251): GuzzleHttp\Promise\TaskQueue->run(true)
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #5 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(227): GuzzleHttp\Promise\Promise->invokeWaitFn()
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #6 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(272): GuzzleHttp\Promise\Promise->waitIfPending()
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #7 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(229): GuzzleHttp\Promise\Promise->invokeWaitList()
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #8 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(69): GuzzleHttp\Promise\Promise->waitIfPending()
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #9 /var/www/docker-aio/php/vendor/guzzlehttp/guzzle/src/Client.php(189): GuzzleHttp\Promise\Promise->wait()
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #10 /var/www/docker-aio/php/src/Docker/DockerActionManager.php(803): GuzzleHttp\Client->request('POST', 'http://localhos...', Array)
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #11 /var/www/docker-aio/php/src/Docker/DockerActionManager.php(822): AIO\Docker\DockerActionManager->ConnectContainerIdToNetwork('nextcloud-aio-m...', '')
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #12 /var/www/docker-aio/php/public/index.php(80): AIO\Docker\DockerActionManager->ConnectMasterContainerToNetwork()
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #13 /var/www/docker-aio/php/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(38): Closure->{closure}(Object(GuzzleHttp\Psr7\ServerRequest), Object(GuzzleHttp\Psr7\Response), Array)
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #14 /var/www/docker-aio/php/vendor/slim/slim/Slim/Routing/Route.php(358): Slim\Handlers\Strategies\RequestResponse->__invoke(Object(Closure), Object(GuzzleHttp\Psr7\ServerRequest), Object(GuzzleHttp\Psr7\Response), Array)
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #15 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\Routing\Route->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #16 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\MiddlewareDispatcher->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #17 /var/www/docker-aio/php/vendor/slim/slim/Slim/Routing/Route.php(315): Slim\MiddlewareDispatcher->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #18 /var/www/docker-aio/php/vendor/slim/slim/Slim/Routing/RouteRunner.php(68): Slim\Routing\Route->run(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #19 /var/www/docker-aio/php/vendor/slim/csrf/src/Guard.php(476): Slim\Routing\RouteRunner->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #20 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(168): Slim\Csrf\Guard->process(Object(GuzzleHttp\Psr7\ServerRequest), Object(Slim\Routing\RouteRunner))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #21 /var/www/docker-aio/php/vendor/slim/twig-view/src/TwigMiddleware.php(115): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #22 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Views\TwigMiddleware->process(Object(GuzzleHttp\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #23 /var/www/docker-aio/php/src/Middleware/AuthMiddleware.php(38): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #24 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(269): AIO\Middleware\AuthMiddleware->__invoke(Object(GuzzleHttp\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #25 /var/www/docker-aio/php/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(76): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #26 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\ErrorMiddleware->process(Object(GuzzleHttp\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #27 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #28 /var/www/docker-aio/php/vendor/slim/slim/Slim/App.php(199): Slim\MiddlewareDispatcher->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #29 /var/www/docker-aio/php/vendor/slim/slim/Slim/App.php(183): Slim\App->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #30 /var/www/docker-aio/php/public/index.php(181): Slim\App->run()
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #31 {main}
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: Tips: To display error details in HTTP response set "displayErrorDetails" to true in the ErrorHandler constructor.
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: NOTICE: PHP message: 404 Not Found
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: Type: Slim\Exception\HttpNotFoundException
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: Code: 404
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: Message: Not found.
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: File: /var/www/docker-aio/php/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: Line: 76
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: Trace: #0 /var/www/docker-aio/php/vendor/slim/slim/Slim/Routing/RouteRunner.php(56): Slim\Middleware\RoutingMiddleware->performRouting(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #1 /var/www/docker-aio/php/vendor/slim/csrf/src/Guard.php(476): Slim\Routing\RouteRunner->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #2 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(168): Slim\Csrf\Guard->process(Object(GuzzleHttp\Psr7\ServerRequest), Object(Slim\Routing\RouteRunner))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #3 /var/www/docker-aio/php/vendor/slim/twig-view/src/TwigMiddleware.php(115): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #4 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Views\TwigMiddleware->process(Object(GuzzleHttp\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #5 /var/www/docker-aio/php/src/Middleware/AuthMiddleware.php(38): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #6 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(269): AIO\Middleware\AuthMiddleware->__invoke(Object(GuzzleHttp\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #7 /var/www/docker-aio/php/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(76): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #8 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\ErrorMiddleware->process(Object(GuzzleHttp\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #9 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #10 /var/www/docker-aio/php/vendor/slim/slim/Slim/App.php(199): Slim\MiddlewareDispatcher->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #11 /var/www/docker-aio/php/vendor/slim/slim/Slim/App.php(183): Slim\App->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #12 /var/www/docker-aio/php/public/index.php(181): Slim\App->run()
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: #13 {main}
Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: Tips: To display error details in HTTP response set "displayErrorDetails" to true in the ErrorHandler constructor.

@szaimen
Copy link
Collaborator

szaimen commented Aug 10, 2023

No I meant what error code is thrown here if the network should already exist?

@jennydaman
Copy link
Author

$e is caught and printed out by

error_log(sprintf("IAMHERE: THE ERROR IS %s", $e));

The specific log line is

IAMHERE: THE ERROR IS GuzzleHttp\Exception\ClientException: Client error: `POST http://localhost/v1.41/networks/create` resulted in a `409 Conflict` response:Aug 10 03:14:52 ferritin nextcloud-aio-mastercontainer[96945]: {"cause":"network already exists","message":"network name nextcloud-aio already used: network already exists","response" (truncated...)

@szaimen
Copy link
Collaborator

szaimen commented Aug 10, 2023

Ah I see. However since the error code is 409, AIO should not throw, right?

@jennydaman
Copy link
Author

That is correct.

Since the error code is 409, $e is caught and not thrown again, and execution proceeds to the code I added which handles the pre-existing network.

@szaimen
Copy link
Collaborator

szaimen commented Aug 10, 2023

This is what I am wondering about: if the network already exists, it should return 409 and then not throw an error anymore. So why does it do on podman but not on docker?

@jennydaman
Copy link
Author

jennydaman commented Aug 10, 2023

Oh, I left out some information. My bad.

The error with network creation is handled correctly, however the error fails later on here:

$url = $this->BuildApiUrl(
sprintf('networks/%s/connect', $network)
);
try {
$this->guzzleClient->request(
'POST',
$url,
[
'json' => [
'container' => $id,
]
]
);
} catch (RequestException $e) {
// 403 is undocumented and gets thrown if a specific container is already part of a network
if ($e->getCode() !== 403) {
throw $e;
}
}

This is because of the linked Podman bug: containers/podman#19577

logs
Aug 09 23:43:17 ferritin podman[15700]: time="2023-08-09T23:43:17-04:00" level=info msg="Request Failed(Internal Server Error): \"slirp4netns\" is not supported: invalid network mode"
Aug 09 23:43:17 ferritin podman[15700]: @ - - [09/Aug/2023:23:43:17 -0400] "POST /v1.41/networks/nextcloud-aio/connect HTTP/1.1" 500 115 "" "GuzzleHttp/7"
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: NOTICE: PHP message: Slim Application Error
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: Type: GuzzleHttp\Exception\ServerException
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: Code: 500
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: Message: Server error: `POST http://localhost/v1.41/networks/nextcloud-aio/connect` resulted in a `500 Internal Server Error` response:
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: {"cause":"invalid network mode","message":"\"slirp4netns\" is not supported: invalid network mode","response":500}
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: File: /var/www/docker-aio/php/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: Line: 113
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: Trace: #0 /var/www/docker-aio/php/vendor/guzzlehttp/guzzle/src/Middleware.php(72): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response), NULL, Array, NULL)
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #1 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(209): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #2 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(158): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #3 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/TaskQueue.php(52): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #4 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(251): GuzzleHttp\Promise\TaskQueue->run(true)
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #5 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(227): GuzzleHttp\Promise\Promise->invokeWaitFn()
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #6 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(272): GuzzleHttp\Promise\Promise->waitIfPending()
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #7 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(229): GuzzleHttp\Promise\Promise->invokeWaitList()
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #8 /var/www/docker-aio/php/vendor/guzzlehttp/promises/src/Promise.php(69): GuzzleHttp\Promise\Promise->waitIfPending()
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #9 /var/www/docker-aio/php/vendor/guzzlehttp/guzzle/src/Client.php(189): GuzzleHttp\Promise\Promise->wait()
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #10 /var/www/docker-aio/php/src/Docker/DockerActionManager.php(784): GuzzleHttp\Client->request('POST', 'http://localhos...', Array)
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #11 /var/www/docker-aio/php/src/Docker/DockerActionManager.php(803): AIO\Docker\DockerActionManager->ConnectContainerIdToNetwork('nextcloud-aio-m...', '')
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #12 /var/www/docker-aio/php/public/index.php(80): AIO\Docker\DockerActionManager->ConnectMasterContainerToNetwork()
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #13 /var/www/docker-aio/php/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(38): Closure->{closure}(Object(GuzzleHttp\Psr7\ServerRequest), Object(GuzzleHttp\Psr7\Response), Array)
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #14 /var/www/docker-aio/php/vendor/slim/slim/Slim/Routing/Route.php(358): Slim\Handlers\Strategies\RequestResponse->__invoke(Object(Closure), Object(GuzzleHttp\Psr7\ServerRequest), Object(GuzzleHttp\Psr7\Response), Array)
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #15 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\Routing\Route->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #16 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\MiddlewareDispatcher->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #17 /var/www/docker-aio/php/vendor/slim/slim/Slim/Routing/Route.php(315): Slim\MiddlewareDispatcher->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #18 /var/www/docker-aio/php/vendor/slim/slim/Slim/Routing/RouteRunner.php(68): Slim\Routing\Route->run(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #19 /var/www/docker-aio/php/vendor/slim/csrf/src/Guard.php(476): Slim\Routing\RouteRunner->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #20 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(168): Slim\Csrf\Guard->process(Object(GuzzleHttp\Psr7\ServerRequest), Object(Slim\Routing\RouteRunner))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #21 /var/www/docker-aio/php/vendor/slim/twig-view/src/TwigMiddleware.php(115): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #22 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Views\TwigMiddleware->process(Object(GuzzleHttp\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #23 /var/www/docker-aio/php/src/Middleware/AuthMiddleware.php(38): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #24 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(269): AIO\Middleware\AuthMiddleware->__invoke(Object(GuzzleHttp\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #25 /var/www/docker-aio/php/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(76): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #26 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\ErrorMiddleware->process(Object(GuzzleHttp\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #27 /var/www/docker-aio/php/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #28 /var/www/docker-aio/php/vendor/slim/slim/Slim/App.php(199): Slim\MiddlewareDispatcher->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #29 /var/www/docker-aio/php/vendor/slim/slim/Slim/App.php(183): Slim\App->handle(Object(GuzzleHttp\Psr7\ServerRequest))
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #30 /var/www/docker-aio/php/public/index.php(181): Slim\App->run()
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: #31 {main}
Aug 09 23:43:17 ferritin nextcloud-aio-mastercontainer[15001]: Tips: To display error details in HTTP response set "displayErrorDetails" to true in the ErrorHandler constructor.

@szaimen
Copy link
Collaborator

szaimen commented Aug 10, 2023

This is because of the linked Podman bug: containers/podman#19577

Ah I see. Since this apparently is a Podman bug, I would rather not like to merge your change into AIO as podman is not supported by us anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants