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

@@ -10,12 +10,12 @@ use App\Framework\ApiGateway\ValueObjects\ApiEndpoint;
use App\Framework\Core\ValueObjects\Duration;
use App\Framework\Http\Headers;
use App\Framework\Http\Method as HttpMethod;
use App\Framework\Http\Url\Url;
use App\Framework\Http\Url\WhatwgUrl;
use App\Framework\HttpClient\AuthConfig;
use App\Framework\HttpClient\ClientRequest;
use App\Framework\HttpClient\ClientResponse;
use App\Framework\HttpClient\HttpClient;
use App\Framework\HttpClient\Status;
use App\Framework\Http\Status;
use App\Framework\Retry\RetryStrategy;
describe('ApiGateway', function () {
@@ -51,7 +51,7 @@ describe('ApiGateway', function () {
$mockCache = new class implements \App\Framework\Cache\Cache {
public function get(\App\Framework\Cache\CacheIdentifier ...$identifiers): \App\Framework\Cache\CacheResult
{
return new \App\Framework\Cache\CacheResult(hits: [], misses: $identifiers);
return \App\Framework\Cache\CacheResult::empty();
}
public function set(\App\Framework\Cache\CacheItem ...$items): bool { return true; }
public function has(\App\Framework\Cache\CacheIdentifier ...$identifiers): array { return []; }
@@ -89,39 +89,14 @@ describe('ApiGateway', function () {
$this->metrics = new \App\Framework\ApiGateway\Metrics\ApiMetrics();
$this->operationTracker = new class implements \App\Framework\Performance\OperationTracker {
public function startOperation(
string $operationId,
\App\Framework\Performance\PerformanceCategory $category,
array $contextData = []
): \App\Framework\Performance\PerformanceSnapshot {
return new \App\Framework\Performance\PerformanceSnapshot(
operationId: $operationId,
category: $category,
startTime: microtime(true),
duration: \App\Framework\Core\ValueObjects\Duration::fromMilliseconds(10),
memoryUsed: 1024,
peakMemory: 2048,
contextData: $contextData
);
}
$memoryMonitor = new \App\Framework\Performance\MemoryMonitor();
public function completeOperation(string $operationId): ?\App\Framework\Performance\PerformanceSnapshot {
return new \App\Framework\Performance\PerformanceSnapshot(
operationId: $operationId,
category: \App\Framework\Performance\PerformanceCategory::HTTP,
startTime: microtime(true) - 0.01,
duration: \App\Framework\Core\ValueObjects\Duration::fromMilliseconds(10),
memoryUsed: 1024,
peakMemory: 2048,
contextData: []
);
}
public function failOperation(string $operationId, \Throwable $exception): ?\App\Framework\Performance\PerformanceSnapshot {
return null;
}
};
$this->operationTracker = new \App\Framework\Performance\OperationTracker(
clock: $mockClock,
memoryMonitor: $memoryMonitor,
logger: null,
eventDispatcher: null
);
$this->apiGateway = new ApiGateway(
$this->httpClient,
@@ -136,7 +111,7 @@ describe('ApiGateway', function () {
$request = new class implements ApiRequest, HasAuth {
public function getEndpoint(): ApiEndpoint
{
return ApiEndpoint::fromUrl(Url::parse('https://api.example.com/test'));
return ApiEndpoint::fromUrl(WhatwgUrl::parse('https://api.example.com/test'));
}
public function getMethod(): HttpMethod
@@ -174,14 +149,14 @@ describe('ApiGateway', function () {
expect($response->status)->toBe(Status::OK);
expect($this->capturedRequest->options->auth)->not->toBeNull();
expect($this->capturedRequest->options->auth->type)->toBe('basic');
expect($this->capturedRequest->options->auth->type->value)->toBe('basic');
});
it('applies custom header authentication when ApiRequest uses AuthConfig::custom()', function () {
$request = new class implements ApiRequest, HasAuth {
public function getEndpoint(): ApiEndpoint
{
return ApiEndpoint::fromUrl(Url::parse('https://api.example.com/test'));
return ApiEndpoint::fromUrl(WhatwgUrl::parse('https://api.example.com/test'));
}
public function getMethod(): HttpMethod
@@ -221,14 +196,14 @@ describe('ApiGateway', function () {
expect($response->status)->toBe(Status::OK);
expect($this->capturedRequest->options->auth)->not->toBeNull();
expect($this->capturedRequest->options->auth->type)->toBe('custom');
expect($this->capturedRequest->options->auth->type->value)->toBe('custom');
});
it('does not apply authentication when ApiRequest does not implement HasAuth', function () {
$request = new class implements ApiRequest {
public function getEndpoint(): ApiEndpoint
{
return ApiEndpoint::fromUrl(Url::parse('https://api.example.com/test'));
return ApiEndpoint::fromUrl(WhatwgUrl::parse('https://api.example.com/test'));
}
public function getMethod(): HttpMethod
@@ -270,7 +245,7 @@ describe('ApiGateway', function () {
$request = new class implements ApiRequest, HasPayload, HasAuth {
public function getEndpoint(): ApiEndpoint
{
return ApiEndpoint::fromUrl(Url::parse('https://api.example.com/test'));
return ApiEndpoint::fromUrl(WhatwgUrl::parse('https://api.example.com/test'));
}
public function getMethod(): HttpMethod
@@ -329,7 +304,7 @@ describe('ApiGateway', function () {
$request = new class implements ApiRequest, HasAuth {
public function getEndpoint(): ApiEndpoint
{
return ApiEndpoint::fromUrl(Url::parse('https://api.example.com/test'));
return ApiEndpoint::fromUrl(WhatwgUrl::parse('https://api.example.com/test'));
}
public function getMethod(): HttpMethod
@@ -376,7 +351,7 @@ describe('ApiGateway', function () {
$request = new class implements ApiRequest {
public function getEndpoint(): ApiEndpoint
{
return ApiEndpoint::fromUrl(Url::parse('https://api.example.com/test'));
return ApiEndpoint::fromUrl(WhatwgUrl::parse('https://api.example.com/test'));
}
public function getMethod(): HttpMethod
@@ -414,7 +389,7 @@ describe('ApiGateway', function () {
$request = new class implements ApiRequest {
public function getEndpoint(): ApiEndpoint
{
return ApiEndpoint::fromUrl(Url::parse('https://api.example.com/test'));
return ApiEndpoint::fromUrl(WhatwgUrl::parse('https://api.example.com/test'));
}
public function getMethod(): HttpMethod
@@ -445,14 +420,14 @@ describe('ApiGateway', function () {
$response = $this->apiGateway->send($request);
expect($response->status)->toBe(Status::OK);
expect($this->capturedRequest->method)->toBe('GET');
expect($this->capturedRequest->method->value)->toBe('GET');
});
it('supports POST requests with payload', function () {
$request = new class implements ApiRequest, HasPayload {
public function getEndpoint(): ApiEndpoint
{
return ApiEndpoint::fromUrl(Url::parse('https://api.example.com/test'));
return ApiEndpoint::fromUrl(WhatwgUrl::parse('https://api.example.com/test'));
}
public function getMethod(): HttpMethod
@@ -488,7 +463,7 @@ describe('ApiGateway', function () {
$response = $this->apiGateway->send($request);
expect($response->status)->toBe(Status::OK);
expect($this->capturedRequest->method)->toBe('POST');
expect($this->capturedRequest->method->value)->toBe('POST');
$bodyData = json_decode($this->capturedRequest->body, true);
expect($bodyData)->toBe(['data' => 'test']);
});
@@ -497,7 +472,7 @@ describe('ApiGateway', function () {
$request = new class implements ApiRequest, HasAuth {
public function getEndpoint(): ApiEndpoint
{
return ApiEndpoint::fromUrl(Url::parse('https://api.example.com/test/123'));
return ApiEndpoint::fromUrl(WhatwgUrl::parse('https://api.example.com/test/123'));
}
public function getMethod(): HttpMethod
@@ -533,14 +508,14 @@ describe('ApiGateway', function () {
$response = $this->apiGateway->send($request);
expect($response->status)->toBe(Status::OK);
expect($this->capturedRequest->method)->toBe('DELETE');
expect($this->capturedRequest->method->value)->toBe('DELETE');
});
it('supports PATCH requests with payload', function () {
$request = new class implements ApiRequest, HasPayload, HasAuth {
public function getEndpoint(): ApiEndpoint
{
return ApiEndpoint::fromUrl(Url::parse('https://api.example.com/test/123'));
return ApiEndpoint::fromUrl(WhatwgUrl::parse('https://api.example.com/test/123'));
}
public function getMethod(): HttpMethod
@@ -581,7 +556,7 @@ describe('ApiGateway', function () {
$response = $this->apiGateway->send($request);
expect($response->status)->toBe(Status::OK);
expect($this->capturedRequest->method)->toBe('PATCH');
expect($this->capturedRequest->method->value)->toBe('PATCH');
$bodyData = json_decode($this->capturedRequest->body, true);
expect($bodyData)->toBe(['name' => 'Updated']);
});
@@ -592,7 +567,7 @@ describe('ApiGateway', function () {
$request = new class implements ApiRequest {
public function getEndpoint(): ApiEndpoint
{
return ApiEndpoint::fromUrl(Url::parse('https://api.example.com/test'));
return ApiEndpoint::fromUrl(WhatwgUrl::parse('https://api.example.com/test'));
}
public function getMethod(): HttpMethod