Skip to content

Commit

Permalink
add checklist for v5 for postgres
Browse files Browse the repository at this point in the history
Signed-off-by: Sahiba3108 <[email protected]>
  • Loading branch information
Sahiba3108 committed Dec 11, 2024
1 parent 0482069 commit a05dc82
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 15 deletions.
18 changes: 9 additions & 9 deletions components/automate-deployment/pkg/majorupgradechecklist/v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
initMsg = `This is a Major upgrade.
========================
1) In this release Embedded PostgreSQL is upgraded to version 13.5
1) In this release Embedded PostgreSQL is upgraded to version %v
2) This will need special care if you use Embedded PostgreSQL.
===== Your installation is using %s PostgreSQL =====
Expand All @@ -35,7 +35,7 @@ const (
$ ` + run_chef_automate_upgrade_status_cmd + `
This should return: Automate is up-to-date`

run_pg_data_migrate = `Migrate Data from PG 9.6 to PG 13.5 using this command:
run_pg_data_migrate = `Migrate Data from PG %v to PG %v using this command:
$ ` + run_pg_data_migrate_cmd

run_pg_data_migrate_cmd = `chef-automate post-major-upgrade migrate --data=pg`
Expand All @@ -44,7 +44,7 @@ const (
run_chef_automate_status = `Check all services are running using:
$ chef-automate status`

run_pg_data_cleanup = `If you are sure all data is available in Upgraded Automate, then we can free up old PostgreSQL 9.6 Data by running:
run_pg_data_cleanup = `If you are sure all data is available in Upgraded Automate, then we can free up old PostgreSQL %v Data by running:
$ ` + run_pg_data_cleanup_cmd

