Skip to content

Commit

Permalink
storage-client: don't panic if reading Kafka/Postgres secret fails
Browse files Browse the repository at this point in the history
The surrounding code paths have been sufficiently refactored such that
it is now possible to gracefully return an error here.

Fix #18438.
  • Loading branch information
benesch committed Apr 4, 2023
1 parent bc93581 commit f62563c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/storage-client/src/types/connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ impl KafkaConnection {
k,
v.get_string(&*connection_context.secrets_reader)
.await
.expect("reading kafka secret unexpectedly failed"),
.context("reading kafka secret")?,
);
}
for (k, v) in extra_options {
Expand Down
21 changes: 19 additions & 2 deletions src/storage/src/source/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,28 @@ impl SourceRender for PostgresSourceConnection {

let resume_lsn = Arc::new(AtomicU64::new(start_offset.offset));

let connection_config = self
let connection_config = match self
.connection
.config(&*connection_context.secrets_reader)
.await
.expect("Postgres connection unexpectedly missing secrets");
{
Ok(config) => config,
Err(e) => {
let update = HealthStatusUpdate {
update: HealthStatus::StalledWithError {
error: format!("failed creating postgres config: {e:#}"),
hint: None,
},
should_halt: true,
};
health_output.give(&health_capability, update).await;
// IMPORTANT: wedge forever until the `SuspendAndRestart` is processed.
// Returning would incorrectly present to the remap operator as progress to the
// empty frontier which would be incorrectly recorded to the remap shard.
std::future::pending::<()>().await;
unreachable!("pending future never returns");
}
};

let mut source_tables = BTreeMap::new();
let tables_iter = self.publication_details.tables.iter();
Expand Down

0 comments on commit f62563c

Please sign in to comment.