-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
This reverts commit 3f57b1c.
controllers/postgres_controller.go
Outdated
|
||
defer resp.Body.Close() | ||
|
||
body, err := ioutil.ReadAll(resp.Body) |
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.
io.ReadAll
viper.SetDefault(replicationChangeRequeueTimeFlg, 10) | ||
replicationChangeRequeueTimeInSeconds = viper.GetInt(replicationChangeRequeueTimeFlg) | ||
replicationChangeRequeueDuration := time.Duration(replicationChangeRequeueTimeInSeconds) * time.Second |
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.
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) |
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.
Can use http.MethodGet
|
||
body, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
r.Log.Info("could not read body") |
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.
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") |
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.
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 |
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.
Exponential backoff might be better on Patroni API unavailability
Resolve conflicts and merge! |
No description provided.