run_pg_data_cleanup_cmd = `chef-automate post-major-upgrade clear-data --data=PG`
Expand All @@ -70,7 +70,7 @@ var postChecklistEmbedded = []PostCheckListItem{
IsExecuted: false,
}, {
Id: "migrate_pg",
Msg: run_pg_data_migrate,
Msg: fmt.Sprintf(run_pg_data_migrate, 9.6, 13.5),
Cmd: run_pg_data_migrate_cmd,
IsExecuted: false,
}, {
Expand All @@ -81,7 +81,7 @@ var postChecklistEmbedded = []PostCheckListItem{
IsExecuted: false,
}, {
Id: "clean_up",
Msg: run_pg_data_cleanup,
Msg: fmt.Sprintf(run_pg_data_cleanup, 9.6),
Cmd: run_pg_data_cleanup_cmd,
Optional: true,
IsExecuted: false,
Expand Down Expand Up @@ -158,7 +158,7 @@ func (ci *V3ChecklistManager) RunChecklist(timeout int64, flags ChecklistUpgrade
if ci.isExternalPG {
dbType = "External"
postcheck = postChecklistExternal
checklists = append(checklists, []Checklist{downTimeCheck(), backupCheck(), replaceS3Url(), externalPGUpgradeCheck(), postChecklistIntimationCheck()}...)
checklists = append(checklists, []Checklist{downTimeCheck(), backupCheck(), replaceS3Url(), externalPGUpgradeCheck(9.6, 13.5), postChecklistIntimationCheck()}...)
} else {
dbType = "Embedded"
postcheck = postChecklistEmbedded
Expand All @@ -170,7 +170,7 @@ func (ci *V3ChecklistManager) RunChecklist(timeout int64, flags ChecklistUpgrade
Writer: ci.writer,
}

ci.writer.Println(fmt.Sprintf(initMsg, dbType, ci.version)) //display the init message
ci.writer.Println(fmt.Sprintf(initMsg, 13.5, dbType, ci.version)) //display the init message

for _, item := range checklists {
if item.TestFunc == nil {
Expand Down Expand Up @@ -272,12 +272,12 @@ func postChecklistIntimationCheck() Checklist {
}
}

func externalPGUpgradeCheck() Checklist {
func externalPGUpgradeCheck(current_version, target_version float64) Checklist {
return Checklist{
Name: "external_pg_upgrade_acceptance",
Description: "confirmation check for external PG upgrade",
TestFunc: func(h ChecklistHelper) error {
resp, err := h.Writer.Confirm("Upgrade your PostgreSQL 9.6 to 13.5 with the help of your Database Administrator")
resp, err := h.Writer.Confirm(fmt.Sprintf("Upgrade your PostgreSQL %v to %v with the help of your Database Administrator", current_version, target_version))
if err != nil {
h.Writer.Error(err.Error())
return status.Errorf(status.InvalidCommandArgsError, err.Error())
Expand Down
67 changes: 61 additions & 6 deletions components/automate-deployment/pkg/majorupgradechecklist/v5.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,61 @@ import (
"github.com/pkg/errors"
)

var postChecklistEmbeddedV5 = []PostCheckListItem{
{
Id: "upgrade_status",
Msg: run_chef_automate_upgrade_status,
Cmd: run_chef_automate_upgrade_status_cmd,
Optional: true,
IsExecuted: false,
}, {
Id: "migrate_pg",
Msg: fmt.Sprintf(run_pg_data_migrate, 13.5, 17.0),
Cmd: run_pg_data_migrate_cmd,
IsExecuted: false,
}, {
Id: "check_ui",
Msg: ui_check,
Cmd: "",
Optional: true,
IsExecuted: false,
}, {
Id: "clean_up",
Msg: fmt.Sprintf(run_pg_data_cleanup, 13.5),
Cmd: run_pg_data_cleanup_cmd,
Optional: true,
IsExecuted: false,
},
}

var postChecklistExternalV5 = []PostCheckListItem{
{
Id: "patch_new_config",
Msg: patch_new_conf,
Cmd: patch_new_conf_cmd,
Optional: true,
IsExecuted: false,
}, {
Id: "upgrade_status",
Msg: run_chef_automate_upgrade_status,
Cmd: run_chef_automate_upgrade_status_cmd,
Optional: true,
IsExecuted: false,
}, {
Id: "status",
Msg: run_chef_automate_status,
Cmd: run_chef_automate_status_cmd,
Optional: true,
IsExecuted: false,
}, {
Id: "check_ui",
Msg: ui_check,
Cmd: "",
Optional: true,
IsExecuted: false,
},
}

type V5ChecklistManager struct {
writer cli.FormatWriter
version string
Expand All @@ -24,9 +79,9 @@ func NewV5ChecklistManager(writer cli.FormatWriter, version string) *V5Checklist
func (ci *V5ChecklistManager) GetPostChecklist() []PostCheckListItem {
var postChecklist []PostCheckListItem
if ci.isExternalPG {
postChecklist = postChecklistExternal
postChecklist = postChecklistExternalV5
} else {
postChecklist = postChecklistEmbedded
postChecklist = postChecklistEmbeddedV5
}
return postChecklist
}
Expand All @@ -39,11 +94,11 @@ func (ci *V5ChecklistManager) RunChecklist(timeout int64, flags ChecklistUpgrade

if ci.isExternalPG {
dbType = "External"
postcheck = postChecklistExternal
checklists = append(checklists, []Checklist{downTimeCheck(), backupCheck(), externalPGUpgradeCheck(), postChecklistIntimationCheck()}...)
postcheck = postChecklistExternalV5
checklists = append(checklists, []Checklist{downTimeCheck(), backupCheck(), externalPGUpgradeCheck(13.5, 17.0), postChecklistIntimationCheck()}...)
} else {
dbType = "Embedded"
postcheck = postChecklistEmbedded
postcheck = postChecklistEmbeddedV5
checklists = append(checklists, []Checklist{diskSpaceCheck(ci.version, flags.SkipStorageCheck, flags.OsDestDataDir), downTimeCheck(), backupCheck(), postChecklistIntimationCheck()}...)
}
checklists = append(checklists, showPostChecklist(&postcheck), promptUpgradeContinue())
Expand All @@ -52,7 +107,7 @@ func (ci *V5ChecklistManager) RunChecklist(timeout int64, flags ChecklistUpgrade
Writer: ci.writer,
}

ci.writer.Println(fmt.Sprintf(initMsg, dbType, ci.version)) //display the init message
ci.writer.Println(fmt.Sprintf(initMsg, 17.0, dbType, ci.version)) //display the init message

for _, item := range checklists {
if item.TestFunc == nil {
Expand Down

0 comments on commit a05dc82

Please sign in to comment.