diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-23 16:12:03 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-27 20:38:04 +0000 |
| commit | 2b21b807bdf6c0bab548ffceb5c41eee0902890c (patch) | |
| tree | e3b17db923384dd512ae40f0f263de165d119f4f /docs/how-to/migration-scripts/30-extract-parse-failures.sh | |
| parent | 6a6c8cf8b70bc387ea7241b5c9ec457cb525eb40 (diff) | |
Prevent Phase 4 from using wrong service (ngit-relay vs ngit-grasp)
Add validation to ensure Phase 4 scripts use ngit-grasp service
(with structured logging) instead of ngit-relay service.
Changes:
- Add validate-service.sh helper for reusable service validation
- Add validation to run-migration-analysis.sh before Phase 4
- Add validation to 30-extract-parse-failures.sh
- Add validation to 31-extract-purgatory-expiry.sh
- Update migration guide with clear warnings about service selection
- Expand troubleshooting for 'Phase 4 finds no logs' issue
- Emphasize lesson learned in relay.ngit.dev notes
This prevents the issue where Phase 4 was run against ngit-relay.service
and found no parse failures because structured logging only exists in
ngit-grasp services.
Diffstat (limited to 'docs/how-to/migration-scripts/30-extract-parse-failures.sh')
| -rwxr-xr-x | docs/how-to/migration-scripts/30-extract-parse-failures.sh | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/docs/how-to/migration-scripts/30-extract-parse-failures.sh b/docs/how-to/migration-scripts/30-extract-parse-failures.sh index bc2049a..410fcbc 100755 --- a/docs/how-to/migration-scripts/30-extract-parse-failures.sh +++ b/docs/how-to/migration-scripts/30-extract-parse-failures.sh | |||
| @@ -65,6 +65,14 @@ | |||
| 65 | 65 | ||
| 66 | set -euo pipefail | 66 | set -euo pipefail |
| 67 | 67 | ||
| 68 | # Get script directory for sourcing helpers | ||
| 69 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| 70 | |||
| 71 | # Source the service validation helper | ||
| 72 | if [[ -f "$SCRIPT_DIR/validate-service.sh" ]]; then | ||
| 73 | source "$SCRIPT_DIR/validate-service.sh" | ||
| 74 | fi | ||
| 75 | |||
| 68 | # Colors for output (disabled if not a terminal) | 76 | # Colors for output (disabled if not a terminal) |
| 69 | if [[ -t 1 ]]; then | 77 | if [[ -t 1 ]]; then |
| 70 | RED='\033[0;31m' | 78 | RED='\033[0;31m' |
| @@ -188,11 +196,35 @@ main() { | |||
| 188 | esac | 196 | esac |
| 189 | done | 197 | done |
| 190 | 198 | ||
| 191 | # Validate service name | 199 | # Validate service name format |
| 192 | if [[ ! "$service" =~ \.service$ ]]; then | 200 | if [[ ! "$service" =~ \.service$ ]]; then |
| 193 | service="${service}.service" | 201 | service="${service}.service" |
| 194 | fi | 202 | fi |
| 195 | 203 | ||
| 204 | # Validate service is appropriate for structured logging | ||
| 205 | # This prevents the common mistake of using ngit-relay instead of ngit-grasp | ||
| 206 | if type validate_service_for_structured_logging &>/dev/null; then | ||
| 207 | # Use non-interactive mode if not a terminal, skip log check (we'll do our own) | ||
| 208 | local interactive="true" | ||
| 209 | [[ ! -t 0 ]] && interactive="false" | ||
| 210 | |||
| 211 | if ! validate_service_for_structured_logging "$service" "false" "$interactive"; then | ||
| 212 | log_error "Service validation failed. Use an ngit-grasp service for structured logging." | ||
| 213 | exit 1 | ||
| 214 | fi | ||
| 215 | else | ||
| 216 | # Fallback validation if helper not available | ||
| 217 | if [[ "$service" == *"ngit-relay"* ]]; then | ||
| 218 | log_error "Service name appears to be ngit-relay: $service" | ||
| 219 | log_error "Structured logging ([PARSE_FAIL]) only exists in ngit-grasp services." | ||
| 220 | log_error "Please use the ngit-grasp archive service instead." | ||
| 221 | log_error "" | ||
| 222 | log_error "To find the correct service:" | ||
| 223 | log_error " systemctl list-units 'ngit-grasp*' --all" | ||
| 224 | exit 1 | ||
| 225 | fi | ||
| 226 | fi | ||
| 227 | |||
| 196 | log_info "Extracting parse failures from systemd logs" | 228 | log_info "Extracting parse failures from systemd logs" |
| 197 | log_info "Service: $service" | 229 | log_info "Service: $service" |
| 198 | log_info "Output: $output_dir" | 230 | log_info "Output: $output_dir" |