Skip to content

Commit 14b0532

Browse files
fix(multitenant): filter consumers by multitenant status
Signed-off-by: Brooks Townsend <brooks@cosmonic.com> chore: bump async-nats wasmcloud-control-interface Signed-off-by: Brooks Townsend <brooks@cosmonic.com> fix missing struct fields Signed-off-by: Brooks Townsend <brooks@cosmonic.com>
1 parent bb75a3a commit 14b0532

File tree

5 files changed

+68
-12
lines changed

5 files changed

+68
-12
lines changed

Cargo.lock

Lines changed: 41 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ _e2e_tests = []
2424

2525
[dependencies]
2626
anyhow = "1"
27-
async-nats = "0.30"
27+
async-nats = "0.31"
2828
async-trait = "0.1"
2929
atty = { version = "0.2", optional = true }
3030
bytes = "1"
@@ -60,7 +60,7 @@ tracing-subscriber = { version = "0.3.7", features = [
6060
], optional = true }
6161
uuid = "1"
6262
wasmbus-rpc = "0.14"
63-
wasmcloud-control-interface = "0.27"
63+
wasmcloud-control-interface = "0.28"
6464
semver = { version = "1.0.16", features = ["serde"] }
6565

6666
[dev-dependencies]
@@ -69,7 +69,4 @@ serial_test = "1"
6969
[[bin]]
7070
name = "wadm"
7171
path = "bin/main.rs"
72-
required-features = ["cli"]
73-
74-
[patch.crates-io]
75-
async-nats = { git = "https://github.com/brooksmtownsend/nats.rs", branch = "fix/jetstream-domain-purge", version = "0.30" }
72+
required-features = ["cli"]

bin/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ async fn main() -> anyhow::Result<()> {
250250
permit_pool.clone(),
251251
event_stream,
252252
event_worker_creator.clone(),
253+
args.multitenant,
253254
)
254255
.await;
255256

@@ -260,6 +261,7 @@ async fn main() -> anyhow::Result<()> {
260261
permit_pool.clone(),
261262
command_stream,
262263
command_worker_creator.clone(),
264+
args.multitenant,
263265
)
264266
.await;
265267

src/consumers/manager.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ impl<C> ConsumerManager<C> {
111111
permit_pool: Arc<Semaphore>,
112112
stream: NatsStream,
113113
worker_generator: F,
114+
multitenant: bool,
114115
) -> ConsumerManager<C>
115116
where
116117
W: Worker + Send + Sync + 'static,
@@ -150,6 +151,13 @@ impl<C> ConsumerManager<C> {
150151
(Some(id), prefix) => (id, prefix),
151152
(None, _) => return None,
152153
};
154+
155+
// Don't create multitenant consumers if running in single tenant mode, and vice versa
156+
if multitenant_prefix.is_some() != multitenant {
157+
trace!(%lattice_id, "Skipping consumer for lattice because multitenant doesn't match");
158+
return None;
159+
}
160+
153161
// NOTE(thomastaylor312): It might be nicer for logs if we add an extra param for a
154162
// friendly consumer manager name
155163
trace!(%lattice_id, subject = %info.config.filter_subject, "Adding consumer for lattice");

src/workers/event.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,8 @@ mod test {
12411241
(
12421242
host1_id.to_string(),
12431243
HostInventory {
1244+
friendly_name: "my-host-1".to_string(),
1245+
issuer: "my-issuer-1".to_string(),
12441246
actors: vec![
12451247
ActorDescription {
12461248
id: actor1.public_key.to_string(),
@@ -1306,6 +1308,8 @@ mod test {
13061308
(
13071309
host2_id.to_string(),
13081310
HostInventory {
1311+
friendly_name: "my-host-2".to_string(),
1312+
issuer: "my-issuer-1".to_string(),
13091313
actors: vec![
13101314
ActorDescription {
13111315
id: actor1.public_key.to_string(),
@@ -1545,6 +1549,8 @@ mod test {
15451549
(
15461550
host1_id.to_string(),
15471551
HostInventory {
1552+
friendly_name: "my-host-3".to_string(),
1553+
issuer: "my-issuer-2".to_string(),
15481554
actors: vec![ActorDescription {
15491555
id: actor2.public_key.to_string(),
15501556
image_ref: None,
@@ -1572,6 +1578,8 @@ mod test {
15721578
(
15731579
host2_id.to_string(),
15741580
HostInventory {
1581+
friendly_name: "my-host-4".to_string(),
1582+
issuer: "my-issuer-2".to_string(),
15751583
actors: vec![ActorDescription {
15761584
id: actor2.public_key.to_string(),
15771585
image_ref: None,
@@ -1757,6 +1765,8 @@ mod test {
17571765
*inventory.write().await = HashMap::from_iter([(
17581766
host_id.to_string(),
17591767
HostInventory {
1768+
friendly_name: "my-host-5".to_string(),
1769+
issuer: "my-issuer-3".to_string(),
17601770
actors: vec![
17611771
ActorDescription {
17621772
id: actor1_id.to_string(),
@@ -2021,6 +2031,8 @@ mod test {
20212031
*inventory.write().await = HashMap::from_iter([(
20222032
host_id.to_string(),
20232033
HostInventory {
2034+
friendly_name: "my-host-6".to_string(),
2035+
issuer: "my-issuer-4".to_string(),
20242036
actors: vec![],
20252037
labels: HashMap::new(),
20262038
host_id: host_id.to_string(),
@@ -2137,6 +2149,8 @@ mod test {
21372149
*inventory.write().await = HashMap::from_iter([(
21382150
host_id.to_string(),
21392151
HostInventory {
2152+
friendly_name: "my-host-7".to_string(),
2153+
issuer: "my-issuer-5".to_string(),
21402154
actors: vec![ActorDescription {
21412155
id: "jabba".to_string(),
21422156
image_ref: None,

0 commit comments

Comments
 (0)