-
Notifications
You must be signed in to change notification settings - Fork 1k
refactor restarting instances #1535
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
Conversation
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE) | ||
|
||
def patroni_rest(self, pod, path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate of 246-252 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, there's a lot of duplicate code. Don't understand why. I thought to better do it, too 😄
Someone should tidy this part up.
e2e/tests/test_e2e.py
Outdated
try: | ||
k8s.create_with_kubectl("manifests/complete-postgres-manifest.yaml") | ||
k8s.wait_for_pod_start("spilo-role=master", self.test_namespace) | ||
k8s.wait_for_pod_start('spilo-role=replica') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does waiting or the master uses the self.test_namespace
and waiting for the replica does not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an oversight, indeed. Might explain why the test fails atm
e2e/tests/test_e2e.py
Outdated
self.eventuallyEqual(lambda: self.k8s.get_operator_state(), {"0": "idle"}, "Operator does not get in sync") | ||
|
||
def compare_config(): | ||
effective_config = k8s.patroni_rest(masterPod.metadata.name, "config") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but that only tells you if the Patroni config was updated, not if the change was actually applied on the PG level.
Patroni has the pending_restart
flag to indicate such situation
$ curl -s http://localhost:8008/patroni | jq .
{
"pending_restart": true,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true. Added a check to query the settings in the database
pkg/cluster/sync.go
Outdated
pods, err = c.listPods() | ||
if err != nil { | ||
return fmt.Errorf("could not set cluster-wide PostgreSQL configuration options: %v", err) | ||
c.logger.Infof("could not list pods of the statefulset: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is arguably still an error because the Sync will fail to complete without the list o pods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error was not replaced but moved into the loop. I took inspiration from line 276 where it's also just an info log line. The function would not fail with an empty list of pods. I've change the log level to warning.
👍 |
1 similar comment
👍 |
refactored restart of instances by moving them into a loop over pods. Same for patching Postgres with
checkAndSetGlobalPostgreSQLConfiguration
From:
To:
This PR also adds the following functionality:
checkAndSetGlobalPostgreSQLConfiguration
to compare Patroni config withc.Spec.Patroni
, too:c.patroni.SetConfig
endpoint which supports the full config hierarchy compared toc.patroni.SetPostgresParameters
which is only forpostrgesql.parameters
test_decrease_max_connections
e2e test (or create a new one) for config changes