Skip to content

Commit

Permalink
Merge pull request #516 from sgotti/report_and_save_postgres_binary_v…
Browse files Browse the repository at this point in the history
…ersion

*: report and save postgres binary version
  • Loading branch information
sgotti committed Jun 16, 2018
2 parents 0299758 + be92998 commit 6c47055
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
24 changes: 14 additions & 10 deletions cmd/keeper/cmd/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,6 @@ func (p *PostgresKeeper) createPGParameters(db *cluster.DB) common.Parameters {
for _, synchronousStandby := range db.Spec.ExternalSynchronousStandbys {
synchronousStandbys = append(synchronousStandbys, synchronousStandby)
}
// TODO(sgotti) Find a way to detect the pg major version also
// when the instance is empty. Parsing the postgres --version
// is not always reliable (for example we can get `10devel` for
// development version).
// Now this will lead to problems starting the instance (or
// warning reloading the parameters) with postgresql < 9.6

// We deliberately don't use postgres FIRST or ANY methods with N
// different than len(synchronousStandbys) because we need that all the
Expand Down Expand Up @@ -533,11 +527,21 @@ func (p *PostgresKeeper) updateKeeperInfo() error {
return nil
}

maj, min, err := p.pgm.BinaryVersion()
if err != nil {
// in case we fail to parse the binary version then log it and just report maj and min as 0
log.Warnf("failed to get postgres binary version: %v", err)
}

keeperInfo := &cluster.KeeperInfo{
InfoUID: common.UID(),
UID: keeperUID,
ClusterUID: clusterUID,
BootUUID: p.bootUUID,
InfoUID: common.UID(),
UID: keeperUID,
ClusterUID: clusterUID,
BootUUID: p.bootUUID,
PostgresBinaryVersion: cluster.PostgresBinaryVersion{
Maj: maj,
Min: min,
},
PostgresState: p.getLastPGState(),
}

Expand Down
2 changes: 2 additions & 0 deletions cmd/sentinel/cmd/sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ func (s *Sentinel) updateKeepersStatus(cd *cluster.ClusterData, keepersInfo clus
s.CleanKeeperError(keeperUID)
// Update keeper status infos
k.Status.BootUUID = ki.BootUUID
k.Status.PostgresBinaryVersion.Maj = ki.PostgresBinaryVersion.Maj
k.Status.PostgresBinaryVersion.Min = ki.PostgresBinaryVersion.Min
}
}

Expand Down
7 changes: 7 additions & 0 deletions internal/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ type FollowConfig struct {
StandbySettings *StandbySettings `json:"standbySettings,omitempty"`
}

type PostgresBinaryVersion struct {
Maj int
Min int
}

type ClusterPhase string

const (
Expand Down Expand Up @@ -530,6 +535,8 @@ type KeeperStatus struct {
LastHealthyTime time.Time `json:"lastHealthyTime,omitempty"`

BootUUID string `json:"bootUUID,omitempty"`

PostgresBinaryVersion PostgresBinaryVersion `json:"postgresBinaryVersion,omitempty"`
}

type Keeper struct {
Expand Down
2 changes: 2 additions & 0 deletions internal/cluster/member.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type KeeperInfo struct {
ClusterUID string `json:"clusterUID,omitempty"`
BootUUID string `json:"bootUUID,omitempty"`

PostgresBinaryVersion PostgresBinaryVersion `json:"postgresBinaryVersion,omitempty"`

PostgresState *PostgresState `json:"postgresState,omitempty"`
}

Expand Down

0 comments on commit 6c47055

Please sign in to comment.