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

Can't update a stream config on a cluster when using mirroring and an optional start time #659

Closed
darkwatchuk opened this issue Oct 17, 2024 · 1 comment · Fixed by #661

Comments

@darkwatchuk
Copy link
Contributor

darkwatchuk commented Oct 17, 2024

Observed behavior

When trying to update a stream against a cluster and using mirroring and an optional start time for that mirror, we get an error saying that we're unable to update the mirror configuration, even though we're not changing it.

The posted code works fine against local running instance, but not against a cluster, super-cluster, or Synadia Cloud.

Expected behavior

Should work against a cluster

Server and client version

Latest .Net client source, latest server, latest synadia cloud.

Host environment

No response

Steps to reproduce

(fill in own jwt and seed for synadia cloud to test)

[Fact]
 public async Task MirrorTimeTest()
 {

     // USE LOCAL HOST
     //await using var server = NatsServer.Start(
     // outputHelper: _output,
     // opts: new NatsServerOptsBuilder()
     //     .UseTransport(TransportType.Tcp)
     //     .Trace()
     //     .UseJetStream()
     //     .Build());
     //var nats = server.CreateClientConnection(new NatsOpts { RequestTimeout = TimeSpan.FromSeconds(10) });
     // Use Synadia Cloud
     var nats = new NatsConnection(new NatsOpts
     {
         Url = "tls://connect.ngs.global",
         AuthOpts = new NatsAuthOpts
         {
             Jwt = "",
             Seed = ""
         }
     });
     await nats.ConnectAsync();


     {
         var js = new NatsJSContext(nats);

         // Create stream
         var stream = await js.CreateStreamAsync(
             config: new StreamConfig { Name = "events", Subjects = new[] { "events.*" }, MaxBytes = 100000, }
             );

         // Test basic mirror stream  - THIS WORKS FINE
         {
             var basicMirrorStream = await js.CreateStreamAsync(config: new StreamConfig {
                 Name = "events_mirror_basic",
                 Mirror = new StreamSource { Name = "events" },
                 Retention = StreamConfigRetention.Limits,
                 Discard = StreamConfigDiscard.Old,
                 MaxBytes = 100000,
                 AllowRollupHdrs = true,
                 DenyDelete = false,
                 DenyPurge = false,
                 AllowDirect = true,
             });
             {
                 var config = basicMirrorStream.Info.Config;
                 config.Description = "updated mirror";
                 var result = await js.UpdateStreamAsync(config);
                 Assert.Equal(config.Description, result.Info.Config.Description);
             }
         }

         // Test mirror stream with optional start time
         {
            var timedMirrorStream = await js.CreateStreamAsync(config: new StreamConfig {
     Name = "events_mirror_timed",
     Mirror = new StreamSource { Name = "events", OptStartTime = DateTimeOffset.Parse("2024-01-01T00:00:00+00:00") },
     Retention = StreamConfigRetention.Limits,
     Discard = StreamConfigDiscard.Old,
     MaxBytes = 100000,
     AllowRollupHdrs = true,
     DenyDelete = false,
     DenyPurge = false,
     AllowDirect = true,
 });
             {
                 var config = timedMirrorStream.Info.Config;
                 config.Description = "updated mirror";
                 var result = await js.UpdateStreamAsync(config);
                 Assert.Equal(config.Description, result.Info.Config.Description);
             }
         }

         // Get the existing stream config
         {
             var existingStreamInfo = await js.GetStreamAsync("events_mirror_timed");
             var config = existingStreamInfo.Info.Config;
             config.Description = "updated description";
             var result = await js.UpdateStreamAsync(config);
         }
     }
 }
@mtmk
Copy link
Collaborator

mtmk commented Oct 17, 2024

it looks like during update, server is not able to compare UTC +00:00 notation and expects Z instead

expected:

"mirror": {
  "name": "events",
  "opt_start_time": "2024-01-01T00:00:00Z"
},

actual sent by client:

"mirror": {
  "name": "events",
  "opt_start_time": "2024-01-01T00:00:00+00:00"
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants