-
Notifications
You must be signed in to change notification settings - Fork 14
feat: retry-system #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: retry-system #101
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
55e20d4
feat: configurable retry policy and combinator
b0da2e4
feat: retry the database backup
5298d82
feat: retry storage uploads
b6a120f
feat: retry the restore backup download
87f33af
fix: wire retry env vars into helm configmap, dedupe terminal retry log
db0f87c
Merge branch 'main' into feat/retry-system
42c3c59
fix: refactoring
99f1ef2
fix: refactoring
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| use crate::services::backup::BackupService; | ||
| use crate::services::backup::logger::JobLogger; | ||
| use crate::services::config::{DatabaseConfig, DbType}; | ||
| use crate::tests::init_tracing_for_test; | ||
|
|
||
| use std::collections::HashMap; | ||
| use std::sync::Arc; | ||
| use tempfile::TempDir; | ||
|
|
||
| fn sqlite_config(path: &str) -> DatabaseConfig { | ||
| DatabaseConfig { | ||
| name: "retry-test".to_string(), | ||
| database: String::new(), | ||
| db_type: DbType::Sqlite, | ||
| username: String::new(), | ||
| password: String::new(), | ||
| port: 0, | ||
| host: String::new(), | ||
| generated_id: "retry-test-gen".to_string(), | ||
| path: path.to_string(), | ||
| max_packet_size: String::new(), | ||
| volume_name: String::new(), | ||
| container_name: None, | ||
| options: HashMap::new(), | ||
| } | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn a_failing_backup_is_retried_and_leaves_no_attempt_directory() { | ||
| init_tracing_for_test(); | ||
|
|
||
| let temp_dir = TempDir::new().unwrap(); | ||
| let tmp_path = temp_dir.path(); | ||
| let logger = Arc::new(JobLogger::new()); | ||
|
|
||
| let cfg = sqlite_config("/nonexistent/definitely-not-here.sqlite"); | ||
|
|
||
| let result = BackupService::run(cfg, tmp_path, Arc::clone(&logger)) | ||
| .await | ||
| .unwrap(); | ||
|
|
||
| assert_eq!(result.status, "failed"); | ||
| assert!(result.backup_file.is_none()); | ||
|
|
||
| let entries = Arc::try_unwrap(logger).unwrap().into_entries(); | ||
| assert_eq!( | ||
| entries.iter().filter(|e| e.level == "warn").count(), | ||
| 2, | ||
| "expected one warn per non-final failed attempt" | ||
| ); | ||
| assert!( | ||
| entries | ||
| .iter() | ||
| .any(|e| e.level == "error" && e.message.starts_with("Backup failed:")), | ||
| "expected a single terminal error from the runner" | ||
| ); | ||
|
|
||
| let leftovers: Vec<_> = std::fs::read_dir(tmp_path) | ||
| .unwrap() | ||
| .filter_map(|e| e.ok()) | ||
| .filter(|e| e.file_name().to_string_lossy().starts_with("attempt-")) | ||
| .collect(); | ||
| assert!( | ||
| leftovers.is_empty(), | ||
| "failed attempt directories must be cleaned up, found {:?}", | ||
| leftovers.iter().map(|e| e.file_name()).collect::<Vec<_>>() | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.