Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Commit adcf2f0

Browse files
committed
Merge branch 'dmius-a002-rec-fix' into 'master'
Fix A002 conclusion message See merge request postgres-ai/postgres-checkup!316
2 parents a025934 + 592bb4f commit adcf2f0

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

pghrep/src/checkup/a002/a002.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,32 @@ func A002CheckMinorVersions(report A002Report, result checkup.ReportOutcome) che
190190
updateVersions = append(updateVersions, hostData.Data.ServerMajorVer+"."+strconv.Itoa(lastVersion))
191191
}
192192
}
193-
if len(updateHosts) > 0 {
194-
result.AppendConclusion(english.PluralWord(len(updateHosts),
193+
curVersions = getUniques(curVersions)
194+
if len(curVersions) > 0 {
195+
result.AppendConclusion(english.PluralWord(len(curVersions),
195196
MSG_NOT_LAST_MINOR_VERSION_CONCLUSION_1, MSG_NOT_LAST_MINOR_VERSION_CONCLUSION_N),
196-
strings.Join(updateHosts, ", "), strings.Join(curVersions, ", "), updateVersions[0])
197+
strings.Join(curVersions, ", "), updateVersions[0])
197198
result.AppendRecommendation(MSG_NOT_LAST_MINOR_VERSION_RECOMMENDATION, updateVersions[0])
198199
result.P2 = true
199200
}
200201
return result
201202
}
202203

204+
func getUniques(array []string) []string {
205+
items := map[string]bool{}
206+
for _, item := range array {
207+
items[item] = true
208+
}
209+
210+
res := make([]string, len(items))
211+
i := 0
212+
for key, _ := range items {
213+
res[i] = key
214+
i++
215+
}
216+
return res
217+
}
218+
203219
func A002Process(report A002Report) checkup.ReportOutcome {
204220
var result checkup.ReportOutcome
205221
A002PrepareVersionInfo()
@@ -215,7 +231,7 @@ func A002PreprocessReportData(data map[string]interface{}) {
215231
var report A002Report
216232
err := json.Unmarshal(jsonRaw, &report)
217233
if err != nil {
218-
log.Err("Can't load json report to process")
234+
log.Err("Cannot load json report to process")
219235
return
220236
}
221237
result := A002Process(report)

pghrep/src/checkup/a002/a002messages.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ const MSG_SUPPORTED_VERSION_CONCLUSION string = "Postgres major version being us
1818
"of bugs and security issues, updates (new minor versions) with fixes will be released and available for use." +
1919
" Read more: [Versioning Policy](https://www.postgresql.org/support/versioning/)."
2020
const MSG_LAST_MINOR_VERSION_CONCLUSION string = "%s is the most up-to-date Postgres minor version in the branch %s."
21-
const MSG_NOT_LAST_MINOR_VERSION_CONCLUSION_1 string = "[P2] Node %s use not the most up-to-date installed minor version%s %s, the newest minor version is %s)."
22-
const MSG_NOT_LAST_MINOR_VERSION_CONCLUSION_N string = "[P2] Nodes %s use not the most up-to-date installed minor versions %s respectively, the newest minor version is %s)."
23-
21+
const MSG_NOT_LAST_MINOR_VERSION_CONCLUSION_1 string = "[P2] The minor version being used (%s) is not up-to-date (%s)."
22+
const MSG_NOT_LAST_MINOR_VERSION_CONCLUSION_N string = "[P2] The minor versions being used (%s) are not up-to-date (%s)."
2423
const MSG_NOT_ALL_VERSIONS_SAME_CONCLUSION_1 string = "[P2] Not all nodes have the same Postgres version. Node %s uses Postgres %s."
2524
const MSG_NOT_ALL_VERSIONS_SAME_CONCLUSION_N string = "[P2] Not all nodes have the same Postgres version. Nodes %s uses Postgres %s respectively."
2625
const MSG_NOT_ALL_VERSIONS_SAME_RECOMMENDATION string = "[P2] Please upgrade Postgres so its versions on all nodes match."

0 commit comments

Comments
 (0)