Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jetstream.CreateOrUpdateKeyValue doesn't handle the Domain property of jetstream.ExternalStream correctly when mirroring #1591

Open
the-plash opened this issue Mar 21, 2024 · 1 comment
Labels
defect Suspected defect such as a bug or regression

Comments

@the-plash
Copy link

Observed behavior

I have a simple setup with a leaf node connected to a hub. Jetstream is separated into two different domains ("hub" and "leaf") and i'm trying to mirror a bucket named "my_bucket" from the hub to the leaf node.

This is the code I'm using:

kv, err := leafJs.CreateOrUpdateKeyValue(ctx, jetstream.KeyValueConfig{
	Bucket:      "my_bucket",
	Mirror: &jetstream.StreamSource{
		Name:     "my_bucket",
		Domain: "hub",
	},
})

But this produces the following error on the leaf node:
nats: API error: code=500 err_code=10052 description=detected cycle

Upon further inspection, the issue may be related to CreateOrUpdateKeyValue requesting a Jetstream API call to $JS.API.STREAM.UPDATE.KV_my_bucket without the proper external property in the mirror map.

If I change the previous code to

kv, err := leafJs.CreateOrUpdateKeyValue(ctx, jetstream.KeyValueConfig{
	Bucket:      "my_bucket",
	Mirror: &jetstream.StreamSource{
		Name:     "my_bucket",
		// Domain: "hub",
		External: &jetstream.ExternalStream{APIPrefix: "$JS.hub.API"},
	},
})

manually specifying the correct APIPrefix (instead of relying on the library compiling it from the Domain property) everything works as expected.

Expected behavior

The previous code should run just fine when specifying only the Domain property of the StreamSource instead

Server and client version

  • Leaf node server version: 2.10.12
  • Hub server version: 2.10.12
  • github.com/nats-io/nats.go v1.34.0
  • go version go1.22.0 windows/amd64

Host environment

No response

Steps to reproduce

No response

@the-plash the-plash added the defect Suspected defect such as a bug or regression label Mar 21, 2024
@piotrpio
Copy link
Collaborator

piotrpio commented Apr 9, 2024

Hello @the-plash, thanks for creating the issue, I'll look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Suspected defect such as a bug or regression
Projects
None yet
Development

No branches or pull requests

2 participants