Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions operator/pkg/disasterrecovery/patroni.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,17 @@ func (m *PatroniDRManager) processHealthRequest(response http.ResponseWriter, re
if err == nil {
isHealthy := m.patroniHelper.IsPatroniClusterHealthy(config)
isDegraded := m.patroniHelper.IsPatroniClusterDegraded(config, m.cluster.PgHost)
reconcileSuccessfull := m.helper.GetCurrentCRStatus() == "successful"
if isHealthy && !isDegraded {
log.Info("Patroni cluster is healthy")
status = "up"
}
if isDegraded {
log.Info("Patroni cluster is degraded")
status = "degraded"
}
if !reconcileSuccessfull {
log.Info("Reconcile status is not successful, setting health status to degraded")
status = "degraded"
}
}
Expand Down
9 changes: 9 additions & 0 deletions operator/pkg/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ func (h *Helper) GetCurrentSiteManagerStatus() *qubershipv1.SiteManagerStatus {
return nil
}

func (h *Helper) GetCurrentCRStatus() string {
if cr, err := h.GetPostgresServiceCR(); err == nil {
if len(cr.Status.Conditions) > 0 {
return strings.ToLower(cr.Status.Conditions[0].Type)
}
}
return ""
}

//
//func (h *Helper) UpdateSiteManagerStatusWithRetry(mode string, status string, clusterName string, patroniUrl string, pgHost string) error {
// patroniReg := fmt.Sprintf("pg-%s-node", clusterName)
Expand Down
Loading