return of GetConfigOrStatus
This commit is contained in:
parent
8b169b5857
commit
132122dff3
|
|
@ -399,7 +399,7 @@ func (c *Cluster) syncStatefulSet() error {
|
||||||
podName := util.NameFromMeta(pods[i].ObjectMeta)
|
podName := util.NameFromMeta(pods[i].ObjectMeta)
|
||||||
patroniConfig, pgParameters, err := c.patroni.GetConfig(&pod)
|
patroniConfig, pgParameters, err := c.patroni.GetConfig(&pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Warningf("could not get Postgres config from pod %s: %#v, %v", podName, patroniConfig, err)
|
c.logger.Warningf("could not get Postgres config from pod %s: %v", podName, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -196,23 +196,28 @@ type MemberData struct {
|
||||||
Patroni MemberDataPatroni `json:"patroni"`
|
Patroni MemberDataPatroni `json:"patroni"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Patroni) GetStatus(server *v1.Pod) (map[string]interface{}, error) {
|
func (p *Patroni) GetConfigOrStatus(server *v1.Pod, path string) (string, error) {
|
||||||
result := make(map[string]interface{})
|
|
||||||
apiURLString, err := apiURL(server)
|
apiURLString, err := apiURL(server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return "", err
|
||||||
}
|
}
|
||||||
|
result, err := p.httpGet(apiURLString + path)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
body, err := p.httpGet(apiURLString + statusPath)
|
func (p *Patroni) GetStatus(server *v1.Pod) (map[string]interface{}, error) {
|
||||||
|
result := make(map[string]interface{})
|
||||||
|
body, err := p.GetConfigOrStatus(server, statusPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(body), &result)
|
err = json.Unmarshal([]byte(body), &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -221,16 +226,10 @@ func (p *Patroni) GetConfig(server *v1.Pod) (acidv1.Patroni, map[string]string,
|
||||||
patroniConfig acidv1.Patroni
|
patroniConfig acidv1.Patroni
|
||||||
pgConfig map[string]interface{}
|
pgConfig map[string]interface{}
|
||||||
)
|
)
|
||||||
|
body, err := p.GetConfigOrStatus(server, configPath)
|
||||||
apiURLString, err := apiURL(server)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return patroniConfig, nil, err
|
return patroniConfig, nil, err
|
||||||
}
|
}
|
||||||
body, err := p.httpGet(apiURLString + configPath)
|
|
||||||
if err != nil {
|
|
||||||
return patroniConfig, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(body), &patroniConfig)
|
err = json.Unmarshal([]byte(body), &patroniConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return patroniConfig, nil, err
|
return patroniConfig, nil, err
|
||||||
|
|
@ -265,10 +264,7 @@ func (p *Patroni) Restart(server *v1.Pod) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
status, err := p.GetStatus(server)
|
status, _ := p.GetStatus(server)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
pending_restart, ok := status["pending_restart"]
|
pending_restart, ok := status["pending_restart"]
|
||||||
if !ok || !pending_restart.(bool) {
|
if !ok || !pending_restart.(bool) {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue