diff --git a/cmd/keeper/cmd/keeper.go b/cmd/keeper/cmd/keeper.go index f37a90b59..b6ce4ffd5 100644 --- a/cmd/keeper/cmd/keeper.go +++ b/cmd/keeper/cmd/keeper.go @@ -579,9 +579,10 @@ func (p *PostgresKeeper) updateKeeperInfo() error { Min: min, }, + PostgresState: p.getLastPGState(), + NeverMaster: p.neverMaster, NeverSynchronousReplica: p.neverSynchronousReplica, - PostgresState: p.getLastPGState(), } // The time to live is just to automatically remove old entries, it's diff --git a/cmd/sentinel/cmd/sentinel.go b/cmd/sentinel/cmd/sentinel.go index f39e95a3f..1b3c2f29a 100644 --- a/cmd/sentinel/cmd/sentinel.go +++ b/cmd/sentinel/cmd/sentinel.go @@ -229,13 +229,13 @@ func (s *Sentinel) updateKeepersStatus(cd *cluster.ClusterData, keepersInfo clus } } - // Keepers support several command line arguments that should be populated in the - // KeeperSpec by the sentinel. This allows us to make decisions about how to arrange - // the cluster that take into consideration the configuration of each keeper. + // Keepers support several command line arguments that should be populated in the + // KeeperStatus by the sentinel. This allows us to make decisions about how to arrange + // the cluster that take into consideration the configuration of each keeper. for keeperUID, k := range cd.Keepers { if ki, ok := keepersInfo[keeperUID]; ok { - k.Spec.NeverMaster = ki.NeverMaster - k.Spec.NeverSynchronousReplica = ki.NeverSynchronousReplica + k.Status.NeverMaster = ki.NeverMaster + k.Status.NeverSynchronousReplica = ki.NeverSynchronousReplica } } @@ -741,7 +741,7 @@ func (s *Sentinel) findBestStandbys(cd *cluster.ClusterData, masterDB *cluster.D func (s *Sentinel) findBestNewMasters(cd *cluster.ClusterData, masterDB *cluster.DB) []*cluster.DB { bestNewMasters := []*cluster.DB{} for _, db := range s.findBestStandbys(cd, masterDB) { - if k, ok := cd.Keepers[db.Spec.KeeperUID]; ok && k.Spec.NeverMaster { + if k, ok := cd.Keepers[db.Spec.KeeperUID]; ok && k.Status.NeverMaster { log.Infow("ignoring keeper since it cannot be master (--never-master)", "db", db.UID, "keeper", db.Spec.KeeperUID) continue } @@ -1344,7 +1344,7 @@ func (s *Sentinel) updateCluster(cd *cluster.ClusterData, pis cluster.ProxiesInf // ignore standbys that cannot be synchronous standbys if db, ok := newcd.DBs[bestStandby.UID]; ok { - if keeper, ok := newcd.Keepers[db.Spec.KeeperUID]; ok && keeper.Spec.NeverSynchronousReplica { + if keeper, ok := newcd.Keepers[db.Spec.KeeperUID]; ok && keeper.Status.NeverSynchronousReplica { log.Infow("cannot choose standby as synchronous (--never-synchronous-replica)", "db", db.UID, "keeper", keeper.UID) continue } diff --git a/internal/cluster/cluster.go b/internal/cluster/cluster.go index 25c355d84..6fa2ed5ee 100644 --- a/internal/cluster/cluster.go +++ b/internal/cluster/cluster.go @@ -549,10 +549,7 @@ func NewCluster(uid string, cs *ClusterSpec) *Cluster { return c } -type KeeperSpec struct { - NeverMaster bool `json:"neverMaster,omitempty"` - NeverSynchronousReplica bool `json:"neverSynchronousReplica,omitempty"` -} +type KeeperSpec struct{} type KeeperStatus struct { Healthy bool `json:"healthy,omitempty"` @@ -563,6 +560,9 @@ type KeeperStatus struct { PostgresBinaryVersion PostgresBinaryVersion `json:"postgresBinaryVersion,omitempty"` ForceFail bool `json:"forceFail,omitempty"` + + NeverMaster bool `json:"neverMaster,omitempty"` + NeverSynchronousReplica bool `json:"neverSynchronousReplica,omitempty"` } type Keeper struct {