fix: respect logging output and ignore discovery cancel#180
Conversation
|
@CodeRabbit can you review, I think this may break the |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Get PR diff for the files in question
gh pr diff 180 --repo thushan/ollaLength of output: 6466 🏁 Script executed: #!/bin/bash
# Get the current state of main.go, logger.go
cat main.go
echo "---SEPARATOR---"
cat internal/logger/logger.go
echo "---SEPARATOR---"
# Look for config struct definitions related to logging
rg -n "LogLevel\|OutputPath\|OLLA_LOG\|logging\|output" --type go -C3 internal/logger/
echo "---SEPARATOR---"
# Find config struct
rg -n "LogLevel\|OutputPath\|Logging\b" --type go -C3 internal/config/ 2>/dev/null || rg -n "LogLevel\|OutputPath\|Logging\b" --type go -C3Length of output: 15832 🏁 Script executed: #!/bin/bash
# Check config yaml files for logging output examples
fd -e yaml -e yml | xargs grep -l "log\|output" 2>/dev/null | head -20
echo "---SEPARATOR---"
fd -e yaml -e yml | head -20 | xargs cat 2>/dev/nullLength of output: 107381 🏁 Script executed: #!/bin/bash
# Find and show the config struct with Logging fields
rg -n "Logging\|LoggingConfig\|type.*Config\b" --type go -C5 internal/config/
echo "---"
# Check if there's an env.IsSet or similar function that could help with precedence
rg -n "GetEnv\|IsSet\|IsEnvSet" --type go internal/env/ 2>/dev/null || fd -e go . internal/env/ | xargs catLength of output: 995
Bug 1 —
|
|
@coderabbitai can you do the review for full context. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
echo "=== PR DIFF ==="
gh pr diff 180 --repo thushan/olla
echo "=== main.go ==="
cat main.go
echo "=== internal/logger/logger.go ==="
cat internal/logger/logger.go
echo "=== internal/adapter/discovery/service.go ==="
cat internal/adapter/discovery/service.go
echo "=== internal/adapter/discovery/service_test.go ==="
cat internal/adapter/discovery/service_test.go
echo "=== internal/env/ ==="
fd -e go . internal/env/ | xargs cat
echo "=== internal/config/ ==="
fd -e go . internal/config/ | xargs catLength of output: 137888 🏁 Script executed: #!/bin/bash
# Check DiscoveryError and NetworkError Unwrap implementations
rg -n "func.*DiscoveryError.*Unwrap\|func.*NetworkError.*Unwrap\|type DiscoveryError\|type NetworkError\|type ParseError" --type go internal/adapter/discovery/Length of output: 477 🏁 Script executed: #!/bin/bash
rg -n "type DiscoveryError\|type NetworkError\|type ParseError\|func.*Unwrap" --type go internal/adapter/discovery/
echo "---"
fd -e go . internal/adapter/discovery/ | xargs grep -n "Unwrap\|DiscoveryError\|NetworkError\|ParseError" | head -60Length of output: 5885
Overall AssessmentThe discovery The config-before-logger reordering is also the right move. ✅ However the Bug 1 —
|
Summary
This PR addresses two operational issues:
logging.outputfrom config during startup logger initialization.context.Canceledduring coordinated shutdown/restart as a normal lifecycle event, not endpoint failure.Changes
main.goLoad config before logger setup so logging config is available at logger init.
Build logger config from loaded config values.
internal/logger/logger.goAdd
OutputPathto logger config.Resolve output file path and ensure directory creation against the final output target.
internal/adapter/discovery/service.goShort-circuit
context.Canceledin discovery error handling.Skip failure-count escalation for expected shutdown cancellation.
internal/adapter/discovery/service_test.goAdd
TestDiscoverEndpointContextCanceledDoesNotCountAsFailure.Validation
go test ./internal/adapter/discovery ./internal/loggerRelated