Skip to content

Check patronic config and only update if neccessary #423

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

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

eberlep
Copy link
Collaborator

@eberlep eberlep commented Aug 31, 2022

No description provided.

@eberlep eberlep linked an issue Aug 31, 2022 that may be closed by this pull request
@eberlep eberlep marked this pull request as ready for review September 2, 2022 13:48

defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

io.ReadAll

@eberlep eberlep requested a review from Gerrit91 January 26, 2023 07:32
Comment on lines +247 to +249
viper.SetDefault(replicationChangeRequeueTimeFlg, 10)
replicationChangeRequeueTimeInSeconds = viper.GetInt(replicationChangeRequeueTimeFlg)
replicationChangeRequeueDuration := time.Duration(replicationChangeRequeueTimeInSeconds) * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also a Duration type for viper arguments, which simplifies handling the flag.

httpClient := &http.Client{}
url := "http://" + podIP + ":" + podPort + "/" + path

req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use http.MethodGet


body, err := io.ReadAll(resp.Body)
if err != nil {
r.Log.Info("could not read body")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also use Log.Error and wrap the error.

var jsonResp PatroniConfig
err = json.Unmarshal(body, &jsonResp)
if err != nil {
r.Log.Info("could not parse config")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also use Log.Error and wrap the error.

// this is done down here to make sure the rest of the resource updates were performed
if patroniConfigChangeErr != nil {
log.Info("Requeueing after modifying patroni replication config failed")
return ctrl.Result{Requeue: true, RequeueAfter: 10 * time.Second}, patroniConfigChangeErr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exponential backoff might be better on Patroni API unavailability

@eberlep
Copy link
Collaborator Author

eberlep commented Oct 10, 2023

Resolve conflicts and merge!

@eberlep eberlep mentioned this pull request Jun 26, 2024
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 this pull request may close these issues.

Fix SyncFailed after promote-to-primary
3 participants