Unverified Commit bdad6f1a authored by Graham King's avatar Graham King Committed by GitHub
Browse files

fix: Make planner VirtualConnectorClient also use v1/ prefix. (#3468)


Signed-off-by: default avatarGraham King <grahamk@nvidia.com>
parent 55f7e637
...@@ -102,7 +102,7 @@ impl VirtualConnectorCoordinator { ...@@ -102,7 +102,7 @@ impl VirtualConnectorCoordinator {
let prefix = root_key(&self.0.namespace); let prefix = root_key(&self.0.namespace);
let inner = self.0.clone(); let inner = self.0.clone();
pyo3_async_runtimes::tokio::future_into_py(py, async move { pyo3_async_runtimes::tokio::future_into_py(py, async move {
let kv_cache = KvCache::new(inner.etcd_client.clone(), "v1", prefix, HashMap::new()) let kv_cache = KvCache::new(inner.etcd_client.clone(), prefix, HashMap::new())
.await .await
.map_err(to_pyerr)?; .map_err(to_pyerr)?;
*inner.kv_cache.lock() = Some(Arc::new(kv_cache)); *inner.kv_cache.lock() = Some(Arc::new(kv_cache));
...@@ -497,5 +497,5 @@ fn load(a: &AtomicUsize) -> usize { ...@@ -497,5 +497,5 @@ fn load(a: &AtomicUsize) -> usize {
} }
fn root_key(namespace: &str) -> String { fn root_key(namespace: &str) -> String {
format!("{namespace}/planner/") format!("v1/{namespace}/planner/")
} }
...@@ -515,14 +515,11 @@ impl KvCache { ...@@ -515,14 +515,11 @@ impl KvCache {
/// Create a new KV cache for the given prefix /// Create a new KV cache for the given prefix
pub async fn new( pub async fn new(
client: Client, client: Client,
version: &str,
prefix: String, prefix: String,
initial_values: HashMap<String, Vec<u8>>, initial_values: HashMap<String, Vec<u8>>,
) -> Result<Self> { ) -> Result<Self> {
let mut cache = HashMap::new(); let mut cache = HashMap::new();
let prefix = format!("{version}/{prefix}");
// First get all existing keys with this prefix // First get all existing keys with this prefix
let existing_kvs = client.kv_get_prefix(&prefix).await?; let existing_kvs = client.kv_get_prefix(&prefix).await?;
for kv in existing_kvs { for kv in existing_kvs {
...@@ -712,7 +709,7 @@ mod tests { ...@@ -712,7 +709,7 @@ mod tests {
// Create a unique test prefix to avoid conflicts with other tests // Create a unique test prefix to avoid conflicts with other tests
let test_id = uuid::Uuid::new_v4().to_string(); let test_id = uuid::Uuid::new_v4().to_string();
let prefix = format!("test_kv_cache_{}/", test_id); let prefix = format!("v1/test_kv_cache_{}/", test_id);
// Initial values // Initial values
let mut initial_values = HashMap::new(); let mut initial_values = HashMap::new();
...@@ -720,7 +717,7 @@ mod tests { ...@@ -720,7 +717,7 @@ mod tests {
initial_values.insert("key2".to_string(), b"value2".to_vec()); initial_values.insert("key2".to_string(), b"value2".to_vec());
// Create the KV cache // Create the KV cache
let kv_cache = KvCache::new(client.clone(), "v1", prefix.clone(), initial_values).await?; let kv_cache = KvCache::new(client.clone(), prefix.clone(), initial_values).await?;
// Test get // Test get
let value1 = kv_cache.get("key1").await; let value1 = kv_cache.get("key1").await;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment