From 33877d1b4ef62d40b0acf1a48a8ccb16978bc527 Mon Sep 17 00:00:00 2001 From: Daniel Cibrao Date: Wed, 26 Oct 2022 16:12:56 +0100 Subject: [PATCH] feat: creates consumers if not present in NATS The jetstream-controller its an operate that should ensure that a system is in a given state. During our tests we found out that if a consumers or stream are deleted via code or through `nats-box` they are not created again by the controller. From my understanding this is happening because we are checking if the observed generation number and generation number match in the CRD, which on this case (a manually delete consumer) will not change and thus not trigger a recreation. The following PR aims to resources (consumers and streams) being created in NATS in case they are not found by the client but there is a CRD for it. --- controllers/jetstream/consumer.go | 2 +- controllers/jetstream/stream.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/jetstream/consumer.go b/controllers/jetstream/consumer.go index 3bf9cc72..da5332ce 100644 --- a/controllers/jetstream/consumer.go +++ b/controllers/jetstream/consumer.go @@ -172,7 +172,7 @@ func (c *Controller) processConsumerObject(cns *apis.Consumer, jsmc jsmClient) ( return err } updateOK := (consumerOK && !deleteOK && newGeneration) - createOK := (!consumerOK && !deleteOK && newGeneration) + createOK := (!consumerOK && !deleteOK) switch { case createOK: diff --git a/controllers/jetstream/stream.go b/controllers/jetstream/stream.go index 4896fb85..02bb1023 100644 --- a/controllers/jetstream/stream.go +++ b/controllers/jetstream/stream.go @@ -211,7 +211,7 @@ func (c *Controller) processStreamObject(str *apis.Stream, jsmc jsmClient) (err return err } updateOK := (strOK && !deleteOK && newGeneration) - createOK := (!strOK && !deleteOK && newGeneration) + createOK := (!strOK && !deleteOK) switch { case createOK: