fix: Gitea Traefik routing and connection pool optimization
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Failing after 10m14s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Has been skipped
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
Security Vulnerability Scan / Check for Dependency Changes (push) Failing after 11m25s
Security Vulnerability Scan / Composer Security Audit (push) Has been cancelled

- Remove middleware reference from Gitea Traefik labels (caused routing issues)
- Optimize Gitea connection pool settings (MAX_IDLE_CONNS=30, authentication_timeout=180s)
- Add explicit service reference in Traefik labels
- Fix intermittent 504 timeouts by improving PostgreSQL connection handling

Fixes Gitea unreachability via git.michaelschiemer.de
This commit is contained in:
2025-11-09 14:46:15 +01:00
parent 85c369e846
commit 36ef2a1e2c
1366 changed files with 104925 additions and 28719 deletions

View File

@@ -20,6 +20,17 @@ use RuntimeException;
*/
describe('ErrorKernel HTTP Response Generation', function () {
beforeEach(function () {
// Mock $_SERVER for API detection
$_SERVER['HTTP_ACCEPT'] = 'application/json';
$_SERVER['REQUEST_URI'] = '/api/test';
});
afterEach(function () {
// Cleanup
unset($_SERVER['HTTP_ACCEPT'], $_SERVER['REQUEST_URI']);
});
it('creates JSON API error response without context', function () {
$errorKernel = new ErrorKernel();
$exception = new RuntimeException('Test API error', 500);
@@ -27,7 +38,7 @@ describe('ErrorKernel HTTP Response Generation', function () {
$response = $errorKernel->createHttpResponse($exception, null, isDebugMode: false);
expect($response->status)->toBe(Status::INTERNAL_SERVER_ERROR);
expect($response->headers['Content-Type'])->toBe('application/json');
expect($response->headers->getFirst('Content-Type'))->toBe('application/json');
$body = json_decode($response->body, true);
expect($body['error']['message'])->toBe('An error occurred while processing your request.');
@@ -64,7 +75,7 @@ describe('ErrorKernel HTTP Response Generation', function () {
occurredAt: new \DateTimeImmutable(),
metadata: ['user_email' => 'test@example.com']
);
$contextProvider->set($exception, $contextData);
$contextProvider->attach($exception, $contextData);
$response = $errorKernel->createHttpResponse($exception, $contextProvider, isDebugMode: true);
@@ -94,7 +105,7 @@ describe('ResponseErrorRenderer', function () {
$response = $renderer->createResponse($exception, null);
expect($response->headers['Content-Type'])->toBe('application/json');
expect($response->headers->getFirst('Content-Type'))->toBe('application/json');
});
it('creates HTML response for non-API requests', function () {
@@ -107,7 +118,7 @@ describe('ResponseErrorRenderer', function () {
$response = $renderer->createResponse($exception, null);
expect($response->headers['Content-Type'])->toBe('text/html; charset=utf-8');
expect($response->headers->getFirst('Content-Type'))->toBe('text/html; charset=utf-8');
expect($response->body)->toContain('<!DOCTYPE html>');
expect($response->body)->toContain('An error occurred while processing your request.');
});
@@ -126,7 +137,7 @@ describe('ResponseErrorRenderer', function () {
requestId: 'req-67890',
occurredAt: new \DateTimeImmutable()
);
$contextProvider->set($exception, $contextData);
$contextProvider->attach($exception, $contextData);
$response = $renderer->createResponse($exception, $contextProvider);
@@ -168,7 +179,7 @@ describe('ExceptionContextProvider WeakMap functionality', function () {
occurredAt: new \DateTimeImmutable()
);
$contextProvider->set($exception, $contextData);
$contextProvider->attach($exception, $contextData);
$retrieved = $contextProvider->get($exception);
expect($retrieved)->not->toBeNull();
@@ -197,7 +208,7 @@ describe('ExceptionContextProvider WeakMap functionality', function () {
occurredAt: new \DateTimeImmutable()
);
$contextProvider->set($exception, $contextData);
$contextProvider->attach($exception, $contextData);
// Verify context exists
expect($contextProvider->get($exception))->not->toBeNull();
@@ -223,16 +234,16 @@ describe('Context enrichment with boundary metadata', function () {
requestId: 'req-abc',
occurredAt: new \DateTimeImmutable()
);
$contextProvider->set($exception, $initialContext);
$contextProvider->attach($exception, $initialContext);
// ErrorBoundary enriches with boundary metadata
$existingContext = $contextProvider->get($exception);
$enrichedContext = $existingContext->withMetadata([
$enrichedContext = $existingContext->addMetadata([
'error_boundary' => 'user_boundary',
'boundary_failure' => true,
'fallback_executed' => true
]);
$contextProvider->set($exception, $enrichedContext);
$contextProvider->attach($exception, $enrichedContext);
// Retrieve and verify enriched context
$finalContext = $contextProvider->get($exception);
@@ -251,17 +262,17 @@ describe('Context enrichment with boundary metadata', function () {
requestId: 'req-http-123',
occurredAt: new \DateTimeImmutable()
);
$contextProvider->set($exception, $initialContext);
$contextProvider->attach($exception, $initialContext);
// Enrich with HTTP-specific fields
$existingContext = $contextProvider->get($exception);
$enrichedContext = $existingContext->withMetadata([
$enrichedContext = $existingContext->addMetadata([
'client_ip' => '192.168.1.100',
'user_agent' => 'Mozilla/5.0',
'http_method' => 'POST',
'request_uri' => '/api/users'
]);
$contextProvider->set($exception, $enrichedContext);
$contextProvider->attach($exception, $enrichedContext);
// Verify both original and enriched data
$finalContext = $contextProvider->get($exception);
@@ -273,6 +284,17 @@ describe('Context enrichment with boundary metadata', function () {
});
describe('End-to-end integration scenario', function () {
beforeEach(function () {
// Mock $_SERVER for API detection
$_SERVER['HTTP_ACCEPT'] = 'application/json';
$_SERVER['REQUEST_URI'] = '/api/test';
});
afterEach(function () {
// Cleanup
unset($_SERVER['HTTP_ACCEPT'], $_SERVER['REQUEST_URI']);
});
it('demonstrates full exception handling flow with context enrichment', function () {
// Setup
$errorKernel = new ErrorKernel();
@@ -289,24 +311,24 @@ describe('End-to-end integration scenario', function () {
occurredAt: new \DateTimeImmutable(),
metadata: ['user_email' => 'test@example.com']
);
$contextProvider->set($exception, $serviceContext);
$contextProvider->attach($exception, $serviceContext);
// 3. ErrorBoundary catches and enriches with boundary metadata
$boundaryContext = $contextProvider->get($exception)->withMetadata([
$boundaryContext = $contextProvider->get($exception)->addMetadata([
'error_boundary' => 'user_registration_boundary',
'boundary_failure' => true,
'fallback_executed' => false
]);
$contextProvider->set($exception, $boundaryContext);
$contextProvider->attach($exception, $boundaryContext);
// 4. HTTP layer enriches with request metadata
$httpContext = $contextProvider->get($exception)->withMetadata([
$httpContext = $contextProvider->get($exception)->addMetadata([
'client_ip' => '203.0.113.42',
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0)',
'http_method' => 'POST',
'request_uri' => '/api/users/register'
]);
$contextProvider->set($exception, $httpContext);
$contextProvider->attach($exception, $httpContext);
// 5. ErrorKernel generates HTTP response
$response = $errorKernel->createHttpResponse($exception, $contextProvider, isDebugMode: true);
@@ -323,6 +345,6 @@ describe('End-to-end integration scenario', function () {
// Metadata can be accessed programmatically via $contextProvider->get($exception)->metadata
expect($response->status)->toBe(Status::INTERNAL_SERVER_ERROR);
expect($response->headers['Content-Type'])->toBe('application/json');
expect($response->headers->getFirst('Content-Type'))->toBe('application/json');
});
});