mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-06 14:31:40 +02:00
Enable promote/demote standby via operator
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -23,6 +23,7 @@ const (
|
||||
type Interface interface {
|
||||
Switchover(master *v1.Pod, candidate string) error
|
||||
SetPostgresParameters(server *v1.Pod, options map[string]string) error
|
||||
EditStandby(server *v1.Pod, options map[string]string) error
|
||||
}
|
||||
|
||||
// Patroni API client
|
||||
@@ -102,3 +103,14 @@ func (p *Patroni) SetPostgresParameters(server *v1.Pod, parameters map[string]st
|
||||
}
|
||||
return p.httpPostOrPatch(http.MethodPatch, apiURL(server)+configPath, buf)
|
||||
}
|
||||
|
||||
//SetPostgresParameters sets Postgres options via Patroni patch API call.
|
||||
func (p *Patroni) EditStandby(server *v1.Pod, options map[string]string) error {
|
||||
buf := &bytes.Buffer{}
|
||||
err := json.NewEncoder(buf).Encode(map[string]map[string]interface{}{"standby_cluster": {"restore_command": options}})
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not encode json: %v", err)
|
||||
}
|
||||
return p.httpPostOrPatch(http.MethodPatch, apiURL(server)+configPath, buf)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user