sync stateful set when syncing streams during ADD event #2245
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.
In #2187 the flow for configuring Postgres for streams was moved to syncStatefulSet, because it's the only place right now where we restart Postgres on config changes. The restart is required to set wal_level to
logical
before creating publications and replication slots.However, syncStatefulSet is not executed during Create. Whem a new cluster is added with stream section we face the same error as before - creation of publication during syncStreams will fail because wal_level has not been adjusted, yet. It happens only during next SYNC when it's too late.
Therefore, this PR proposed to call syncStatefulSet inside Create method, if streams are defined.
In case the sync of statefulset will fail return an error. I moved setting replicationSlots before the syncing of streams to have it set even when there is this error.