remove stream resources after drop from Postgres manifest #2563
+44
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Usually, the Postgres Operator does not drop resources when they are removed from the manifest like databases or users. This is due to safety reasons. However, for the slots defined in the Patroni section we already made an exception because of the danger unused slots in Postgres will have on the cluster health (disk space running full).
Therefore, if somebody wants to stop using streams we could and should also do the same cleanup for the affected database slots. But it gets a bit tricky. So far, it can also be seen as a feature that the Postgres Operator can be used to create stream CRDs so that the user does not have to write the yaml file. After the creation the resource could be copied to a repo and removed from the Postgres manifest. Nothing will happen. But we are learning that this is not the expectation of our users. When they remove the streams section they do it with the intention so stop using event streaming.
The state of the PR atm if only a quick first step of removing the stream CRDs when the stream section is removed. I have extended the unit test to cover this case. But, there are still many ToDos:
We are already thinking of redefining the idea of how slots are handeled. It would be easier if their definition is handled with a separate resource, which the Postgres Operator can create and a another operator takes care of the rest.