Skip to content

Commit 15d8bf1

Browse files
authored
fix: external history tables config and env conflict (#18341)
* fix: external history tables config and env conflict * add test * fix test * fix: allow history table to load credential by connection * fix: allow history table to load credential by connection
1 parent eb2d36e commit 15d8bf1

File tree

6 files changed

+317
-240
lines changed

6 files changed

+317
-240
lines changed

.github/actions/test_logs/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ runs:
3333
bash ./tests/logging/test-logs.sh
3434
3535
- name: Run History Tables Tests
36+
env:
37+
LOG_HISTORY_STORAGE_S3_ACCESS_KEY_ID: 'minioadmin'
38+
LOG_HISTORY_STORAGE_S3_SECRET_ACCESS_KEY: 'minioadmin'
3639
shell: bash
3740
run: |
3841
bash ./tests/logging/test-history-tables.sh

src/query/config/src/config.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,12 +2794,17 @@ pub struct HistoryLogConfig {
27942794
#[serde(rename = "tables")]
27952795
pub log_history_tables: Vec<HistoryLogTableConfig>,
27962796

2797-
/// Specifies the storage parameters for the history log
2797+
/// Specifies whether enable external storage
2798+
/// If set to false (default), the default storage parameters from `[storage]` will be used.
2799+
#[clap(skip)]
2800+
#[serde(rename = "storage_on", default)]
2801+
pub log_history_external_storage_on: bool,
2802+
2803+
/// Specifies the external storage parameters for the history log
27982804
/// This is used to configure how the history log data is stored.
2799-
/// If not specified, the default storage parameters from `[storage]` will be used.
28002805
#[clap(skip)]
28012806
#[serde(rename = "storage")]
2802-
pub log_history_storage_params: Option<StorageConfig>,
2807+
pub log_history_storage_params: StorageConfig,
28032808
}
28042809

28052810
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
@@ -2849,12 +2854,11 @@ impl TryInto<InnerHistoryConfig> for HistoryLogConfig {
28492854
type Error = ErrorCode;
28502855

28512856
fn try_into(self) -> Result<InnerHistoryConfig> {
2852-
let storage_params: Option<InnerStorageConfig> =
2853-
if self.log_history_storage_params.is_some() {
2854-
Some(self.log_history_storage_params.unwrap().try_into()?)
2855-
} else {
2856-
None
2857-
};
2857+
let storage_params: Option<InnerStorageConfig> = if self.log_history_external_storage_on {
2858+
Some(self.log_history_storage_params.try_into()?)
2859+
} else {
2860+
None
2861+
};
28582862
Ok(InnerHistoryConfig {
28592863
on: self.log_history_on,
28602864
log_only: self.log_history_log_only,
@@ -2887,7 +2891,8 @@ impl From<InnerHistoryConfig> for HistoryLogConfig {
28872891
log_history_level: inner.level,
28882892
log_history_retention_interval: inner.retention_interval,
28892893
log_history_tables: inner.tables.into_iter().map(Into::into).collect(),
2890-
log_history_storage_params: inner_storage_config.map(Into::into),
2894+
log_history_external_storage_on: inner_storage_config.is_some(),
2895+
log_history_storage_params: inner_storage_config.map(Into::into).unwrap_or_default(),
28912896
}
28922897
}
28932898
}

0 commit comments

Comments
 (0)