Skip to content

Commit

Permalink
fix(meta): include secret in meta backup for etcd meta store (#17908)
Browse files Browse the repository at this point in the history
  • Loading branch information
zwang28 authored Aug 5, 2024
1 parent 3c745df commit bf1c1db
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/meta/src/backup_restore/meta_snapshot_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use risingwave_backup::meta_snapshot_v1::{ClusterMetadata, MetaSnapshotV1};
use risingwave_backup::MetaSnapshotId;
use risingwave_hummock_sdk::version::{HummockVersion, HummockVersionDelta};
use risingwave_pb::catalog::{
Connection, Database, Function, Index, Schema, Sink, Source, Subscription, Table, View,
Connection, Database, Function, Index, Schema, Secret, Sink, Source, Subscription, Table, View,
};
use risingwave_pb::hummock::HummockVersionStats;
use risingwave_pb::meta::SystemParams;
Expand Down Expand Up @@ -124,6 +124,7 @@ impl<S: MetaStore> MetaSnapshotV1Builder<S> {
.ok_or_else(|| anyhow!("cluster id not found in meta store"))?
.into();
let subscription = Subscription::list_at_snapshot::<S>(&meta_store_snapshot).await?;
let secret = Secret::list_at_snapshot::<S>(&meta_store_snapshot).await?;

self.snapshot.metadata = ClusterMetadata {
default_cf,
Expand All @@ -144,6 +145,7 @@ impl<S: MetaStore> MetaSnapshotV1Builder<S> {
system_param,
cluster_id,
subscription,
secret,
};
Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions src/meta/src/backup_restore/restore_impl/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,6 @@ async fn restore_metadata<S: MetaStore>(
restore_system_param_model(&meta_store, &[snapshot.metadata.system_param]).await?;
restore_cluster_id(&meta_store, snapshot.metadata.cluster_id.into()).await?;
restore_metadata_model(&meta_store, &snapshot.metadata.subscription).await?;
restore_metadata_model(&meta_store, &snapshot.metadata.secret).await?;
Ok(())
}
3 changes: 2 additions & 1 deletion src/meta/src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ macro_rules! for_all_metadata_models {
($macro:ident) => {
$macro! {
// These items should be included in a meta snapshot.
// So be sure to update meta backup/restore when adding new items.
// Make sure to update the meta backup&restore methods accordingly when adding new items,
// referring to https://github.com/risingwavelabs/risingwave/pull/15371/commits/c5a75320845a38cfb43241ddee16fd5c0e47833b
{ risingwave_pb::hummock::HummockVersionStats },
{ crate::hummock::model::CompactionGroup },
{ risingwave_pb::catalog::Database },
Expand Down
11 changes: 10 additions & 1 deletion src/storage/backup/src/meta_snapshot_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use itertools::Itertools;
use risingwave_common::util::iter_util::ZipEqFast;
use risingwave_hummock_sdk::version::HummockVersion;
use risingwave_pb::catalog::{
Connection, Database, Function, Index, Schema, Sink, Source, Subscription, Table, View,
Connection, Database, Function, Index, Schema, Secret, Sink, Source, Subscription, Table, View,
};
use risingwave_pb::hummock::{CompactionGroup, HummockVersionStats, PbHummockVersion};
use risingwave_pb::meta::{SystemParams, TableFragments};
Expand Down Expand Up @@ -72,6 +72,10 @@ impl Display for ClusterMetadata {
writeln!(f, "{:#?}", self.system_param)?;
writeln!(f, "cluster_id:")?;
writeln!(f, "{:#?}", self.cluster_id)?;
writeln!(f, "subscription:")?;
writeln!(f, "{:#?}", self.subscription)?;
writeln!(f, "secret:")?;
writeln!(f, "{:#?}", self.secret)?;
Ok(())
}
}
Expand Down Expand Up @@ -121,6 +125,7 @@ pub struct ClusterMetadata {
pub system_param: SystemParams,
pub cluster_id: String,
pub subscription: Vec<Subscription>,
pub secret: Vec<Secret>,
}

impl ClusterMetadata {
Expand All @@ -146,6 +151,7 @@ impl ClusterMetadata {
Self::encode_prost_message(&self.system_param, buf);
Self::encode_prost_message(&self.cluster_id, buf);
Self::encode_prost_message_list(&self.subscription.iter().collect_vec(), buf);
Self::encode_prost_message_list(&self.secret.iter().collect_vec(), buf);
Ok(())
}

Expand Down Expand Up @@ -175,6 +181,8 @@ impl ClusterMetadata {
let cluster_id: String = Self::decode_prost_message(&mut buf)?;
let subscription: Vec<Subscription> =
Self::try_decode_prost_message_list(&mut buf).unwrap_or_else(|| Ok(vec![]))?;
let secret: Vec<Secret> =
Self::try_decode_prost_message_list(&mut buf).unwrap_or_else(|| Ok(vec![]))?;

Ok(Self {
default_cf,
Expand All @@ -195,6 +203,7 @@ impl ClusterMetadata {
system_param,
cluster_id,
subscription,
secret,
})
}

Expand Down

0 comments on commit bf1c1db

Please sign in to comment.