Repository navigation
Commit 9f46ca0
committed
fix: complete error logging migration and fix grep pattern bug
This commit completes the robustness fixes from commit 1cdc1a1 by
addressing two critical issues identified in code review:
1. **Fix grep pattern bug in get_running_services_count()**
- Changed from: `grep -c " Up"`
- Changed to: `grep -cE " Up\b"` (word boundary)
- FIXES: Previous pattern caused false positives on stopped containers
with "Up" in command name (e.g., "UpgradeDB", "Uploader")
- Now correctly matches only State column, not Command column
- Prevents operational issues where backup/restore blocked incorrectly
2. **Complete error() function migration (5 critical errors)**
- Updated deploy.sh (3 errors):
* "Failed to pull images from GHCR" (line 194)
* "Backup failed" (line 213)
* "Services unhealthy after timeout" (line 249)
- Updated rollback.sh (2 errors):
* "Backup restoration failed" (line 172)
* "Rollback health check failed" (line 213)
- FIXES: Critical operational errors now visible in quiet mode
- All deployment/rollback failures now properly logged
3. **Consistency improvements (7 helper functions)**
- Updated to use error() instead of direct stderr:
* acquire_lock() - flock requirement and lock conflict errors
* require_jq() - dependency check
* require_curl() - dependency check
* validate_compose_file() - file existence check
* determine_backup_name() - missing backup error
* validate_and_check_backup() - removed duplicate error message
* require_services_stopped() - services running error
- Ensures consistent error handling and logging across all functions
- All errors now include timestamps and log to LOG_FILE
**Testing:**
- Grep pattern tested against docker-compose output formats:
* Simple "Up" (end of line) - ✅ matches
* "Up (healthy)" - ✅ matches
* "Up 5 seconds" - ✅ matches
* "Up ports..." - ✅ matches
* "UpgradeDB" in command - ✅ does NOT match (false positive fixed)
- Error logging tested in quiet mode - all errors visible
**Impact:**
- Eliminates grep pattern false positive bug
- Ensures critical errors never suppressed in quiet mode
- Improves operational visibility and troubleshooting
- No breaking changes to functionality
These fixes complete the robustness improvements and make the code
production-ready for merge.1 parent 1cdc1a1 commit 9f46ca0
3 files changed
Lines changed: 21 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
| 194 | + | |
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
| 249 | + | |
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
| 87 | + | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
| |||
213 | 215 | | |
214 | 216 | | |
215 | 217 | | |
216 | | - | |
| 218 | + | |
217 | 219 | | |
218 | 220 | | |
219 | 221 | | |
| |||
222 | 224 | | |
223 | 225 | | |
224 | 226 | | |
225 | | - | |
| 227 | + | |
226 | 228 | | |
227 | 229 | | |
228 | 230 | | |
| |||
395 | 397 | | |
396 | 398 | | |
397 | 399 | | |
398 | | - | |
| 400 | + | |
399 | 401 | | |
400 | 402 | | |
401 | 403 | | |
| |||
405 | 407 | | |
406 | 408 | | |
407 | 409 | | |
408 | | - | |
| 410 | + | |
409 | 411 | | |
410 | 412 | | |
411 | 413 | | |
| |||
415 | 417 | | |
416 | 418 | | |
417 | 419 | | |
418 | | - | |
| 420 | + | |
419 | 421 | | |
420 | 422 | | |
421 | 423 | | |
| |||
540 | 542 | | |
541 | 543 | | |
542 | 544 | | |
543 | | - | |
544 | | - | |
545 | | - | |
| 545 | + | |
546 | 546 | | |
| 547 | + | |
| 548 | + | |
547 | 549 | | |
548 | 550 | | |
549 | 551 | | |
| |||
561 | 563 | | |
562 | 564 | | |
563 | 565 | | |
564 | | - | |
565 | | - | |
| 566 | + | |
566 | 567 | | |
567 | 568 | | |
568 | 569 | | |
| |||
575 | 576 | | |
576 | 577 | | |
577 | 578 | | |
578 | | - | |
| 579 | + | |
579 | 580 | | |
580 | | - | |
| 581 | + | |
581 | 582 | | |
582 | 583 | | |
583 | 584 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| |||
0 commit comments