You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: crates/corrosion/src/command/consul/sync.rs
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -229,7 +229,7 @@ async fn update_hashes(
229
229
230
230
let services = conn
231
231
.prepare(
232
-
"SELECT id, name, tags, meta, port, address FROM consul_services WHERE node = ?",
232
+
"SELECT id, name, tags, meta, port, address FROM consul_services WHERE node = ? AND source IS NULL",
233
233
)?
234
234
.query_map([nodename], |row| {
235
235
let tag_json:String = row.get(2)?;
@@ -258,7 +258,7 @@ async fn update_hashes(
258
258
.map_err(|e| eyre::eyre!("could not query consul_checks' table_info: {e}"))?
259
259
.collect::<Result<Vec<_>,_>>()?;
260
260
261
-
let checks = conn.prepare("SELECT id, name, status, output, service_id, service_name FROM consul_checks WHERE node = ?")?
261
+
let checks = conn.prepare("SELECT id, name, status, output, service_id, service_name FROM consul_checks WHERE node = ? AND source IS NULL")?
262
262
.query_map([nodename], |row| {
263
263
Ok(AgentCheck{
264
264
id: row.get(0)?,
@@ -659,7 +659,7 @@ async fn execute(
659
659
}
660
660
661
661
// delete everything that's wrong in the DB! this is useful on restore from a backup...
662
-
statements.push(Statement::WithParams("DELETE FROM consul_services WHERE node = ? AND id NOT IN (SELECT id FROM __corro_consul_services)".into(),vec![node.into()]));
662
+
statements.push(Statement::WithParams("DELETE FROM consul_services WHERE node = ? AND source IS NULL AND id NOT IN (SELECT id FROM __corro_consul_services)".into(),vec![node.into()]));
663
663
664
664
letmut check_to_upsert = vec![];
665
665
letmut check_to_delete = vec![];
@@ -685,7 +685,7 @@ async fn execute(
685
685
}
686
686
687
687
// delete everything that's wrong in the DB! this is useful on restore from a backup...
688
-
statements.push(Statement::WithParams("DELETE FROM consul_checks WHERE node = ? AND id NOT IN (SELECT id FROM __corro_consul_checks)".into(),vec![node.into()]));
688
+
statements.push(Statement::WithParams("DELETE FROM consul_checks WHERE node = ? AND source IS NULL AND id NOT IN (SELECT id FROM __corro_consul_checks)".into(),vec![node.into()]));
689
689
690
690
if !statements.is_empty(){
691
691
ifletSome(e) = corrosion
@@ -756,6 +756,7 @@ mod tests {
756
756
address TEXT NOT NULL DEFAULT '',
757
757
updated_at INTEGER NOT NULL DEFAULT 0,
758
758
app_id INTEGER AS (CAST(JSON_EXTRACT(meta, '$.app_id') AS INTEGER)),
0 commit comments